Commit dc3912f86e9517353d71c9f430a02ae9fd0bc665

Authored by Junior Silva
1 parent f2e97688

change-password: fixed bug in change password error

AI3012
app/controllers/public/account_controller.rb
... ... @@ -135,6 +135,9 @@ class AccountController < ApplicationController
135 135 rescue User::IncorrectPassword => e
136 136 session[:notice] = _('The supplied current password is incorrect.')
137 137 render :action => 'change_password'
  138 + rescue ActiveRecord::RecordInvalid
  139 + session[:notice] = _("Passwords don't match!")
  140 + render :action => 'change_password'
138 141 end
139 142 else
140 143 render :action => 'change_password'
... ...
test/functional/account_controller_test.rb
... ... @@ -203,6 +203,16 @@ class AccountControllerTest < ActionController::TestCase
203 203 assert_equal users(:ze), @controller.send(:current_user)
204 204 end
205 205  
  206 + should "not change password when new password and new password confirmation don't match" do
  207 + login_as 'ze'
  208 + post :change_password, :current_password => 'test', :new_password => 'blabla', :new_password_confirmation => 'blibli'
  209 + assert_response :success
  210 + assert_template 'change_password'
  211 + assert !assigns(:current_user).authenticated?('blabla')
  212 + assert !assigns(:current_user).authenticated?('blibli')
  213 + assert_equal users(:ze), @controller.send(:current_user)
  214 + end
  215 +
206 216 should 'provide a "I forget my password" link at the login page' do
207 217 get :login
208 218 assert_tag :tag => 'a', :attributes => {
... ...