From fffb85987c3dd7755c4faf1b39beec874fd54518 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 15 Apr 2021 17:14:50 +0200 Subject: [PATCH] app: retain user email on sign-in error --- app/views/users/sessions/new.html.haml | 2 +- spec/features/sessions/sign_in_spec.rb | 5 ++++- spec/views/users/sessions/new.html.haml_spec.rb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml index 5dc8a35d4..fdd4de5d8 100644 --- a/app/views/users/sessions/new.html.haml +++ b/app/views/users/sessions/new.html.haml @@ -2,7 +2,7 @@ .auth-form.sign-in-form - = form_for User.new, url: user_session_path, html: { class: "form" } do |f| + = form_for resource, url: user_session_path, html: { class: "form" } do |f| %h1.huge-title= t('views.sessions.new.title') = render partial: 'shared/france_connect_login', locals: { url: france_connect_particulier_path } diff --git a/spec/features/sessions/sign_in_spec.rb b/spec/features/sessions/sign_in_spec.rb index 84361db70..e6888e6f8 100644 --- a/spec/features/sessions/sign_in_spec.rb +++ b/spec/features/sessions/sign_in_spec.rb @@ -6,8 +6,11 @@ feature 'Signin in:' do visit root_path click_on 'Connexion' - sign_in_with user.email, password + sign_in_with user.email, 'invalid-password' + expect(page).to have_content 'Courriel ou mot de passe incorrect.' + expect(page).to have_field('Email', with: user.email) + sign_in_with user.email, password expect(page).to have_current_path dossiers_path end diff --git a/spec/views/users/sessions/new.html.haml_spec.rb b/spec/views/users/sessions/new.html.haml_spec.rb index 9b3da052d..10a1181af 100644 --- a/spec/views/users/sessions/new.html.haml_spec.rb +++ b/spec/views/users/sessions/new.html.haml_spec.rb @@ -3,7 +3,7 @@ describe 'users/sessions/new.html.haml', type: :view do before(:each) do allow(view).to receive(:devise_mapping).and_return(Devise.mappings[:user]) - allow(view).to receive(:resource_name).and_return(:user) + allow(view).to receive(:resource).and_return(:user) end before do