Enterprise users can bulk edit inactive products

This commit is contained in:
Rohan Mitchell
2013-10-16 16:57:20 +11:00
parent 751801653e
commit e29497c5b4
2 changed files with 25 additions and 0 deletions

View File

@@ -4,4 +4,22 @@ Spree::Api::ProductsController.class_eval do
respond_with(@products, default_template: :index)
end
private
# Copied and modified from Spree::Api::BaseController to allow
# enterprise users to access inactive products
def product_scope
if current_api_user.has_spree_role?("admin") || current_api_user.enterprises.present? # This line modified
scope = Spree::Product
unless params[:show_deleted]
scope = scope.not_deleted
end
else
scope = Spree::Product.active
end
scope.includes(:master)
end
end

View File

@@ -442,6 +442,7 @@ feature %q{
let(:d2) { create(:distributor_enterprise, name: 'Another Distributor') }
let!(:product_supplied) { create(:product, supplier: s1, price: 10.0, on_hand: 6) }
let!(:product_not_supplied) { create(:product, supplier: s3) }
let!(:product_supplied_inactive) { create(:product, supplier: s1, price: 10.0, on_hand: 6, available_on: 1.week.from_now) }
before(:each) do
@enterprise_user = create_enterprise_user
@@ -466,6 +467,12 @@ feature %q{
page.should_not have_select 'supplier', with_options: [s3.name]
end
it "shows inactive products that I supply" do
visit '/admin/products/bulk_edit'
page.should have_field 'product_name', with: product_supplied_inactive.name
end
it "allows me to update a product" do
p = product_supplied