Sha256: 0c9495d37b1f3c0901db9e14e1895e70ca7007174d465904ea9a77b790b11582

Contents?: true

Size: 1.4 KB

Versions: 51

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

FactoryBot.define do
  sequence :email do |n|
    "renalware.user-#{n}@nhs.net"
  end

  sequence :username do |n|
    "renalwareuser-#{n}"
  end

  factory :user, class: "Renalware::User" do
    given_name { Faker::Name.first_name }
    family_name { Faker::Name.last_name }
    username
    email
    password { "supersecret" }
    approved { true }
    professional_position { "Health Minister" }
    signature { Faker::Name.name }

    # By default a user has no roles.
    # If you want a use with a role, use a trait, e.g. create(:user, :clinical)
    transient do
      role { nil }
    end

    after(:create) do |user, obj|
      user.roles << create(:role, obj.role) if obj.role.present?
    end

    trait :unapproved do
      approved { false }
    end

    trait :author do
      signature { Faker::Name.name }
    end

    trait :expired do
      last_activity_at { 90.days.ago }
      expired_at { Time.zone.now }
    end

    trait :super_admin do
      transient do
        role { :super_admin }
      end
    end

    trait :admin do
      transient do
        role { :admin }
      end
    end

    trait :clinical do
      given_name { "Aneurin" }
      family_name { "Bevan" }
      signature { "Aneurin Bevan" }

      transient do
        role { :clinical }
      end
    end

    trait :read_only do
      transient do
        role { :read_only }
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
renalware-core-2.0.121 spec/factories/system/users.rb
renalware-core-2.0.120 spec/factories/system/users.rb
renalware-core-2.0.119 spec/factories/system/users.rb
renalware-core-2.0.118 spec/factories/system/users.rb
renalware-core-2.0.117 spec/factories/system/users.rb
renalware-core-2.0.116 spec/factories/system/users.rb
renalware-core-2.0.115 spec/factories/system/users.rb
renalware-core-2.0.113 spec/factories/system/users.rb
renalware-core-2.0.112 spec/factories/system/users.rb
renalware-core-2.0.111 spec/factories/system/users.rb
renalware-core-2.0.110 spec/factories/system/users.rb
renalware-core-2.0.109 spec/factories/system/users.rb
renalware-core-2.0.108 spec/factories/system/users.rb
renalware-core-2.0.106 spec/factories/system/users.rb
renalware-core-2.0.105 spec/factories/system/users.rb
renalware-core-2.0.104 spec/factories/system/users.rb
renalware-core-2.0.103 spec/factories/system/users.rb
renalware-core-2.0.102 spec/factories/system/users.rb
renalware-core-2.0.101 spec/factories/system/users.rb
renalware-core-2.0.100 spec/factories/system/users.rb