Required fields on trackable
This commit is contained in:
parent
f3bace570d
commit
890f6031c3
|
@ -11,6 +11,14 @@ module Devise
|
||||||
# * last_sign_in_ip - Holds the remote ip of the previous sign in
|
# * last_sign_in_ip - Holds the remote ip of the previous sign in
|
||||||
#
|
#
|
||||||
module Trackable
|
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)
|
def update_tracked_fields!(request)
|
||||||
old_current, new_current = self.current_sign_in_at, Time.now.utc
|
old_current, new_current = self.current_sign_in_at, Time.now.utc
|
||||||
self.last_sign_in_at = old_current || new_current
|
self.last_sign_in_at = old_current || new_current
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TrackableTest < ActiveSupport::TestCase
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue