Sha256: 2da5834573512dc3ec2c73de751124e88edce3e9d8a4a68626b7d535eadfa819

Contents?: true

Size: 1.18 KB

Versions: 25

Compression:

Stored size: 1.18 KB

Contents

require 'test_helper'

class TrackableTest < ActiveSupport::TestCase
  test 'required_fields should contain the fields that Devise uses' do
    assert_same_content Devise::Models::Trackable.required_fields(User), [
      :current_sign_in_at,
      :current_sign_in_ip,
      :last_sign_in_at,
      :last_sign_in_ip,
      :sign_in_count
    ]
  end

  test 'update_tracked_fields should only set attributes but not save the record' do
    user = create_user
    request = mock
    request.stubs(:remote_ip).returns("127.0.0.1")

    assert_nil user.current_sign_in_ip
    assert_nil user.last_sign_in_ip
    assert_nil user.current_sign_in_at
    assert_nil user.last_sign_in_at
    assert_equal 0, user.sign_in_count

    user.update_tracked_fields(request)

    assert_equal "127.0.0.1", user.current_sign_in_ip
    assert_equal "127.0.0.1", user.last_sign_in_ip
    assert_not_nil user.current_sign_in_at
    assert_not_nil user.last_sign_in_at
    assert_equal 1, user.sign_in_count

    user.reload

    assert_nil user.current_sign_in_ip
    assert_nil user.last_sign_in_ip
    assert_nil user.current_sign_in_at
    assert_nil user.last_sign_in_at
    assert_equal 0, user.sign_in_count
  end
end

Version data entries

25 entries across 25 versions & 5 rubygems

Version Path
devise-3.5.10 test/models/trackable_test.rb
devise-4.0.3 test/models/trackable_test.rb
devise-4.1.1 test/models/trackable_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/devise-4.1.0/test/models/trackable_test.rb
devise-4.1.0 test/models/trackable_test.rb
devise-3.5.9 test/models/trackable_test.rb
devise-4.0.2 test/models/trackable_test.rb
devise-4.0.1 test/models/trackable_test.rb
devise-3.5.8 test/models/trackable_test.rb
devise-3.5.7 test/models/trackable_test.rb
devise-4.0.0 test/models/trackable_test.rb
devise-4.0.0.rc2 test/models/trackable_test.rb
devise-4.0.0.rc1 test/models/trackable_test.rb
devise-3.5.6 test/models/trackable_test.rb
devise-3.5.5 test/models/trackable_test.rb
devise-3.5.4 test/models/trackable_test.rb
devise-3.5.3 test/models/trackable_test.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/devise-3.5.2/test/models/trackable_test.rb
devise-3.5.2 test/models/trackable_test.rb
devise-3.5.1 test/models/trackable_test.rb