aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2019-07-16 20:21:45 +0200
committerEdouard CHIN <edouard.chin@shopify.com>2019-07-16 22:18:32 +0200
commit2dbb904c5ef97799908a746c54d2997538aa2906 (patch)
treec94797efac27d9e2a809d1bac260d7cdf7dd8ee9 /actionpack
parent5a9301ce47f1117c8d457cad2b850f932bf7f518 (diff)
downloadrails-2dbb904c5ef97799908a746c54d2997538aa2906.tar.gz
rails-2dbb904c5ef97799908a746c54d2997538aa2906.tar.bz2
rails-2dbb904c5ef97799908a746c54d2997538aa2906.zip
Don't include routes helpers inside System test class:
- https://github.com/rails/rails/pull/36283 made a change to make SystemTest inherits from ActiveSupport::TestCase instead of ActionDispatch::IntegrationTest. With this change, the route helpers are now directly included inside the SystemTest class. This causes an edge case in case you have a routes whos name starts with `test_`, minitest will consider it as a test and will try to run it https://github.com/seattlerb/minitest/blob/ab39d35fb4e84eb866ed9c4ecb707cbf3889de42/lib/minitest/test.rb#L66 This PR uses a proxy and deleted missing method to a dummy class that has all the route helpers.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/railtie.rb6
-rw-r--r--actionpack/lib/action_dispatch/system_test_case.rb13
2 files changed, 13 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb
index 66f90980b9..2e09aed41d 100644
--- a/actionpack/lib/action_dispatch/railtie.rb
+++ b/actionpack/lib/action_dispatch/railtie.rb
@@ -54,11 +54,5 @@ module ActionDispatch
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
diff --git a/actionpack/lib/action_dispatch/system_test_case.rb b/actionpack/lib/action_dispatch/system_test_case.rb
index 29864c0f8e..9772beb8aa 100644
--- a/actionpack/lib/action_dispatch/system_test_case.rb
+++ b/actionpack/lib/action_dispatch/system_test_case.rb
@@ -119,6 +119,11 @@ module ActionDispatch
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 @@ module ActionDispatch
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