diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-02-17 06:55:24 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-03-04 23:26:51 +0300 |
commit | 6df45eb4630d3eef4f232398de405b169c3c6876 (patch) | |
tree | 1f059ced536939bc14ea5d86fba8afce04537d40 /spec/factories/users.rb | |
parent | 5de46014d74c1805b6bb090f5b2abebd6fb1f399 (diff) |
Move all factory definitions to their own file
Diffstat (limited to 'spec/factories/users.rb')
-rw-r--r-- | spec/factories/users.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 00000000000..785c2a3d811 --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,50 @@ +FactoryGirl.define do + sequence(:name) { FFaker::Name.name } + + factory :user, aliases: [:author, :assignee, :recipient, :owner, :creator] do + email { FFaker::Internet.email } + name + sequence(:username) { |n| "#{FFaker::Internet.user_name}#{n}" } + password "12345678" + confirmed_at { Time.now } + confirmation_token { nil } + can_create_group true + + trait :admin do + admin true + end + + trait :two_factor do + before(:create) do |user| + user.two_factor_enabled = true + user.otp_secret = User.generate_otp_secret(32) + user.otp_grace_period_started_at = Time.now + user.generate_otp_backup_codes! + end + end + + trait :with_avatar do + avatar { fixture_file_upload(Rails.root.join(*%w(spec fixtures dk.png)), 'image/png') } + avatar_crop_x 0 + avatar_crop_y 0 + avatar_crop_size 256 + end + + factory :omniauth_user do + transient do + extern_uid '123456' + provider 'ldapmain' + end + + after(:create) do |user, evaluator| + user.identities << create( + :identity, + provider: evaluator.provider, + extern_uid: evaluator.extern_uid + ) + end + end + + factory :admin, traits: [:admin] + end +end |