Skip to content

Commit

Permalink
Using the same url in success and failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Flores committed Jun 22, 2011
1 parent 803e46c commit 7d16065
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/controllers/devise/passwords_controller.rb
Expand Up @@ -14,7 +14,16 @@ def create

if resource.errors.empty? || Devise.paranoid
set_flash_message(:notice, Devise.paranoid ? :send_paranoid_instructions : :send_instructions) if is_navigational_format?
respond_with resource, :location => new_session_path(resource_name)

#TODO needs refactor
if Devise.paranoid
if resource.errors.any?
resource.errors.clear
end
respond_with_navigational(resource) { render_with_scope :new }
else
respond_with resource, :location => new_session_path(resource_name)
end
else
respond_with_navigational(resource){ render_with_scope :new }
end
Expand Down
8 changes: 7 additions & 1 deletion test/integration/recoverable_test.rb
Expand Up @@ -226,17 +226,23 @@ def reset_password(options={}, &block)
visit_new_password_path
fill_in "email", :with => "arandomemail@test.com"
click_button 'Send me reset password instructions'

assert_not_contain "1 error prohibited this user from being saved:"
assert_not_contain "Email not found"
assert_contain "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
assert_current_url "/users/password"
end
end

test "when in paranoid mode and with a valid e-mail, asking to reset password should display a message that does not indicates that the email exists in the database" do
test "when in paranoid mode and with a valid e-mail, asking to reset password should display a message that does not indicates that the email exists in the database and redirect to the failure route" do
swap Devise, :paranoid => true do
user = create_user
visit_new_password_path
fill_in 'email', :with => user.email
click_button 'Send me reset password instructions'

assert_contain "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
assert_current_url "/users/password"
end
end
end

0 comments on commit 7d16065

Please sign in to comment.