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

View file

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

View file

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