From a6add2eff6849ae0db8b3406f7a625912ccd4a8e Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 15 Dec 2016 16:03:46 +1100 Subject: [PATCH] Limiting shops loaded onto standing orders index to those with standing orders enabled --- app/controllers/admin/standing_orders_controller.rb | 2 +- spec/controllers/admin/standing_orders_controller_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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