mirror of https://github.com/rails/rails
Dont try to call method missing in routes if thats not what we want
If, doing a test like this: ``` class BugTest < ActionView::TestCase def test_foo omg end ``` Will raise with: ``` RuntimeError: In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers`. ``` Thats a bit confusing, as we are not calling url_for at all.
This commit is contained in:
parent
942f412631
commit
0ffaa56d51
|
@ -263,9 +263,15 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(selector, *args)
|
def method_missing(selector, *args)
|
||||||
if @controller.respond_to?(:_routes) &&
|
begin
|
||||||
( @controller._routes.named_routes.route_defined?(selector) ||
|
routes = @controller.respond_to?(:_routes) && @controller._routes
|
||||||
@controller._routes.mounted_helpers.method_defined?(selector) )
|
rescue
|
||||||
|
# Dont call routes, if there is an error on _routes call
|
||||||
|
end
|
||||||
|
|
||||||
|
if routes &&
|
||||||
|
( routes.named_routes.route_defined?(selector) ||
|
||||||
|
routes.mounted_helpers.method_defined?(selector) )
|
||||||
@controller.__send__(selector, *args)
|
@controller.__send__(selector, *args)
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
|
Loading…
Reference in New Issue