Skip to content

Commit

Permalink
Merge pull request #2677 from luisramos0/2-0-sample-data
Browse files Browse the repository at this point in the history
[Spree Upgrade] Fixed db:load_sample_data
  • Loading branch information
mkllnk authored Sep 18, 2018
2 parents 692101d + 145b438 commit 1130bb3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/tasks/dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,12 @@ namespace :openfoodnetwork do

enterprise2 = Enterprise.find_by_name('Enterprise 2')
enterprise2.sells = 'any'
enterprise2.shipping_methods.build(
name: 'Pickup',
zone_id: 3,
require_ship_address: true,
calculator_type: 'OpenFoodNetwork::Calculator::Weight',
distributor_ids: [enterprise2.id]
)
enterprise2.shipping_methods << FactoryBot.create(:shipping_method,
name: 'Pickup',
zone: zone,
require_ship_address: true,
calculator_type: 'OpenFoodNetwork::Calculator::Weight',
distributors: [enterprise2])
enterprise2.payment_methods << Spree::PaymentMethod.last
enterprise2.save!

Expand All @@ -200,7 +199,9 @@ namespace :openfoodnetwork do

CreateOrderCycle.new(enterprise2, variants).call

EnterpriseRole.create!(user: Spree::User.first, enterprise: enterprise2)
unless EnterpriseRole.where( user_id: Spree::User.first, enterprise_id: enterprise2 ).any?
EnterpriseRole.create!(user: Spree::User.first, enterprise: enterprise2)
end
end
end
end

0 comments on commit 1130bb3

Please sign in to comment.