提交 109aad7c 编写于 作者: E Eileen M. Uchitelle 提交者: Gannon McGibbon

Merge pull request #36741 from Edouard-chin/ec-system-test-url-options

Define the `url_options` needed for SytemTest inside the route proxy:
上级 1a09b6eb
......@@ -120,7 +120,13 @@ def initialize(*) # :nodoc:
super
self.class.driver.use
@proxy_route = if ActionDispatch.test_app
Class.new { include ActionDispatch.test_app.routes.url_helpers }.new
Class.new do
include ActionDispatch.test_app.routes.url_helpers
def url_options
default_url_options.merge(host: Capybara.app_host)
end
end.new
else
nil
end
......@@ -164,10 +170,6 @@ def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400], options: {
driven_by :selenium
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)
......
# 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册