Sha256: ad42d648319e8b310e4eb3e592e86a80ff0497b448b88a94dd1361bb18996a92

Contents?: true

Size: 1.37 KB

Versions: 13

Compression:

Stored size: 1.37 KB

Contents

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

module ORMAdaptersTests
  module ActiveRecordAdapterTests
    module ActsAsAuthenticTests
      class PersistenceTest < ActiveSupport::TestCase
        def test_unique_token
          assert_equal 128, User.unique_token.length
          assert_equal 128, Employee.unique_token.length # make sure encryptions use hashes also

          unique_tokens = []
          1000.times { unique_tokens << User.unique_token }
          unique_tokens.uniq!

          assert_equal 1000, unique_tokens.size
        end
        
        def test_forget_all
          http_basic_auth_for(users(:ben)) { UserSession.find }
          http_basic_auth_for(users(:zack)) { UserSession.find(:ziggity_zack) }
          assert UserSession.find
          assert UserSession.find(:ziggity_zack)
          User.forget_all!
          assert !UserSession.find
          assert !UserSession.find(:ziggity_zack)
        end
        
        def test_forget
          ben = users(:ben)
          zack = users(:zack)
          http_basic_auth_for(ben) { UserSession.find }
          http_basic_auth_for(zack) { UserSession.find(:ziggity_zack) }

          assert ben.reload.logged_in?
          assert zack.reload.logged_in?

          ben.forget!

          assert !UserSession.find
          assert UserSession.find(:ziggity_zack)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
authlogic-1.1.2 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.2.0 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.3.2 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.1.1 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.2.1 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.2.2 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.3.0 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.3.1 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.3.3 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.3.7 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.3.4 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.3.5 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb
authlogic-1.3.6 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/persistence_test.rb