instiki/vendor/rails/actionpack/test/controller/session/abstract_store_test.rb
Jacques Distler 9e909d5be3 Update Rails, rails_xss and Bundler
Update Bundler to 1.0.15.
Update Rails to 2.3.12.
Update rails_xss plugin.

The latter two were the
source of a considerable
amount of grief, as rails_xss
is now MUCH stricter about what
string methods can be used.

Also made it possible to use
rake 0.9.x with Instiki. But
you probably REALLY want to use

 ruby bundle exec rake ...

instead of just saying

 rake ....
2011-06-15 00:43:38 -05:00

65 lines
1.4 KiB
Ruby

require 'abstract_unit'
# You need to start a memcached server inorder to run these tests
class AbstractStoreTest < ActionController::IntegrationTest
SessionKey = '_myapp_session'
DispatcherApp = ActionController::Dispatcher.new
class TestController < ActionController::Base
def get_session
session[:test] = 'test'
head :ok
end
end
def test_expiry_after
with_test_route_set(:expire_after => 5 * 60) do
get 'get_session'
assert_response :success
assert_match /expires=\S+/, headers['Set-Cookie']
end
end
protected
def with_test_route_set(options = {})
with_routing do |set|
set.draw do |map|
map.with_options :controller => "abstract_store_test/test" do |c|
c.connect "/:action"
end
end
options = { :key => SessionKey, :secret => 'SessionSecret' }.merge!(options)
@integration_session = open_session(TestStore.new(DispatcherApp, options))
yield
end
end
class TestStore < ActionController::Session::AbstractStore
def initialize(app, options = {})
super
@_store = Hash.new({})
end
private
def get_session(env, sid)
sid ||= generate_sid
session = @_store[sid]
[sid, session]
end
def set_session(env, sid, session_data)
@_store[sid] = session_data
end
def destroy(env)
@_store.delete(sid)
end
end
end