mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
fix issue when visiting / when app_host has a trailing /
This commit is contained in:
parent
e44214cd7b
commit
a5f81f97b6
2 changed files with 17 additions and 11 deletions
|
@ -257,18 +257,19 @@ module Capybara
|
|||
|
||||
uri_base.port ||= @server.port if @server && config.always_include_port
|
||||
|
||||
# TODO - this is only for compatability with previous 2.x behavior that concatenated
|
||||
# Capybara.app_host and a "relative" path - Consider removing in 3.0
|
||||
# @abotalov brought up a good point about this behavior potentially being useful to people
|
||||
# deploying to a subdirectory and/or single page apps where only the url fragment changes
|
||||
if visit_uri.scheme.nil? && uri_base
|
||||
visit_uri.path = uri_base.path + visit_uri.path
|
||||
end
|
||||
|
||||
if uri_base && [nil, 'http', 'https'].include?(visit_uri.scheme)
|
||||
visit_uri = uri_base.merge(visit_uri.to_hash.delete_if { |k,v| v.nil? })
|
||||
end
|
||||
visit_uri_parts = visit_uri.to_hash.delete_if { |k,v| v.nil? }
|
||||
|
||||
if visit_uri.scheme.nil?
|
||||
# TODO - this is only for compatability with previous 2.x behavior that concatenated
|
||||
# Capybara.app_host and a "relative" path - Consider removing in 3.0
|
||||
# @abotalov brought up a good point about this behavior potentially being useful to people
|
||||
# deploying to a subdirectory and/or single page apps where only the url fragment changes
|
||||
visit_uri_parts[:path] = uri_base.path + visit_uri.path
|
||||
end
|
||||
|
||||
visit_uri = uri_base.merge(visit_uri_parts)
|
||||
end
|
||||
driver.visit(visit_uri.to_s)
|
||||
end
|
||||
|
||||
|
|
|
@ -113,8 +113,13 @@ Capybara::SpecHelper.spec '#visit' do
|
|||
@session.visit('/times')
|
||||
expect(@session).to have_content('redirection complete')
|
||||
end
|
||||
end
|
||||
|
||||
it "should work if `app_host` has a trailing /", requires: [:server] do
|
||||
Capybara.app_host = "http://#{@session.server.host}:#{@session.server.port}/"
|
||||
@session.visit('/')
|
||||
expect(@session).to have_content('Hello world!')
|
||||
end
|
||||
end
|
||||
|
||||
it "should send no referer when visiting a page" do
|
||||
@session.visit '/get_referer'
|
||||
|
|
Loading…
Reference in a new issue