Sha256: 2d563e71a72a7a3f56945b71e15d756d3387fa9ddfa84075e31ae352ffd564bf

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

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

module SessionTests
  class SessionTest < ActiveSupport::TestCase
    def test_valid_session
      ben = users(:ben)
      session = UserSession.new
      
      assert !session.valid_session?
      
      set_session_for(ben)
      assert session.valid_session?
      assert session.find_record
      assert_equal ben, session.record
      assert_equal ben.remember_token, @controller.session["user_credentials"]
      assert_equal ben, session.unauthorized_record
      assert !session.new_session?
    end
    
    def test_save
      ben = users(:ben)
      session = UserSession.new(ben)
      assert @controller.session["user_credentials"].blank?
      assert session.save
      assert_equal ben.remember_token, @controller.session["user_credentials"]
    end
    
    def test_destroy
      ben = users(:ben)
      set_session_for(ben)
      assert_equal ben.remember_token, @controller.session["user_credentials"]
      session = UserSession.find
      assert session.destroy
      assert @controller.session["user_credentials"].blank?
    end
    
    def test_find
      ben = users(:ben)
      set_cookie_for(ben)
      assert @controller.session["user_credentials"].blank?
      assert UserSession.find
      assert_equal ben.remember_token, @controller.session["user_credentials"]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
authlogic-1.1.1 test/session_tests/session_test.rb
authlogic-1.1.2 test/session_tests/session_test.rb
authlogic-1.2.0 test/session_tests/session_test.rb
authlogic-1.1.0 test/session_tests/session_test.rb