aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2019-07-24 00:28:57 +0200
committerEdouard CHIN <edouard.chin@shopify.com>2019-07-24 01:18:00 +0200
commite6cf57df8a609c697c0bc593576f06895414da64 (patch)
tree740cc8de112a7fa6b57b8f289b5208995c2d5646 /railties/test
parent31105c81cc82ae829c382a4eee2c5aa362882dea (diff)
downloadrails-e6cf57df8a609c697c0bc593576f06895414da64.tar.gz
rails-e6cf57df8a609c697c0bc593576f06895414da64.tar.bz2
rails-e6cf57df8a609c697c0bc593576f06895414da64.zip
Define the `url_options` needed for SytemTest inside the route proxy:
- I made a change in https://github.com/rails/rails/pull/36691 to delegate route helper to a proxy class. This didn't take into account that the `url_options` we redefine in SystemTest would be ignored. This PR fixes that by definin the url_options inside the proxy
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/system_test_case_test.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/railties/test/application/system_test_case_test.rb b/railties/test/application/system_test_case_test.rb
new file mode 100644
index 0000000000..d15a0d9210
--- /dev/null
+++ b/railties/test/application/system_test_case_test.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+require "isolation/abstract_unit"
+require "rack/test"
+
+class SystemTestCaseTest < ActiveSupport::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ end
+
+ def teardown
+ teardown_app
+ end
+
+ test "url helpers are delegated to a proxy class" do
+ app_file "config/routes.rb", <<-RUBY
+ Rails.application.routes.draw do
+ get 'foo', to: 'foo#index', as: 'test_foo'
+ end
+ RUBY
+
+ app("test")
+
+ assert_not_includes(ActionDispatch::SystemTestCase.runnable_methods, :test_foo_url)
+ end
+
+ test "system tests set the Capybara host in the url_options by default" do
+ app_file "config/routes.rb", <<-RUBY
+ Rails.application.routes.draw do
+ get 'foo', to: 'foo#index', as: 'test_foo'
+ end
+ RUBY
+
+ app("test")
+ system_test = ActionDispatch::SystemTestCase.new("my_test")
+ previous_app_host = ::Capybara.app_host
+ ::Capybara.app_host = "https://my_test_example.com"
+
+ assert_equal("https://my_test_example.com/foo", system_test.test_foo_url)
+ ensure
+ ::Capybara.app_host = previous_app_host
+ end
+end