openstreetmap-website/vendor/plugins/session-persistence/test/session_timeout_test.rb
Tom Hughes 60f145f13e 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.
2010-02-25 16:39:51 +00:00

41 lines
No EOL
817 B
Ruby

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