admin: create without providing email
This commit is contained in:
parent
2bb161c3cb
commit
ed970d3f3c
3 changed files with 3 additions and 4 deletions
|
@ -82,7 +82,7 @@ class User < ApplicationRecord
|
||||||
user = User.create_or_promote_to_instructeur(email, password)
|
user = User.create_or_promote_to_instructeur(email, password)
|
||||||
|
|
||||||
if user.valid? && user.administrateur_id.nil?
|
if user.valid? && user.administrateur_id.nil?
|
||||||
user.create_administrateur!(email: email)
|
user.create_administrateur!
|
||||||
end
|
end
|
||||||
|
|
||||||
user
|
user
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
sequence(:administrateur_email) { |n| "admin#{n}@admin.com" }
|
sequence(:administrateur_email) { |n| "admin#{n}@admin.com" }
|
||||||
factory :administrateur do
|
factory :administrateur do
|
||||||
email { generate(:administrateur_email) }
|
|
||||||
|
|
||||||
transient do
|
transient do
|
||||||
|
email { generate(:administrateur_email) }
|
||||||
password { 'mon chien aime les bananes' }
|
password { 'mon chien aime les bananes' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,6 @@ class AdministrationMailerPreview < ActionMailer::Preview
|
||||||
end
|
end
|
||||||
|
|
||||||
def administrateur
|
def administrateur
|
||||||
Administrateur.new(id: 111, email: "chef.de.service@administration.gouv.fr")
|
Administrateur.new(id: 111, user: User.new(email: "chef.de.service@administration.gouv.fr"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue