users.rb 724 Bytes
Newer Older
1 2 3 4 5
# frozen_string_literal: true

FactoryBot.modify do
  factory :user do
    trait :auditor do
6
      auditor { true }
7
    end
8 9

    trait :group_managed do
10 11 12 13 14 15 16 17
      association :managing_group, factory: :group_with_managed_accounts

      after(:create) do |user, evaluator|
        create(:group_saml_identity,
          user: user,
          saml_provider: user.managing_group.saml_provider
        )
      end
18
    end
19 20

    trait :service_user do
21
      user_type { :service_user }
22
    end
23 24 25 26
  end

  factory :omniauth_user do
    transient do
27
      saml_provider { nil }
28 29 30 31 32 33 34 35
    end
  end
end

FactoryBot.define do
  factory :auditor, parent: :user, traits: [:auditor]
  factory :external_user, parent: :user, traits: [:external]
end