From 1f2c6f2a85e2562f9aebfa269814bf24005abe7e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Tue, 4 Apr 2017 00:45:01 +0100 Subject: [PATCH] Ensure shops display as closed when not configured for sales squashme squashme squash squash squash --- app/controllers/base_controller.rb | 7 +++++++ spec/controllers/shop_controller_spec.rb | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) 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