diff --git a/app/controllers/spree/api/products_controller_decorator.rb b/app/controllers/spree/api/products_controller_decorator.rb index 3fc46108ab..7175ded8c1 100644 --- a/app/controllers/spree/api/products_controller_decorator.rb +++ b/app/controllers/spree/api/products_controller_decorator.rb @@ -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 diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index c7c4aabdd1..9141eb2783 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -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