Sha256: ebcfae6f21173edded46321f6656f20cadbed13ddae01f4e00e339ceee2de0f5

Contents?: true

Size: 1023 Bytes

Versions: 2

Compression:

Stored size: 1023 Bytes

Contents

FactoryBot.define do
  factory :user do
    email { Faker::Internet.unique.safe_email }
    password { Faker::Internet.password }
    provider { 'email' }

    transient do
      allow_unconfirmed_period { Time.now.utc - Devise.allow_unconfirmed_access_for }
    end

    trait :with_nickname do
      nickname { Faker::Internet.username }
    end

    trait :confirmed do
      after(:create) { |user| user.confirm }
    end

    # confirmation period is expired
    trait :unconfirmed do
      after(:create) do |user, evaluator|
        user.update_attribute(:confirmation_sent_at, evaluator.allow_unconfirmed_period - 1.day )
      end
    end

    trait :facebook do
      uid { Faker::Number.number }
      provider { 'facebook' }
    end

    trait :locked do
      after(:create) { |user| user.lock_access! }
    end

    factory :lockable_user, class: 'LockableUser'
    factory :mang_user, class: 'Mang'
    factory :only_email_user, class: 'OnlyEmailUser'
    factory :scoped_user, class: 'ScopedUser'
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
devise-tokens-1.0.4 test/factories/users.rb
devise_token_auth-1.1.3 test/factories/users.rb