Modify specs to create enterprise groups where needed

This commit is contained in:
Rohan Mitchell
2013-10-30 13:56:10 +11:00
parent 57a450b0aa
commit 521ed565b4
8 changed files with 20 additions and 1 deletions

View File

@@ -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 <strong>bisento</strong> 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

View File

@@ -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 => '<p>Hello, world!</p>')
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)

View File

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

View File

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

View File

@@ -90,6 +90,7 @@ feature %q{
# Given some distributors with products
d1 = create(:distributor_enterprise, :name => "Edible garden", :long_description => "<p>Hello, world!</p>")
d2 = create(:distributor_enterprise)
create_enterprise_group_for d1
p1 = create(:product, :distributors => [d1])
p2 = create(:product, :distributors => [d2])
supplier = create(:supplier_enterprise)

View File

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

View File

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

View File

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