diff --git a/lib/open_food_network/enterprise_injection_data.rb b/lib/open_food_network/enterprise_injection_data.rb index 938c8b3aab..2c8b470069 100644 --- a/lib/open_food_network/enterprise_injection_data.rb +++ b/lib/open_food_network/enterprise_injection_data.rb @@ -1,7 +1,7 @@ module OpenFoodNetwork class EnterpriseInjectionData def active_distributors - @active_distributors ||= Enterprise.distributors_with_active_order_cycles + @active_distributors ||= Enterprise.distributors_with_active_order_cycles.andand.ready_for_checkout end def earliest_closing_times diff --git a/spec/features/consumer/shops_spec.rb b/spec/features/consumer/shops_spec.rb index c9e8063e72..082bf57d79 100644 --- a/spec/features/consumer/shops_spec.rb +++ b/spec/features/consumer/shops_spec.rb @@ -6,8 +6,8 @@ feature 'Shops', js: true do let!(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) } let!(:invisible_distributor) { create(:distributor_enterprise, visible: false) } - let(:d1) { create(:distributor_enterprise) } - let(:d2) { create(:distributor_enterprise) } + let!(:d1) { create(:distributor_enterprise, with_payment_and_shipping: true) } + let!(:d2) { create(:distributor_enterprise, with_payment_and_shipping: true) } let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) } let!(:producer) { create(:supplier_enterprise) } let!(:er) { create(:enterprise_relationship, parent: distributor, child: producer) } @@ -57,6 +57,20 @@ feature 'Shops', js: true do end end + describe "showing available hubs" do + let!(:hub) { create(:distributor_enterprise, with_payment_and_shipping: false) } + let!(:order_cycle) { create(:simple_order_cycle, distributors: [hub], coordinator: hub) } + let!(:producer) { create(:supplier_enterprise) } + let!(:er) { create(:enterprise_relationship, parent: hub, child: producer) } + + it "does not show hubs that are not ready for checkout" do + visit shops_path + + Enterprise.ready_for_checkout.should_not include hub + page.should_not have_content hub.name + end + end + describe "filtering by product property" do let!(:order_cycle) { create(:simple_order_cycle, distributors: [d1, d2], coordinator: create(:distributor_enterprise)) } let!(:p1) { create(:simple_product, supplier: producer) } @@ -92,7 +106,7 @@ feature 'Shops', js: true do describe "taxon badges" do let!(:closed_oc) { create(:closed_order_cycle, distributors: [shop], variants: [p_closed.variants.first]) } let!(:p_closed) { create(:simple_product, taxons: [taxon_closed]) } - let(:shop) { create(:distributor_enterprise) } + let(:shop) { create(:distributor_enterprise, with_payment_and_shipping: true) } let(:taxon_closed) { create(:taxon, name: 'Closed') } describe "open shops" do