Skip to content

Commit

Permalink
Fix stack overflow bug in integration test router helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Mar 30, 2010
1 parent 37102a5 commit 17f0c1e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Expand Up @@ -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
Expand Down
47 changes: 47 additions & 0 deletions actionpack/test/controller/integration_test.rb
Expand Up @@ -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

0 comments on commit 17f0c1e

Please sign in to comment.