From 521ed565b435b835eeab1e2dae31554dabc04af3 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 30 Oct 2013 13:56:10 +1100 Subject: [PATCH] Modify specs to create enterprise groups where needed --- .../enterprises_distributor_info_rich_text_feature_spec.rb | 1 + spec/features/consumer/browse_products_spec.rb | 2 ++ spec/features/consumer/checkout_spec.rb | 2 ++ spec/features/consumer/cms_spec.rb | 3 ++- spec/features/consumer/distributors_spec.rb | 1 + spec/features/consumer/order_cycles_spec.rb | 4 ++++ spec/spec_helper.rb | 1 + spec/support/enterprise_groups_helper.rb | 7 +++++++ 8 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 spec/support/enterprise_groups_helper.rb diff --git a/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb b/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb index acf32dbcf5..b0c985d423 100644 --- a/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb +++ b/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb @@ -92,6 +92,7 @@ feature "enterprises distributor info as rich text" do ActionMailer::Base.deliveries.clear d = create(:distributor_enterprise, name: 'Green Grass', distributor_info: 'Chu ge sai yubi dan bisento tobi ashi yubi ge omote.', next_collection_at: 'Thursday 2nd May') + create_enterprise_group_for d p = create(:product) oc = create(:simple_order_cycle, distributors: [d], variants: [p.master]) ex = oc.exchanges.outgoing.last diff --git a/spec/features/consumer/browse_products_spec.rb b/spec/features/consumer/browse_products_spec.rb index 28a4b66170..c14f290ac7 100644 --- a/spec/features/consumer/browse_products_spec.rb +++ b/spec/features/consumer/browse_products_spec.rb @@ -27,6 +27,7 @@ feature %q{ it "displays the distributor's name on the home page" do # Given a distributor with a product d = create(:distributor_enterprise, :name => 'Melb Uni Co-op', :description => '

Hello, world!

') + create_enterprise_group_for d p1 = create(:product, :distributors => [d]) # When I select the distributor @@ -70,6 +71,7 @@ feature %q{ # Given a product with two variants s = create(:supplier_enterprise) d = create(:distributor_enterprise, name: 'Green Grass') + create_enterprise_group_for d p = create(:simple_product, supplier: s) v1 = create(:variant, product: p, is_master: false) v2 = create(:variant, product: p, is_master: false) diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index 31dac80149..3650718b9d 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -229,6 +229,7 @@ feature %q{ scenario "changing distributor updates delivery fees", :future => true do # Given two distributors and enterprise fees d1 = create(:distributor_enterprise, :name => "FruitAndVeg") + create_enterprise_group_for d1 d2 = create(:distributor_enterprise) ef1 = create(:enterprise_fee, calculator: Spree::Calculator::PerItem.new) ef1.calculator.set_preference :amount, 1.23; ef1.calculator.save! @@ -527,6 +528,7 @@ feature %q{ # Distributors distributor1 = FactoryGirl.create(:distributor_enterprise, name: "FruitAndVeg") distributor2 = FactoryGirl.create(:distributor_enterprise, name: "MoreFreshStuff") + create_enterprise_group_for distributor1 distributor_fee1 = create(:enterprise_fee, enterprise: distributor1, fee_type: 'packing', amount: 7) distributor_fee2 = create(:enterprise_fee, enterprise: distributor1, fee_type: 'transport', amount: 8) distributor_fee3 = create(:enterprise_fee, enterprise: distributor2, fee_type: 'admin', amount: 9) diff --git a/spec/features/consumer/cms_spec.rb b/spec/features/consumer/cms_spec.rb index cc1daedae7..36653bea01 100644 --- a/spec/features/consumer/cms_spec.rb +++ b/spec/features/consumer/cms_spec.rb @@ -9,7 +9,8 @@ feature %q{ include WebHelper background do - create(:distributor_enterprise, :name => 'Edible garden') + d = create(:distributor_enterprise, :name => 'Edible garden') + create_enterprise_group_for d end scenario "viewing shop front does not display home page content" do diff --git a/spec/features/consumer/distributors_spec.rb b/spec/features/consumer/distributors_spec.rb index b8c62f7428..f4652ac5b9 100644 --- a/spec/features/consumer/distributors_spec.rb +++ b/spec/features/consumer/distributors_spec.rb @@ -90,6 +90,7 @@ feature %q{ # Given some distributors with products d1 = create(:distributor_enterprise, :name => "Edible garden", :long_description => "

Hello, world!

") d2 = create(:distributor_enterprise) + create_enterprise_group_for d1 p1 = create(:product, :distributors => [d1]) p2 = create(:product, :distributors => [d2]) supplier = create(:supplier_enterprise) diff --git a/spec/features/consumer/order_cycles_spec.rb b/spec/features/consumer/order_cycles_spec.rb index 5ea99f7690..c34eabaecf 100644 --- a/spec/features/consumer/order_cycles_spec.rb +++ b/spec/features/consumer/order_cycles_spec.rb @@ -34,6 +34,7 @@ feature %q{ scenario "selecting order cycle when multiple options are available", js: true do d = create(:distributor_enterprise, name: 'Green Grass') + create_enterprise_group_for d oc1 = create(:simple_order_cycle, name: 'oc 1', distributors: [d]) oc2 = create(:simple_order_cycle, name: 'oc 2', distributors: [d]) @@ -48,6 +49,7 @@ feature %q{ scenario "when there are no available order cycles" do Timecop.freeze do d = create(:distributor_enterprise, name: 'Green Grass') + create_enterprise_group_for d oc1 = create(:simple_order_cycle, name: 'oc 1', distributors: [d], orders_close_at: 5.minutes.ago) visit spree.root_path @@ -65,6 +67,7 @@ feature %q{ scenario "changing order cycle", js: true do s = create(:supplier_enterprise) d = create(:distributor_enterprise, name: 'Green Grass') + create_enterprise_group_for d p = create(:simple_product, supplier: s) oc = create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.master]) @@ -110,6 +113,7 @@ feature %q{ scenario "order cycle expires mid-order" do d = create(:distributor_enterprise, name: 'Green Grass', email: 'd@example.com', phone: '1029 3847') + create_enterprise_group_for d p = create(:simple_product) oc = create(:simple_order_cycle, name: 'oc', distributors: [d], variants: [p.master]) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3edbba9ea6..1ee17cbf40 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -88,6 +88,7 @@ RSpec.configure do |config| config.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller config.include Devise::TestHelpers, :type => :controller config.include OpenFoodNetwork::FeatureToggleHelper + config.include OpenFoodNetwork::EnterpriseGroupsHelper config.include ActionView::Helpers::DateHelper # Factory girl diff --git a/spec/support/enterprise_groups_helper.rb b/spec/support/enterprise_groups_helper.rb new file mode 100644 index 0000000000..d8bf46017f --- /dev/null +++ b/spec/support/enterprise_groups_helper.rb @@ -0,0 +1,7 @@ +module OpenFoodNetwork + module EnterpriseGroupsHelper + def create_enterprise_group_for(distributor) + create(:enterprise_group, on_front_page: true, enterprises: [distributor]) + end + end +end