Create OidcAccount factory for simpler specs

This commit is contained in:
Maikel Linke
2024-10-18 15:06:00 +11:00
parent 63c83a19d6
commit a5f677f748
2 changed files with 17 additions and 10 deletions

View 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

View File

@@ -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