Skip to content
This repository
Browse code

Clean up session integration tests so they don't reference AC::Dispat…

…cher
  • Loading branch information...
commit 0c638b340685b0bd1020bef2cd8a6d221058aa78 1 parent db65bb5
Joshua Peek josh authored
27 actionpack/test/activerecord/active_record_store_test.rb
@@ -33,7 +33,6 @@ def rescue_action(e) raise end
33 33
34 34 def setup
35 35 ActiveRecord::SessionStore.session_class.create_table!
36   - reset_app!
37 36 end
38 37
39 38 def teardown
@@ -132,9 +131,7 @@ def test_prevents_session_fixation
132 131 end
133 132
134 133 def test_allows_session_fixation
135   - with_test_route_set do
136   - reset_with_fixation!
137   -
  134 + with_test_route_set(:cookie_only => false) do
138 135 get '/set_session_value'
139 136 assert_response :success
140 137 assert cookies['_session_id']
@@ -145,8 +142,6 @@ def test_allows_session_fixation
145 142 session_id = cookies['_session_id']
146 143 assert session_id
147 144
148   - reset_with_fixation!
149   -
150 145 get '/set_session_value', :_session_id => session_id, :foo => "baz"
151 146 assert_response :success
152 147 assert_equal session_id, cookies['_session_id']
@@ -159,24 +154,14 @@ def test_allows_session_fixation
159 154 end
160 155
161 156 private
162   - def reset_app!
163   - app = ActiveRecord::SessionStore.new(ActionController::Dispatcher.new, :key => '_session_id')
164   - @integration_session = open_session(app)
165   - end
166   -
167   - def reset_with_fixation!
168   - app = ActiveRecord::SessionStore.new(ActionController::Dispatcher.new, :key => '_session_id', :cookie_only => false)
169   - @integration_session = open_session(app)
170   - end
171   -
172   - def with_test_route_set
  157 + def with_test_route_set(options = {})
173 158 with_routing do |set|
174 159 set.draw do |map|
175   - map.with_options :controller => "active_record_store_test/test" do |c|
176   - c.connect "/:action"
177   - end
  160 + map.connect "/:action", :controller => "active_record_store_test/test"
178 161 end
179   - reset_app!
  162 + options = {:key => '_session_id'}.merge(options)
  163 + app = ActiveRecord::SessionStore.new(set, options)
  164 + @integration_session = open_session(app)
180 165 yield
181 166 end
182 167 end
25 actionpack/test/dispatch/session/cookie_store_test.rb
@@ -46,10 +46,6 @@ def raise_data_overflow
@@ -193,10 +189,7 @@ def test_persistent_session_id
@@ -226,20 +219,14 @@ def test_session_store_with_expire_after
15 actionpack/test/dispatch/session/mem_cache_store_test.rb
@@ -32,8 +32,6 @@ def rescue_action(e) raise end
32 32 end
33 33
34 34 begin
35   - App = ActionDispatch::Session::MemCacheStore.new(ActionController::Dispatcher.new, :key => '_session_id')
36   -
37 35 def test_setting_and_getting_session_value
38 36 with_test_route_set do
39 37 get '/set_session_value'
@@ -107,20 +105,13 @@ def test_prevents_session_fixation
107 105 end
108 106
109 107 private
110   - def reset_app!
111   - app = ActionDispatch::Session::MemCacheStore.new(
112   - ActionController::Dispatcher.new, :key => '_session_id')
113   - @integration_session = open_session(app)
114   - end
115   -
116 108 def with_test_route_set
117 109 with_routing do |set|
118 110 set.draw do |map|
119   - map.with_options :controller => "mem_cache_store_test/test" do |c|
120   - c.connect "/:action"
121   - end
  111 + map.connect "/:action", :controller => "mem_cache_store_test/test"
122 112 end
123   - reset_app!
  113 + app = ActionDispatch::Session::MemCacheStore.new(set, :key => '_session_id')
  114 + @integration_session = open_session(app)
124 115 yield
125 116 end
126 117 end

0 comments on commit 0c638b3

Please sign in to comment.
Something went wrong with that request. Please try again.