Permalink
Browse files

Check if the routes object really responds to define_mount_prefix.

  • Loading branch information...
1 parent f572a02 commit 28cf77203b0b5af648e441b5d9cfb75863ba2f39 @josevalim josevalim committed Dec 9, 2010
Showing with 19 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +18 −0 actionpack/test/dispatch/mount_test.rb
@@ -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
@@ -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"]}"]]
@@ -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
@@ -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.