diff --git a/test/controllers/passwords_controller_test.rb b/test/controllers/passwords_controller_test.rb index f2d5c1dd0..85b70befb 100644 --- a/test/controllers/passwords_controller_test.rb +++ b/test/controllers/passwords_controller_test.rb @@ -32,7 +32,7 @@ def put_update_with_params end test '#edit redirect if reset_password_token has expired' do - @user.reset_password_sent_at = @user.class.reset_password_within - 1.second + @user.reset_password_sent_at = Time.now - @user.class.reset_password_within - 1.second @user.save get :edit, params: { reset_password_token: @raw } assert_equal "This password recovery link has expired, please request a new one.", flash[:alert] diff --git a/test/integration/recoverable_test.rb b/test/integration/recoverable_test.rb index c391b0b2e..492d46a1d 100644 --- a/test/integration/recoverable_test.rb +++ b/test/integration/recoverable_test.rb @@ -154,13 +154,12 @@ def reset_password(options = {}, &block) test 'not authenticated user with invalid reset password token should not be able to change their password' do user = create_user - reset_password reset_password_token: 'invalid_reset_password' + get edit_user_password_path(reset_password_token: 'invalid_reset_password') - assert_response :success - assert_current_url '/users/password' - assert_have_selector '#error_explanation' - assert_contain %r{Reset password token(.*)invalid} - assert_not user.reload.valid_password?('987654321') + assert_response :redirect + assert_redirected_to "/users/password/new" + follow_redirect! + assert_contain 'This password recovery link is invalid, please request a new one.' end test 'not authenticated user with valid reset password token but invalid password should not be able to change their password' do