diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 36084c0225..e5535b71ad 100644 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -26,6 +26,8 @@ class BaseController < ApplicationController @order_cycles = OrderCycle.with_distributor(@distributor).active .order(@distributor.preferred_shopfront_order_cycle_order) + ensure_shop_ready + applicator = OpenFoodNetwork::TagRuleApplicator.new(@distributor, "FilterOrderCycles", current_customer.andand.tag_list) applicator.filter!(@order_cycles) @@ -34,4 +36,9 @@ class BaseController < ApplicationController current_order(true).set_order_cycle! @order_cycles.first end end + + def ensure_shop_ready + # Don't display order cycles if shop is not ready for checkout + @order_cycles = {} unless @distributor.ready_for_checkout? + end end diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index c3784df428..eac8a399d2 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -1,7 +1,9 @@ require 'spec_helper' describe ShopController do - let(:distributor) { create(:distributor_enterprise) } + let!(:pm) { create(:payment_method) } + let!(:sm) { create(:shipping_method) } + let(:distributor) { create(:distributor_enterprise, payment_methods: [pm], shipping_methods: [sm]) } it "redirects to the home page if no distributor is selected" do spree_get :show