mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Create OidcAccount factory for simpler specs
This commit is contained in:
15
spec/factories/oidc_account_factory.rb
Normal file
15
spec/factories/oidc_account_factory.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :oidc_account, class: OidcAccount do
|
||||
provider { "openid_connect" }
|
||||
uid { user&.email || generate(:random_email) }
|
||||
|
||||
# This is a live test account authenticated via Les Communes.
|
||||
factory :testdfc_account do
|
||||
uid { "testdfc@protonmail.com" }
|
||||
refresh_token { ENV.fetch("OPENID_REFRESH_TOKEN") }
|
||||
updated_at { 1.day.ago }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -39,20 +39,12 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :oidc_user do
|
||||
oidc_account {
|
||||
OidcAccount.new(provider: "openid_connect", uid: email)
|
||||
}
|
||||
oidc_account { build(:oidc_account, uid: email) }
|
||||
end
|
||||
|
||||
# This is a live test user authenticated via Les Communes.
|
||||
factory :testdfc_user do
|
||||
oidc_account {
|
||||
OidcAccount.new(
|
||||
uid: "testdfc@protonmail.com",
|
||||
refresh_token: ENV.fetch("OPENID_REFRESH_TOKEN"),
|
||||
updated_at: 1.day.ago,
|
||||
)
|
||||
}
|
||||
oidc_account { build(:testdfc_account) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user