aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-09-26 20:51:05 -0500
committerJoshua Peek <josh@joshpeek.com>2009-09-26 20:51:05 -0500
commitacfeec515111d427b3a27aef3af034922e0d9248 (patch)
tree33e1ea90436ab5dc58fe8c2da4e3735696911e72 /actionpack
parent02413baabbc2d7458377822974ee3405a91fe627 (diff)
downloadrails-acfeec515111d427b3a27aef3af034922e0d9248.tar.gz
rails-acfeec515111d427b3a27aef3af034922e0d9248.tar.bz2
rails-acfeec515111d427b3a27aef3af034922e0d9248.zip
Allow integration test rack app to be set with "@app" ivar instead of using open_session
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb5
-rw-r--r--actionpack/test/activerecord/active_record_store_test.rb13
-rw-r--r--actionpack/test/controller/integration_test.rb2
-rw-r--r--actionpack/test/controller/rescue_test.rb7
-rw-r--r--actionpack/test/controller/webservice_test.rb4
-rw-r--r--actionpack/test/dispatch/session/cookie_store_test.rb4
-rw-r--r--actionpack/test/dispatch/session/mem_cache_store_test.rb6
-rw-r--r--actionpack/test/dispatch/show_exceptions_test.rb8
8 files changed, 22 insertions, 27 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index f344c1b572..4c0d4455f9 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -168,8 +168,8 @@ module ActionDispatch
attr_accessor :request_count
# Create and initialize a new Session instance.
- def initialize(app = nil)
- @app = app || ActionController::Dispatcher.new
+ def initialize(app)
+ @app = app
reset!
end
@@ -354,6 +354,7 @@ module ActionDispatch
# can use this method to open multiple sessions that ought to be tested
# simultaneously.
def open_session(app = nil)
+ app ||= @app ||= ActionController::Dispatcher.new
session = Integration::Session.new(app)
# delegate the fixture accessors back to the test instance
diff --git a/actionpack/test/activerecord/active_record_store_test.rb b/actionpack/test/activerecord/active_record_store_test.rb
index 71719c0f97..102b9cffdd 100644
--- a/actionpack/test/activerecord/active_record_store_test.rb
+++ b/actionpack/test/activerecord/active_record_store_test.rb
@@ -119,14 +119,10 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
reset!
- get '/set_session_value', :_session_id => session_id, :foo => "baz"
- assert_response :success
- assert_equal nil, cookies['_session_id']
-
get '/get_session_value', :_session_id => session_id
assert_response :success
assert_equal 'foo: nil', response.body
- assert_equal nil, cookies['_session_id']
+ assert_not_equal session_id, cookies['_session_id']
end
end
@@ -142,6 +138,8 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
session_id = cookies['_session_id']
assert session_id
+ reset!
+
get '/set_session_value', :_session_id => session_id, :foo => "baz"
assert_response :success
assert_equal session_id, cookies['_session_id']
@@ -159,9 +157,8 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
set.draw do |map|
map.connect "/:action", :controller => "active_record_store_test/test"
end
- options = {:key => '_session_id'}.merge(options)
- app = ActiveRecord::SessionStore.new(set, options)
- @integration_session = open_session(app)
+ @app = ActiveRecord::SessionStore.new(set, options.reverse_merge(:key => '_session_id'))
+ reset!
yield
end
end
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 61668b72f1..0e4ca21143 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -394,7 +394,7 @@ class MetalIntegrationTest < ActionController::IntegrationTest
end
def setup
- @integration_session = ActionController::Integration::Session.new(Poller)
+ @app = Poller
end
def test_successful_get
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb
index 09eddfe4a7..6ad708bba1 100644
--- a/actionpack/test/controller/rescue_test.rb
+++ b/actionpack/test/controller/rescue_test.rb
@@ -326,19 +326,16 @@ class RescueTest < ActionController::IntegrationTest
end
test 'rescue routing exceptions' do
- app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) do
+ @app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) do
rescue_from ActionController::RoutingError, lambda { |env| [200, {"Content-Type" => "text/html"}, "Gotcha!"] }
end
- @integration_session = open_session(app)
get '/b00m'
assert_equal "Gotcha!", response.body
end
test 'unrescued exception' do
- app = ActionDispatch::Rescue.new(ActionController::Routing::Routes)
- @integration_session = open_session(app)
-
+ @app = ActionDispatch::Rescue.new(ActionController::Routing::Routes)
assert_raise(ActionController::RoutingError) { get '/b00m' }
end
diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb
index 916124e221..c04d20fbad 100644
--- a/actionpack/test/controller/webservice_test.rb
+++ b/actionpack/test/controller/webservice_test.rb
@@ -245,8 +245,8 @@ class WebServiceTest < ActionController::IntegrationTest
private
def with_params_parsers(parsers = {})
old_session = @integration_session
- app = ActionDispatch::ParamsParser.new(ActionController::Routing::Routes, parsers)
- @integration_session = open_session(app)
+ @app = ActionDispatch::ParamsParser.new(ActionController::Routing::Routes, parsers)
+ reset!
yield
ensure
@integration_session = old_session
diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb
index bc0b4b22a5..6241c79829 100644
--- a/actionpack/test/dispatch/session/cookie_store_test.rb
+++ b/actionpack/test/dispatch/session/cookie_store_test.rb
@@ -222,8 +222,8 @@ class CookieStoreTest < ActionController::IntegrationTest
map.connect "/:action", :controller => "cookie_store_test/test"
end
options = {:key => SessionKey, :secret => SessionSecret}.merge(options)
- app = ActionDispatch::Session::CookieStore.new(set, options)
- @integration_session = open_session(app)
+ @app = ActionDispatch::Session::CookieStore.new(set, options)
+ reset!
yield
end
end
diff --git a/actionpack/test/dispatch/session/mem_cache_store_test.rb b/actionpack/test/dispatch/session/mem_cache_store_test.rb
index 4c6a80fdb8..c2d40ae24a 100644
--- a/actionpack/test/dispatch/session/mem_cache_store_test.rb
+++ b/actionpack/test/dispatch/session/mem_cache_store_test.rb
@@ -101,7 +101,7 @@ class MemCacheStoreTest < ActionController::IntegrationTest
get '/set_session_value', :_session_id => session_id
assert_response :success
- assert_equal nil, cookies['_session_id']
+ assert_not_equal session_id, cookies['_session_id']
end
end
rescue LoadError, RuntimeError
@@ -114,8 +114,8 @@ class MemCacheStoreTest < ActionController::IntegrationTest
set.draw do |map|
map.connect "/:action", :controller => "mem_cache_store_test/test"
end
- app = ActionDispatch::Session::MemCacheStore.new(set, :key => '_session_id')
- @integration_session = open_session(app)
+ @app = ActionDispatch::Session::MemCacheStore.new(set, :key => '_session_id')
+ reset!
yield
end
end
diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb
index d4800e4edb..9f6a93756c 100644
--- a/actionpack/test/dispatch/show_exceptions_test.rb
+++ b/actionpack/test/dispatch/show_exceptions_test.rb
@@ -35,7 +35,7 @@ class ShowExceptionsTest < ActionController::IntegrationTest
DevelopmentApp = ActionDispatch::ShowExceptions.new(Boomer, true)
test "rescue in public from a remote ip" do
- @integration_session = open_session(ProductionApp)
+ @app = ProductionApp
self.remote_addr = '208.77.188.166'
get "/"
@@ -52,7 +52,7 @@ class ShowExceptionsTest < ActionController::IntegrationTest
end
test "rescue locally from a local request" do
- @integration_session = open_session(ProductionApp)
+ @app = ProductionApp
self.remote_addr = '127.0.0.1'
get "/"
@@ -73,7 +73,7 @@ class ShowExceptionsTest < ActionController::IntegrationTest
old_locale, I18n.locale = I18n.locale, :da
begin
- @integration_session = open_session(ProductionApp)
+ @app = ProductionApp
self.remote_addr = '208.77.188.166'
get "/"
@@ -89,7 +89,7 @@ class ShowExceptionsTest < ActionController::IntegrationTest
end
test "always rescue locally in development mode" do
- @integration_session = open_session(DevelopmentApp)
+ @app = DevelopmentApp
self.remote_addr = '208.77.188.166'
get "/"