2016-09-24 03:00:46 +00:00
|
|
|
# frozen_string_literal: true
|
2017-11-06 16:15:18 +00:00
|
|
|
|
2016-01-07 07:47:45 +00:00
|
|
|
#
|
|
|
|
# This file supports three factories, because code and joinedwithcode
|
|
|
|
# make things complicated!
|
|
|
|
#
|
|
|
|
# Generally, use :simple_user to generate users. It's simplest.
|
|
|
|
#
|
|
|
|
# If you want to test code generation, or need a setup with users that
|
|
|
|
# have actual codes, you'll need to specify one simple_user and then you
|
|
|
|
# can specify other :code_user users based on the pre-existing user's code.
|
|
|
|
|
2015-10-19 07:23:49 +00:00
|
|
|
FactoryGirl.define do
|
2016-01-07 07:47:45 +00:00
|
|
|
factory :code_user, class: User do
|
2015-12-21 02:59:09 +00:00
|
|
|
sequence(:name) { |n| "Cool User ##{n}" }
|
|
|
|
sequence(:email) { |n| "cooluser#{n}@cooldomain.com" }
|
2015-10-19 07:23:49 +00:00
|
|
|
password 'omgwtfbbq'
|
2015-12-16 14:33:29 +00:00
|
|
|
|
2016-01-07 07:47:45 +00:00
|
|
|
factory :simple_user, aliases: [:user] do
|
2016-07-26 00:14:23 +00:00
|
|
|
joinedwithcode { 'qwertyui' }
|
|
|
|
code { 'qwertyui' }
|
2015-12-21 02:59:09 +00:00
|
|
|
|
2016-01-07 07:47:45 +00:00
|
|
|
transient do
|
|
|
|
validate false
|
|
|
|
end
|
|
|
|
|
|
|
|
# bypass validation of the joinedwithcode
|
|
|
|
to_create { |instance| instance.save(validate: instance.validate) }
|
|
|
|
end
|
2015-10-19 07:23:49 +00:00
|
|
|
end
|
|
|
|
end
|