2013-04-22 08:22:53 -04:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class PasswordsControllerTest < ActionController::TestCase
|
|
|
|
tests Devise::PasswordsController
|
|
|
|
include Devise::TestHelpers
|
|
|
|
|
2013-08-06 05:55:13 -04:00
|
|
|
setup do
|
2013-04-22 08:22:53 -04:00
|
|
|
request.env["devise.mapping"] = Devise.mappings[:user]
|
2013-08-15 07:17:11 -04:00
|
|
|
@user = create_user.tap(&:confirm!)
|
2013-08-06 05:55:13 -04:00
|
|
|
@raw = @user.send_reset_password_instructions
|
2013-04-22 08:22:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def put_update_with_params
|
2013-05-03 20:52:00 -04:00
|
|
|
put :update, "user" => {
|
2013-08-06 05:55:13 -04:00
|
|
|
"reset_password_token" => @raw, "password" => "123456", "password_confirmation" => "123456"
|
2013-05-03 20:52:00 -04:00
|
|
|
}
|
2013-04-22 08:22:53 -04:00
|
|
|
end
|
|
|
|
|
2013-04-22 10:25:40 -04:00
|
|
|
test 'redirect to after_sign_in_path_for if after_resetting_password_path_for is not overridden' do
|
2013-04-22 08:22:53 -04:00
|
|
|
put_update_with_params
|
|
|
|
assert_redirected_to "http://test.host/"
|
|
|
|
end
|
|
|
|
|
2013-04-22 10:25:40 -04:00
|
|
|
test 'redirect accordingly if after_resetting_password_path_for is overridden' do
|
2013-04-22 08:22:53 -04:00
|
|
|
custom_path = "http://custom.path/"
|
2013-04-22 10:25:40 -04:00
|
|
|
Devise::PasswordsController.any_instance.stubs(:after_resetting_password_path_for).with(@user).returns(custom_path)
|
2013-05-03 20:52:00 -04:00
|
|
|
|
2013-04-22 08:22:53 -04:00
|
|
|
put_update_with_params
|
|
|
|
assert_redirected_to custom_path
|
|
|
|
end
|
|
|
|
end
|