Skip to content

Commit

Permalink
Added required_fields to recoverable
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Flores committed Feb 22, 2012
1 parent bee8784 commit ce3422e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/devise/models/recoverable.rb
Expand Up @@ -24,6 +24,10 @@ module Models
module Recoverable
extend ActiveSupport::Concern

def self.required_fields(klass)
[:reset_password_sent_at, :reset_password_token]
end

# Update password saving the record and clearing token. Returns true if
# the passwords are valid and the record was saved, false otherwise.
def reset_password!(new_password, new_password_confirmation)
Expand Down
9 changes: 8 additions & 1 deletion test/models/recoverable_test.rb
Expand Up @@ -195,4 +195,11 @@ def setup
assert_equal "has expired, please request a new one", reset_password_user.errors[:reset_password_token].join
end
end
end

test 'required_fields should contain the fields that Devise uses' do
assert_equal Devise::Models::Recoverable.required_fields(User), [
:reset_password_sent_at,
:reset_password_token
]
end
end

0 comments on commit ce3422e

Please sign in to comment.