Make sure we show errors correctly when resetting a password

This commit is contained in:
Tom Hughes 2017-08-11 17:45:57 +01:00
parent 7fd1e55938
commit a70898be6d
2 changed files with 7 additions and 1 deletions

View file

@ -2,7 +2,7 @@
<h1><%= t 'user.reset_password.heading', :user => current_user.display_name %></h1> <h1><%= t 'user.reset_password.heading', :user => current_user.display_name %></h1>
<% end %> <% end %>
<%= error_messages_for :user %> <%= error_messages_for current_user %>
<%= form_tag do %> <%= form_tag do %>
<%= hidden_field_tag(:token, params[:token]) %> <%= hidden_field_tag(:token, params[:token]) %>

View file

@ -749,6 +749,12 @@ class UserControllerTest < ActionController::TestCase
assert_response :success assert_response :success
assert_template :reset_password 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 # Test setting a new password
post :reset_password, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "new_password" } } post :reset_password, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "new_password" } }
assert_response :redirect assert_response :redirect