Skip to content

Commit

Permalink
Fix bug when the reset_password_sent_at field doesn't exist generate_…
Browse files Browse the repository at this point in the history
…password_token returns nil causing the token not to be saved.
  • Loading branch information
stevehodgkiss authored and josevalim committed Apr 17, 2011
1 parent ee6a8ab commit 6080971
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/devise/models/recoverable.rb
Expand Up @@ -73,6 +73,7 @@ def should_generate_token?
def generate_reset_password_token
self.reset_password_token = self.class.reset_password_token
self.reset_password_sent_at = Time.now.utc if respond_to?(:reset_password_sent_at=)
self.reset_password_token
end

# Resets the reset password token with and save the record without
Expand Down
8 changes: 8 additions & 0 deletions test/models/recoverable_test.rb
Expand Up @@ -196,4 +196,12 @@ def setup
end
end

test 'should save the model when the reset_password_sent_at doesnt exist' do
user = create_user
user.stubs(:respond_to?).with(:reset_password_sent_at=).returns(false)
user.stubs(:respond_to?).with(:headers_for).returns(false)
user.send_reset_password_instructions
user.reload
assert_not_nil user.reset_password_token
end
end

0 comments on commit 6080971

Please sign in to comment.