forked from heartcombo/devise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for non-navigational formats in PasswordsController
Signed-off-by: José Valim <[email protected]>
- Loading branch information
Showing
2 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,4 +157,41 @@ def reset_password(options={}, &block) | |
assert !warden.authenticated?(:user) | ||
end | ||
|
||
test 'reset password request with valid E-Mail in XML format should return valid response' do | ||
create_user | ||
post user_password_path(:format => 'xml'), :user => {:email => "[email protected]"} | ||
assert_response :success | ||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>) | ||
end | ||
|
||
test 'reset password request with invalid E-Mail in XML format should return valid response' do | ||
create_user | ||
post user_password_path(:format => 'xml'), :user => {:email => "[email protected]"} | ||
assert_response :unprocessable_entity | ||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>) | ||
end | ||
|
||
test 'change password with valid parameters in XML format should return valid response' do | ||
user = create_user | ||
request_forgot_password | ||
put user_password_path(:format => 'xml'), :user => {:reset_password_token => user.reload.reset_password_token, :password => '987654321', :password_confirmation => '987654321'} | ||
assert_response :success | ||
assert warden.authenticated?(:user) | ||
end | ||
|
||
test 'change password with invalid token in XML format should return invalid response' do | ||
user = create_user | ||
request_forgot_password | ||
put user_password_path(:format => 'xml'), :user => {:reset_password_token => 'invalid.token', :password => '987654321', :password_confirmation => '987654321'} | ||
assert_response :unprocessable_entity | ||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>) | ||
end | ||
|
||
test 'change password with invalid new password in XML format should return invalid response' do | ||
user = create_user | ||
request_forgot_password | ||
put user_password_path(:format => 'xml'), :user => {:reset_password_token => user.reload.reset_password_token, :password => '', :password_confirmation => '987654321'} | ||
assert_response :unprocessable_entity | ||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>) | ||
end | ||
end |