instructeurs: fix expert creation not to use Instructeur.email

It kind of worked until now, because the email field is disabled, and
thus never accessed.

But better make it clean, by accessing an object (User) where the email
field actually exists.
This commit is contained in:
Pierre de La Morinerie 2019-10-21 09:24:43 +00:00
parent 38f994a151
commit d78d206544
4 changed files with 4 additions and 4 deletions

View file

@ -81,7 +81,7 @@ module Instructeurs
def create_instructeur
email = params[:email]
password = params['instructeur']['password']
password = params[:user][:password]
# Not perfect because the password will not be changed if the user already exists
user = User.create_or_promote_to_instructeur(email, password)

View file

@ -4,7 +4,7 @@
%p.description= @dossier.procedure.libelle
%p.dossier Dossier nº #{@dossier.id}
.column
= form_for(Instructeur.new, url: { controller: "instructeurs/avis", action: :create_instructeur }, method: :post, html: { class: "form" }) do |f|
= form_for(User.new, url: { controller: "instructeurs/avis", action: :create_instructeur }, method: :post, html: { class: "form" }) do |f|
%h1 Créez-vous un compte
= f.label :email, "Email"

View file

@ -296,7 +296,7 @@ describe Instructeurs::AvisController, type: :controller do
post :create_instructeur, params: {
id: avis_id,
email: invited_email,
instructeur: {
user: {
password: password
}
}

View file

@ -181,7 +181,7 @@ feature 'Instructing a dossier:' do
def avis_sign_up(avis, email)
visit sign_up_instructeur_avis_path(avis, email)
fill_in 'instructeur_password', with: 'démarches-simplifiées-pwd'
fill_in 'user_password', with: 'démarches-simplifiées-pwd'
click_on 'Créer un compte'
expect(page).to have_current_path(instructeur_avis_index_path)
end