ask the named routes collection if the route is defined

we should not be accessing internals to figure out if a method is
defined.
This commit is contained in:
Aaron Patterson 2014-07-29 12:15:04 -07:00
parent 0088b08dca
commit f889831ed6
2 changed files with 5 additions and 1 deletions

View File

@ -94,6 +94,10 @@ module ActionDispatch
@module = Module.new
end
def route_defined?(name)
@module.method_defined? name
end
def helper_names
@helpers.map(&:to_s)
end

View File

@ -165,7 +165,7 @@ module ActionDispatch
# ROUTES TODO: These assertions should really work in an integration context
def method_missing(selector, *args, &block)
if defined?(@controller) && @controller && @routes && @routes.named_routes.helpers.include?(selector)
if defined?(@controller) && @controller && @routes && @routes.named_routes.route_defined?(selector)
@controller.send(selector, *args, &block)
else
super