Skip to content

Commit

Permalink
Check if the routes object really responds to define_mount_prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Dec 9, 2010
1 parent f572a02 commit 28cf772
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -327,7 +327,7 @@ def app_name(app)
end

def define_generate_prefix(app, name)
return unless app.respond_to?(:routes)
return unless app.respond_to?(:routes) && app.routes.respond_to?(:define_mounted_helper)

_route = @set.named_routes.routes[name.to_sym]
_routes = @set
Expand Down
18 changes: 18 additions & 0 deletions actionpack/test/dispatch/mount_test.rb
Expand Up @@ -2,6 +2,17 @@

class TestRoutingMount < ActionDispatch::IntegrationTest
Router = ActionDispatch::Routing::RouteSet.new

class FakeEngine
def self.routes
Object.new
end

def self.call(env)
[200, {"Content-Type" => "text/html"}, ["OK"]]
end
end

Router.draw do
SprocketsApp = lambda { |env|
[200, {"Content-Type" => "text/html"}, ["#{env["SCRIPT_NAME"]} -- #{env["PATH_INFO"]}"]]
Expand All @@ -10,6 +21,8 @@ class TestRoutingMount < ActionDispatch::IntegrationTest
mount SprocketsApp, :at => "/sprockets"
mount SprocketsApp => "/shorthand"

mount FakeEngine, :at => "/fakeengine"

scope "/its_a" do
mount SprocketsApp, :at => "/sprocket"
end
Expand All @@ -33,4 +46,9 @@ def test_mounting_with_shorthand
get "/shorthand/omg"
assert_equal "/shorthand -- /omg", response.body
end

def test_with_fake_engine_does_not_call_invalid_method
get "/fakeengine"
assert_equal "OK", response.body
end
end

0 comments on commit 28cf772

Please sign in to comment.