From 577b1146624ac19dfc6dc04c5caf174790050e55 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 6 Aug 2013 14:23:38 +1000 Subject: [PATCH] Add distributor and supplier users to load_sample_data task --- lib/tasks/dev.rake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 50d9eaddfd..215ff342b0 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -43,6 +43,23 @@ namespace :openfoodweb do FactoryGirl.create(:itemwise_shipping_method) end + # -- Enterprise Users + unless Spree::User.count > 1 + puts "[#{task_name}] Seeding enterprise users" + + pw = "spree123" + + u = FactoryGirl.create(:user, email: "sup@example.com", password: pw, password_confirmation: pw) + u.enterprises << Enterprise.is_primary_producer.first + u.enterprises << Enterprise.is_primary_producer.second + puts " Supplier User created: #{u.email}/#{pw} (" + u.enterprise_roles.map{ |er| er.enterprise.name}.join(", ") + ")" + + u = FactoryGirl.create(:user, email: "dist@example.com", password: pw, password_confirmation: pw) + u.enterprises << Enterprise.is_distributor.first + u.enterprises << Enterprise.is_distributor.second + puts " Distributor User created: #{u.email}/#{pw} (" + u.enterprise_roles.map{ |er| er.enterprise.name}.join(", ") + ")" + end + # -- Products unless Spree::Product.count > 0 puts "[#{task_name}] Seeding products"