Required fields on token_authenticatable

This commit is contained in:
Rodrigo Flores 2012-02-17 15:50:15 -02:00
parent 533511f8c3
commit f3bace570d
2 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,14 @@ module Devise
module TokenAuthenticatable
extend ActiveSupport::Concern
module ModuleMethods
extend self
def required_fields
[:authentication_token]
end
end
# Generate new authentication token (a.k.a. "single access token").
def reset_authentication_token
self.authentication_token = self.class.authentication_token

View File

@ -46,4 +46,10 @@ class TokenAuthenticatableTest < ActiveSupport::TestCase
user = User.find_for_token_authentication(:auth_token => {'$ne' => user1.authentication_token})
assert_nil user
end
test 'required_fields should contain the fields that Devise uses' do
assert_equal Devise::Models::TokenAuthenticatable::ModuleMethods.required_fields.sort, [
:authentication_token
]
end
end