Required fields on trackable

This commit is contained in:
Rodrigo Flores 2012-02-17 17:43:15 -02:00
parent f3bace570d
commit 890f6031c3
2 changed files with 17 additions and 1 deletions

View File

@ -11,6 +11,14 @@ module Devise
# * last_sign_in_ip - Holds the remote ip of the previous sign in
#
module Trackable
module ModuleMethods
extend self
def required_fields
[:current_sign_in_at, :current_sign_in_ip, :last_sign_in_at, :last_sign_in_ip, :sign_in_count]
end
end
def update_tracked_fields!(request)
old_current, new_current = self.current_sign_in_at, Time.now.utc
self.last_sign_in_at = old_current || new_current

View File

@ -1,5 +1,13 @@
require 'test_helper'
class TrackableTest < ActiveSupport::TestCase
test 'required_fields should contain the fields that Devise uses' do
assert_equal Devise::Models::Trackable::ModuleMethods.required_fields.sort, [
:current_sign_in_at,
:current_sign_in_ip,
:last_sign_in_at,
:last_sign_in_ip,
:sign_in_count
]
end
end