Merge pull request #36691 from Edouard-chin/ec-system-test-route

Don't include routes helpers inside System test class:
This commit is contained in:
Rafael França 2019-07-17 15:11:53 -04:00 committed by GitHub
commit 8d967534de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

@ -54,11 +54,5 @@ class Railtie < Rails::Railtie # :nodoc:
ActionDispatch.test_app = app
end
initializer "action_dispatch.system_tests" do |app|
ActiveSupport.on_load(:action_dispatch_system_test_case) do
include app.routes.url_helpers
end
end
end
end

@ -119,6 +119,11 @@ class SystemTestCase < ActiveSupport::TestCase
def initialize(*) # :nodoc:
super
self.class.driver.use
@proxy_route = if ActionDispatch.test_app
Class.new { include ActionDispatch.test_app.routes.url_helpers }.new
else
nil
end
end
def self.start_application # :nodoc:
@ -163,6 +168,14 @@ def url_options # :nodoc:
default_url_options.merge(host: Capybara.app_host)
end
def method_missing(method, *args, &block)
if @proxy_route.respond_to?(method)
@proxy_route.send(method, *args, &block)
else
super
end
end
ActiveSupport.run_load_hooks(:action_dispatch_system_test_case, self)
end