Hubs display as closed when not configured for payment or shipping

This commit is contained in:
Matt-Yorkley
2016-12-20 12:55:39 +00:00
committed by Maikel Linke
parent 775f9b3ada
commit f4eb9cb790
2 changed files with 18 additions and 4 deletions

View File

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

View File

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