Sha256: 4ae9df356ea38e9d81af2a8e83f005a511c366b7262785cc986ad3756efc5ad9

Contents?: true

Size: 1.37 KB

Versions: 40

Compression:

Stored size: 1.37 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|
      if obj.role.present?
        user.roles << create(:role, obj.role)
      end
    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

40 entries across 40 versions & 1 rubygems

Version Path
renalware-core-2.0.42 spec/factories/system/users.rb
renalware-core-2.0.41 spec/factories/system/users.rb
renalware-core-2.0.40 spec/factories/system/users.rb
renalware-core-2.0.39 spec/factories/system/users.rb
renalware-core-2.0.38 spec/factories/system/users.rb
renalware-core-2.0.37 spec/factories/system/users.rb
renalware-core-2.0.36 spec/factories/system/users.rb
renalware-core-2.0.35 spec/factories/system/users.rb
renalware-core-2.0.34 spec/factories/system/users.rb
renalware-core-2.0.33 spec/factories/system/users.rb
renalware-core-2.0.32 spec/factories/system/users.rb
renalware-core-2.0.31 spec/factories/system/users.rb
renalware-core-2.0.30 spec/factories/system/users.rb
renalware-core-2.0.28 spec/factories/system/users.rb
renalware-core-2.0.27 spec/factories/system/users.rb
renalware-core-2.0.26 spec/factories/system/users.rb
renalware-core-2.0.25 spec/factories/system/users.rb
renalware-core-2.0.24 spec/factories/system/users.rb
renalware-core-2.0.23 spec/factories/system/users.rb
renalware-core-2.0.22 spec/factories/system/users.rb