Commit 5a3a20e8 authored by Rémy Coutable's avatar Rémy Coutable

Extract EE-specific code from spec/factories/users.rb

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 927037f5
# frozen_string_literal: true
FactoryBot.modify do
factory :user do
trait :auditor do
auditor true
end
end
factory :omniauth_user do
transient do
saml_provider nil
end
end
end
FactoryBot.define do
factory :auditor, parent: :user, traits: [:auditor]
factory :external_user, parent: :user, traits: [:external]
end
......@@ -16,10 +16,6 @@ FactoryBot.define do
admin true
end
trait :auditor do
auditor true
end
trait :blocked do
after(:build) { |user, _| user.block! }
end
......@@ -74,21 +70,22 @@ FactoryBot.define do
transient do
extern_uid '123456'
provider 'ldapmain'
saml_provider nil
end
after(:create) do |user, evaluator|
user.identities << create(
:identity,
identity_attrs = {
provider: evaluator.provider,
extern_uid: evaluator.extern_uid,
saml_provider: evaluator.saml_provider
)
extern_uid: evaluator.extern_uid
}
if evaluator.respond_to?(:saml_provider)
identity_attrs[:saml_provider] = evaluator.saml_provider
end
user.identities << create(:identity, identity_attrs)
end
end
factory :admin, traits: [:admin]
factory :auditor, traits: [:auditor]
factory :external_user, traits: [:external]
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment