aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2012-01-03 20:26:45 +0100
committerJosé Valim <jose.valim@gmail.com>2012-01-03 20:27:38 +0100
commitd38dac8ea967d3a74598ebb72615ce7189a0add7 (patch)
treeca99c10ee246010e89ad255a0a5cdd4f2ad5c261
parent0d7d3a6e77c7f2f34236459bd1170951ded91bd5 (diff)
downloadrails-d38dac8ea967d3a74598ebb72615ce7189a0add7.tar.gz
rails-d38dac8ea967d3a74598ebb72615ce7189a0add7.tar.bz2
rails-d38dac8ea967d3a74598ebb72615ce7189a0add7.zip
Override respond_to? since we are also overriding method_missing.
-rw-r--r--actionpack/lib/action_dispatch/routing/routes_proxy.rb4
-rw-r--r--actionpack/test/dispatch/prefix_generation_test.rb7
2 files changed, 11 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/routes_proxy.rb b/actionpack/lib/action_dispatch/routing/routes_proxy.rb
index f7d5f6397d..73af5920ed 100644
--- a/actionpack/lib/action_dispatch/routing/routes_proxy.rb
+++ b/actionpack/lib/action_dispatch/routing/routes_proxy.rb
@@ -16,6 +16,10 @@ module ActionDispatch
end
end
+ def respond_to?(method, include_private = false)
+ super || routes.url_helpers.respond_to?(method)
+ end
+
def method_missing(method, *args)
if routes.url_helpers.respond_to?(method)
self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
diff --git a/actionpack/test/dispatch/prefix_generation_test.rb b/actionpack/test/dispatch/prefix_generation_test.rb
index 93eccaecbd..bd5b5edab0 100644
--- a/actionpack/test/dispatch/prefix_generation_test.rb
+++ b/actionpack/test/dispatch/prefix_generation_test.rb
@@ -30,6 +30,7 @@ module TestGenerationPrefix
match "/url_to_application", :to => "inside_engine_generating#url_to_application"
match "/polymorphic_path_for_engine", :to => "inside_engine_generating#polymorphic_path_for_engine"
match "/conflicting_url", :to => "inside_engine_generating#conflicting"
+ match "/foo", :to => "never#invoked", :as => :named_helper_that_should_be_invoked_only_in_respond_to_test
end
routes
@@ -152,6 +153,8 @@ module TestGenerationPrefix
RailsApplication.routes.default_url_options = {}
end
+ include BlogEngine.routes.mounted_helpers
+
# Inside Engine
test "[ENGINE] generating engine's url use SCRIPT_NAME from request" do
get "/pure-awesomeness/blog/posts/1"
@@ -219,6 +222,10 @@ module TestGenerationPrefix
end
# Inside any Object
+ test "[OBJECT] proxy route should override respond_to?() as expected" do
+ assert_respond_to blog_engine, :named_helper_that_should_be_invoked_only_in_respond_to_test_path
+ end
+
test "[OBJECT] generating engine's route includes prefix" do
assert_equal "/awesome/blog/posts/1", engine_object.post_path(:id => 1)
end