Add a plugin to handle session persistence. This is based on the

plugin at http://github.com/augustl/session-persistence but modified
to work with rails 2 rather than rails 3.
This commit is contained in:
Tom Hughes 2010-02-25 16:39:51 +00:00
parent 345ac0bd1a
commit 60f145f13e
5 changed files with 134 additions and 0 deletions

View file

@ -0,0 +1,41 @@
require "test/unit"
module ActionController
class Base
def self.after_filter(*args)
end
end
end
$LOAD_PATH.push(File.dirname(__FILE__) + "../lib")
require "../init"
class SessionPersistenceTest < Test::Unit::TestCase
def setup
@controller = ActionController::Base.new
@controller.instance_eval {
def session
@session ||= {}
end
def session_persistence_key
:mine
end
}
end
def test_session_expires_after
@controller.instance_eval { session_expires_after 10 }
assert_equal 10, @controller.session[:mine]
end
def test_session_expires_automatically
@controller.instance_eval {
session_expires_after 10
session_expires_automatically
}
assert !@controller.session.has_key?(:mine)
end
end