Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uk/hub closed new #6

Merged
merged 2 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions app/controllers/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ class BaseController < ApplicationController
private

def set_order_cycles
unless @distributor.ready_for_checkout?
@order_cycles = OrderCycle.where('false')
return
end

@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)

Expand All @@ -36,9 +39,4 @@ def set_order_cycles
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
2 changes: 1 addition & 1 deletion lib/open_food_network/enterprise_injection_data.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module OpenFoodNetwork
class EnterpriseInjectionData
def active_distributors
@active_distributors ||= Enterprise.distributors_with_active_order_cycles.andand.ready_for_checkout
@active_distributors ||= Enterprise.distributors_with_active_order_cycles.ready_for_checkout
end

def earliest_closing_times
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/shops_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let!(:invisible_distributor) { create(:distributor_enterprise, visible: false) }

before do
Enterprise.stub_chain("distributors_with_active_order_cycles.andand.ready_for_checkout") { [distributor] }
Enterprise.stub_chain("distributors_with_active_order_cycles.ready_for_checkout") { [distributor] }
end

# Exclusion from actual rendered view handled in features/consumer/home
Expand Down