aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-03-30 13:58:18 -0500
committerJoshua Peek <josh@joshpeek.com>2010-03-30 13:58:18 -0500
commit17f0c1e9e8a5bfa7c4d2e1632c3b8b91f4678f03 (patch)
tree852436ea410bb28f0a0744119ef76b01a839afb0
parent37102a52373c368c1da18f916bfda1c4c4489fee (diff)
downloadrails-17f0c1e9e8a5bfa7c4d2e1632c3b8b91f4678f03.tar.gz
rails-17f0c1e9e8a5bfa7c4d2e1632c3b8b91f4678f03.tar.bz2
rails-17f0c1e9e8a5bfa7c4d2e1632c3b8b91f4678f03.zip
Fix stack overflow bug in integration test router helpers
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/routing.rb2
-rw-r--r--actionpack/test/controller/integration_test.rb47
2 files changed, 48 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
index 1bb81ede3b..08f3d90e18 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -168,7 +168,7 @@ module ActionDispatch
# ROUTES TODO: These assertions should really work in an integration context
def method_missing(selector, *args, &block)
- if @controller && @router.named_routes.helpers.include?(selector)
+ if @controller && @router && @router.named_routes.helpers.include?(selector)
@controller.send(selector, *args, &block)
else
super
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index c9782856bd..1e2ee06adc 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -430,3 +430,50 @@ class MetalIntegrationTest < ActionController::IntegrationTest
assert_equal 'http://www.example.com/foo', url_for(:controller => "foo")
end
end
+
+class ApplicationIntegrationTest < ActionController::IntegrationTest
+ class TestController < ActionController::Base
+ def index
+ render :text => "index"
+ end
+ end
+
+ def self.call(env)
+ routes.call(env)
+ end
+
+ def self.routes
+ @routes ||= ActionDispatch::Routing::RouteSet.new
+ end
+
+ routes.draw do
+ match 'foo', :to => 'application_integration_test/test#index', :as => :foo
+ match 'bar', :to => 'application_integration_test/test#index', :as => :bar
+ end
+
+ def app
+ self.class
+ end
+
+ test "includes route helpers" do
+ assert_equal '/foo', foo_path
+ assert_equal '/bar', bar_path
+ end
+
+ test "route helpers after controller access" do
+ get '/foo'
+ assert_equal '/foo', foo_path
+
+ get '/bar'
+ assert_equal '/bar', bar_path
+ end
+
+ test "missing route helper before controller access" do
+ assert_raise(NameError) { missing_path }
+ end
+
+ test "missing route helper after controller access" do
+ get '/foo'
+ assert_raise(NameError) { missing_path }
+ end
+end