Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix stack overflow bug in integration test router helpers

  • Loading branch information...
commit 17f0c1e9e8a5bfa7c4d2e1632c3b8b91f4678f03 1 parent 37102a5
Joshua Peek josh authored
2  actionpack/lib/action_dispatch/testing/assertions/routing.rb
View
@@ -168,7 +168,7 @@ def with_routing
# 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
47 actionpack/test/controller/integration_test.rb
View
@@ -430,3 +430,50 @@ def test_generate_url_without_controller
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
Please sign in to comment.
Something went wrong with that request. Please try again.