From a70898be6dde1e9e9f61f90f8dc9b2c18a6f9287 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Aug 2017 17:45:57 +0100 Subject: [PATCH] Make sure we show errors correctly when resetting a password --- app/views/user/reset_password.html.erb | 2 +- test/controllers/user_controller_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/user/reset_password.html.erb b/app/views/user/reset_password.html.erb index 4cb94374a..895bd98b6 100644 --- a/app/views/user/reset_password.html.erb +++ b/app/views/user/reset_password.html.erb @@ -2,7 +2,7 @@

<%= t 'user.reset_password.heading', :user => current_user.display_name %>

<% end %> -<%= error_messages_for :user %> +<%= error_messages_for current_user %> <%= form_tag do %> <%= hidden_field_tag(:token, params[:token]) %> diff --git a/test/controllers/user_controller_test.rb b/test/controllers/user_controller_test.rb index 1404fc795..1561a9ebe 100644 --- a/test/controllers/user_controller_test.rb +++ b/test/controllers/user_controller_test.rb @@ -749,6 +749,12 @@ class UserControllerTest < ActionController::TestCase assert_response :success assert_template :reset_password + # Test that errors are reported for erroneous submissions + post :reset_password, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "different_password" } } + assert_response :success + assert_template :reset_password + assert_select "div#errorExplanation" + # Test setting a new password post :reset_password, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "new_password" } } assert_response :redirect -- 2.39.5