Skip to content

Commit

Permalink
Merge pull request #6 from mkllnk/uk/hub_closed_new
Browse files Browse the repository at this point in the history
Merging mklink's updates
  • Loading branch information
Matt-Yorkley authored Apr 12, 2017
2 parents c52cbec + 46ea091 commit 9cd740c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
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

0 comments on commit 9cd740c

Please sign in to comment.