admin: create without providing email

This commit is contained in:
Christophe Robillard 2020-02-03 11:09:54 +01:00
parent 2bb161c3cb
commit ed970d3f3c
3 changed files with 3 additions and 4 deletions

View file

@ -82,7 +82,7 @@ class User < ApplicationRecord
user = User.create_or_promote_to_instructeur(email, password)
if user.valid? && user.administrateur_id.nil?
user.create_administrateur!(email: email)
user.create_administrateur!
end
user

View file

@ -1,9 +1,8 @@
FactoryBot.define do
sequence(:administrateur_email) { |n| "admin#{n}@admin.com" }
factory :administrateur do
email { generate(:administrateur_email) }
transient do
email { generate(:administrateur_email) }
password { 'mon chien aime les bananes' }
end

View file

@ -41,6 +41,6 @@ class AdministrationMailerPreview < ActionMailer::Preview
end
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