diff --git a/app/controllers/admin/standing_orders_controller.rb b/app/controllers/admin/standing_orders_controller.rb index 36883bdc9d..3eb9d674f5 100644 --- a/app/controllers/admin/standing_orders_controller.rb +++ b/app/controllers/admin/standing_orders_controller.rb @@ -77,7 +77,7 @@ module Admin end def load_shops - @shops = Enterprise.managed_by(spree_current_user).is_distributor + @shops = Enterprise.managed_by(spree_current_user).is_distributor.where(enable_standing_orders: true) end def load_form_data diff --git a/spec/controllers/admin/standing_orders_controller_spec.rb b/spec/controllers/admin/standing_orders_controller_spec.rb index a4a98e1b76..aecd736301 100644 --- a/spec/controllers/admin/standing_orders_controller_spec.rb +++ b/spec/controllers/admin/standing_orders_controller_spec.rb @@ -5,7 +5,7 @@ describe Admin::StandingOrdersController, type: :controller do describe 'index' do let!(:user) { create(:user, enterprise_limit: 10) } - let!(:shop) { create(:distributor_enterprise) } + let!(:shop) { create(:distributor_enterprise, enable_standing_orders: true) } let!(:standing_order) { create(:standing_order, shop: shop) } before do @@ -24,6 +24,7 @@ describe Admin::StandingOrdersController, type: :controller do context 'as an enterprise user' do before { shop.update_attributes(owner: user) } + let!(:not_enabled_shop) { create(:distributor_enterprise, owner: user) } it 'renders the index page with appropriate data' do spree_get :index, params