Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fallback host for SystemTestCase driven by RackTest #43273

Merged

Conversation

p8
Copy link
Member

@p8 p8 commented Sep 21, 2021

Summary

For links to work in SystemTestCases, it requires the host to be added
to the default_url_options. Since 78c7343 this is done by looking at
Capybara.app_host or Capybara.current_session.server_url.

This works correctly when using the Selenium webdriver, as Capybara sets
either the Capybara.app_host or the Capybara.current_session.server_url.
However the Capybara RackTest driver uses paths instead of URL's, so it doesn't
set Capybara.app_host or Capybara.current_session.server_url.

For SystemTestCase to work for the RackTest driver a host has to be
available for url options. We can fallback to "http://127.0.0.1" which
was the default before 78c7343.

Fixes: #42780

@rails-bot rails-bot bot added the actionpack label Sep 21, 2021
@p8 p8 marked this pull request as draft September 21, 2021 12:11
@p8 p8 force-pushed the actionpack/add-fallback-host-for-rack-system-tests branch from ddc26bd to bf03089 Compare September 21, 2021 17:33
For links to work in SystemTestCases, it requires the `host` to be added
to the `default_url_options`. Since
78c7343 this is done by looking at
`Capybara.app_host` or `Capybara.current_session.server_url`.

This works correctly when using the Selenium webdriver, as Capybara sets
either the `Capybara.app_host` or the `Capybara.current_session.server_url`.
However the Capybara RackTest driver uses paths instead of URL's, so it doesn't
set Capybara.app_host or Capybara.current_session.server_url.

For SystemTestCase to work for the RackTest driver a host has to be
available for url options. We can fallback to "http://127.0.0.1" which
was the default before 78c7343.
@p8 p8 force-pushed the actionpack/add-fallback-host-for-rack-system-tests branch from bf03089 to 4b78325 Compare September 21, 2021 18:09
@rails-bot rails-bot bot added the railties label Sep 21, 2021
@p8 p8 marked this pull request as ready for review September 21, 2021 18:41
@rafaelfranca rafaelfranca merged commit ce72a8a into rails:main Sep 21, 2021
rafaelfranca added a commit that referenced this pull request Sep 21, 2021
…ck-system-tests

Add fallback host for SystemTestCase driven by RackTest
@p8 p8 deleted the actionpack/add-fallback-host-for-rack-system-tests branch September 22, 2021 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rails 6.1.4 system tests for scaffolding fail out of the box with rack_test
2 participants