Sha256: e83781ce80667344b72b50d04d757c98229c681727103a2f385b954191e8a4a1

Contents?: true

Size: 1.61 KB

Versions: 16

Compression:

Stored size: 1.61 KB

Contents

require File.dirname(__FILE__) + '/../../../test_helper.rb'

module ORMAdaptersTests
  module ActiveRecordAdapterTests
    module ActsAsAuthenticTests
      class PerishabilityTest < ActiveSupport::TestCase
        def test_before_validation
          ben = users(:ben)
          old_perishable_token = ben.perishable_token
          assert ben.valid?
          assert_not_equal old_perishable_token, ben.perishable_token
          ben.reload
          assert_equal old_perishable_token, ben.perishable_token
          assert ben.save
          assert_not_equal old_perishable_token, ben.perishable_token
        end
        
        def test_find_using_perishable_token
          ben = users(:ben)
          assert_nil User.find_using_perishable_token("")
          assert_equal ben, User.find_using_perishable_token(ben.perishable_token)
          assert ben.class.connection.execute("update users set updated_at = '#{10.minutes.ago.to_s(:db)}' where id = '#{ben.id}';")
          assert_nil User.find_using_perishable_token(ben.perishable_token)
          assert_equal ben, User.find_using_perishable_token(ben.perishable_token, 20.minutes)
        end
        
        def test_reset_perishable_token
          ben = users(:ben)
          old_perishable_token = ben.perishable_token
          ben.reset_perishable_token
          assert_not_equal old_perishable_token, ben.perishable_token
          ben.reload
          assert_equal old_perishable_token, ben.perishable_token
          ben.reset_perishable_token!
          ben.reload
          assert_not_equal old_perishable_token, ben.perishable_token
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
authlogic-1.2.2 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.1 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.2.1 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.2 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.0 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.4.1 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.6 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.7 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.9 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.4.0 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.5 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.8 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.3 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.3.4 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.4.3 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb
authlogic-1.4.2 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/perishability_test.rb