mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Clean up session integration tests so they don't reference AC::Dispatcher
This commit is contained in:
parent
db65bb5a31
commit
0c638b3406
3 changed files with 15 additions and 52 deletions
|
@ -33,7 +33,6 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
ActiveRecord::SessionStore.session_class.create_table!
|
ActiveRecord::SessionStore.session_class.create_table!
|
||||||
reset_app!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
@ -132,9 +131,7 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_allows_session_fixation
|
def test_allows_session_fixation
|
||||||
with_test_route_set do
|
with_test_route_set(:cookie_only => false) do
|
||||||
reset_with_fixation!
|
|
||||||
|
|
||||||
get '/set_session_value'
|
get '/set_session_value'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert cookies['_session_id']
|
assert cookies['_session_id']
|
||||||
|
@ -145,8 +142,6 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
|
||||||
session_id = cookies['_session_id']
|
session_id = cookies['_session_id']
|
||||||
assert session_id
|
assert session_id
|
||||||
|
|
||||||
reset_with_fixation!
|
|
||||||
|
|
||||||
get '/set_session_value', :_session_id => session_id, :foo => "baz"
|
get '/set_session_value', :_session_id => session_id, :foo => "baz"
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal session_id, cookies['_session_id']
|
assert_equal session_id, cookies['_session_id']
|
||||||
|
@ -159,24 +154,14 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def reset_app!
|
def with_test_route_set(options = {})
|
||||||
app = ActiveRecord::SessionStore.new(ActionController::Dispatcher.new, :key => '_session_id')
|
|
||||||
@integration_session = open_session(app)
|
|
||||||
end
|
|
||||||
|
|
||||||
def reset_with_fixation!
|
|
||||||
app = ActiveRecord::SessionStore.new(ActionController::Dispatcher.new, :key => '_session_id', :cookie_only => false)
|
|
||||||
@integration_session = open_session(app)
|
|
||||||
end
|
|
||||||
|
|
||||||
def with_test_route_set
|
|
||||||
with_routing do |set|
|
with_routing do |set|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.with_options :controller => "active_record_store_test/test" do |c|
|
map.connect "/:action", :controller => "active_record_store_test/test"
|
||||||
c.connect "/:action"
|
|
||||||
end
|
end
|
||||||
end
|
options = {:key => '_session_id'}.merge(options)
|
||||||
reset_app!
|
app = ActiveRecord::SessionStore.new(set, options)
|
||||||
|
@integration_session = open_session(app)
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,10 +46,6 @@ class CookieStoreTest < ActionController::IntegrationTest
|
||||||
def rescue_action(e) raise end
|
def rescue_action(e) raise end
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
|
||||||
reset_app!
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_raises_argument_error_if_missing_session_key
|
def test_raises_argument_error_if_missing_session_key
|
||||||
assert_raise(ArgumentError, nil.inspect) {
|
assert_raise(ArgumentError, nil.inspect) {
|
||||||
ActionDispatch::Session::CookieStore.new(nil,
|
ActionDispatch::Session::CookieStore.new(nil,
|
||||||
|
@ -193,10 +189,7 @@ class CookieStoreTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_session_store_with_expire_after
|
def test_session_store_with_expire_after
|
||||||
with_test_route_set do
|
with_test_route_set(:expire_after => 5.hours) do
|
||||||
app = ActionDispatch::Session::CookieStore.new(ActionController::Dispatcher.new, :key => SessionKey, :secret => SessionSecret, :expire_after => 5.hours)
|
|
||||||
@integration_session = open_session(app)
|
|
||||||
|
|
||||||
# First request accesses the session
|
# First request accesses the session
|
||||||
time = Time.local(2008, 4, 24)
|
time = Time.local(2008, 4, 24)
|
||||||
Time.stubs(:now).returns(time)
|
Time.stubs(:now).returns(time)
|
||||||
|
@ -226,20 +219,14 @@ class CookieStoreTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def reset_app!
|
def with_test_route_set(options = {})
|
||||||
app = ActionDispatch::Session::CookieStore.new(ActionController::Dispatcher.new,
|
|
||||||
:key => SessionKey, :secret => SessionSecret)
|
|
||||||
@integration_session = open_session(app)
|
|
||||||
end
|
|
||||||
|
|
||||||
def with_test_route_set
|
|
||||||
with_routing do |set|
|
with_routing do |set|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.with_options :controller => "cookie_store_test/test" do |c|
|
map.connect "/:action", :controller => "cookie_store_test/test"
|
||||||
c.connect "/:action"
|
|
||||||
end
|
end
|
||||||
end
|
options = {:key => SessionKey, :secret => SessionSecret}.merge(options)
|
||||||
reset_app!
|
app = ActionDispatch::Session::CookieStore.new(set, options)
|
||||||
|
@integration_session = open_session(app)
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,8 +32,6 @@ class MemCacheStoreTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
App = ActionDispatch::Session::MemCacheStore.new(ActionController::Dispatcher.new, :key => '_session_id')
|
|
||||||
|
|
||||||
def test_setting_and_getting_session_value
|
def test_setting_and_getting_session_value
|
||||||
with_test_route_set do
|
with_test_route_set do
|
||||||
get '/set_session_value'
|
get '/set_session_value'
|
||||||
|
@ -107,20 +105,13 @@ class MemCacheStoreTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def reset_app!
|
|
||||||
app = ActionDispatch::Session::MemCacheStore.new(
|
|
||||||
ActionController::Dispatcher.new, :key => '_session_id')
|
|
||||||
@integration_session = open_session(app)
|
|
||||||
end
|
|
||||||
|
|
||||||
def with_test_route_set
|
def with_test_route_set
|
||||||
with_routing do |set|
|
with_routing do |set|
|
||||||
set.draw do |map|
|
set.draw do |map|
|
||||||
map.with_options :controller => "mem_cache_store_test/test" do |c|
|
map.connect "/:action", :controller => "mem_cache_store_test/test"
|
||||||
c.connect "/:action"
|
|
||||||
end
|
end
|
||||||
end
|
app = ActionDispatch::Session::MemCacheStore.new(set, :key => '_session_id')
|
||||||
reset_app!
|
@integration_session = open_session(app)
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue