From 1b14d85c7730d937cc3148bbd751c4fcf5ed4e8d Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 16 Aug 2019 16:41:28 +0200 Subject: [PATCH] Rerender if wrong credentials --- app/controllers/users/sessions_controller.rb | 3 +-- spec/controllers/users/sessions_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 774436d69..bd8525c0d 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -31,8 +31,7 @@ class Users::SessionsController < Devise::SessionsController redirect_to after_sign_in_path_for(:user) else flash.alert = 'Mauvais couple login / mot de passe' - new - render :new, status: 401 + render :new, assigns: { user: User.new } end end diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb index ad2907313..5e502cdcc 100644 --- a/spec/controllers/users/sessions_controller_spec.rb +++ b/spec/controllers/users/sessions_controller_spec.rb @@ -44,7 +44,7 @@ describe Users::SessionsController, type: :controller do it 'fails to sign in with bad credentials' do subject - expect(response.unauthorized?).to be(true) + expect(response).to render_template(:new) expect(controller.current_user).to be(nil) end end