Skip to content

Commit

Permalink
Merge pull request #36691 from Edouard-chin/ec-system-test-route
Browse files Browse the repository at this point in the history
Don't include routes helpers inside System test class:
  • Loading branch information
rafaelfranca committed Jul 17, 2019
2 parents 6a50498 + 2dbb904 commit 8d96753
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 0 additions & 6 deletions actionpack/lib/action_dispatch/railtie.rb
Expand Up @@ -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
13 changes: 13 additions & 0 deletions actionpack/lib/action_dispatch/system_test_case.rb
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 8d96753

Please sign in to comment.