foodsoft/spec/factories/user.rb

37 lines
875 B
Ruby
Raw Normal View History

2013-07-12 20:06:49 +02:00
require 'factory_girl'
FactoryGirl.define do
factory :user do
sequence(:nick) { |n| "user#{n}"}
first_name { Faker::Name.first_name }
email { Faker::Internet.email }
2013-07-12 20:06:49 +02:00
password { new_random_password }
factory :admin do
sequence(:nick) { |n| "admin#{n}" }
first_name 'Administrator'
after :create do |user, evaluator|
2013-09-18 12:44:41 +02:00
create :workgroup, role_admin: true, user_ids: [user.id]
2013-07-12 20:06:49 +02:00
end
end
end
factory :group do
sequence(:name) {|n| "Group ##{n}"}
factory :workgroup do
type ''
end
factory :ordergroup do
type 'Ordergroup'
sequence(:name) {|n| "Order group ##{n}"}
2013-07-24 12:37:20 +02:00
# workaround to avoid needing to save the ordergroup
# avoids e.g. error after logging in related to applebar
after :create do |group| Ordergroup.find(group.id).update_stats! end
2013-07-12 20:06:49 +02:00
end
end
end