Sha256: 488ddfaac8edabc3a90e453b11c35f208ada01405b7d11e896557dc3105ba0e2

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

FactoryBot.define do
  factory :admin, class: User do
    sequence(:username){|n| "admin_#{n}"}
    sequence(:email){|n| "admin_#{n}@example.jp"}
    password { 'adminpassword' }
    password_confirmation { 'adminpassword' }
    association :profile
    after(:create) do |user|
      user.role = Role.find_by(name: 'Administrator')
    end
  end

  factory :librarian, class: User do
    sequence(:username){|n| "librarian_#{n}"}
    sequence(:email){|n| "librarian_#{n}@example.jp"}
    password { 'librarianpassword' }
    password_confirmation { 'librarianpassword' }
    association :profile
    after(:create) do |user|
      user.role = Role.find_by(name: 'Librarian')
    end
  end

  factory :user, class: User do
    sequence(:username){|n| "user_#{n}"}
    sequence(:email){|n| "user_#{n}@example.jp"}
    password { 'userpassword' }
    password_confirmation { 'userpassword' }
    association :profile
    after(:create) do |user|
      user.role = Role.find_by(name: 'User')
    end
  end

  factory :invalid_user, class: User do
  end
end

Version data entries

11 entries across 11 versions & 5 rubygems

Version Path
enju_inventory-0.4.0.rc.1 spec/factories/user.rb
enju_subject-0.4.0.rc.1 spec/factories/user.rb
enju_library-0.4.0.rc.1 spec/factories/user.rb
enju_library-0.4.0.beta.4 spec/factories/user.rb
enju_leaf-2.0.0.beta.2 spec/factories/user.rb
enju_library-0.4.0.beta.3 spec/factories/user.rb
enju_library-0.4.0.beta.2 spec/factories/user.rb
enju_leaf-2.0.0.beta.1 spec/factories/user.rb
enju_subject-0.4.0.beta.1 spec/factories/user.rb
enju_library-0.4.0.beta.1 spec/factories/user.rb
enju_seed-0.5.0.beta.1 spec/factories/user.rb