Skip to content

Commit 180edc8

Browse files
committed
Override respond_to? since we are also overriding method_missing.
1 parent 49b6b49 commit 180edc8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

actionpack/lib/action_dispatch/routing/routes_proxy.rb

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def url_options
1616
end
1717
end
1818

19+
def respond_to?(method, include_private = false)
20+
super || routes.url_helpers.respond_to?(method)
21+
end
22+
1923
def method_missing(method, *args)
2024
if routes.url_helpers.respond_to?(method)
2125
self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1

actionpack/test/dispatch/prefix_generation_test.rb

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def self.routes
3030
match "/url_to_application", :to => "inside_engine_generating#url_to_application"
3131
match "/polymorphic_path_for_engine", :to => "inside_engine_generating#polymorphic_path_for_engine"
3232
match "/conflicting_url", :to => "inside_engine_generating#conflicting"
33+
match "/foo", :to => "never#invoked", :as => :named_helper_that_should_be_invoked_only_in_respond_to_test
3334
end
3435

3536
routes
@@ -152,6 +153,8 @@ def setup
152153
RailsApplication.routes.default_url_options = {}
153154
end
154155

156+
include BlogEngine.routes.mounted_helpers
157+
155158
# Inside Engine
156159
test "[ENGINE] generating engine's url use SCRIPT_NAME from request" do
157160
get "/pure-awesomeness/blog/posts/1"
@@ -219,6 +222,10 @@ def setup
219222
end
220223

221224
# Inside any Object
225+
test "[OBJECT] proxy route should override respond_to?() as expected" do
226+
assert_respond_to blog_engine, :named_helper_that_should_be_invoked_only_in_respond_to_test_path
227+
end
228+
222229
test "[OBJECT] generating engine's route includes prefix" do
223230
assert_equal "/awesome/blog/posts/1", engine_object.post_path(:id => 1)
224231
end

0 commit comments

Comments
 (0)