clicking on a link with blank href should go to the current url

This commit is contained in:
Thomas Walpole 2017-03-23 17:26:13 -07:00
parent d6cc9d4320
commit 362188e803
3 changed files with 14 additions and 4 deletions

View File

@ -45,10 +45,13 @@ class Capybara::RackTest::Browser
def process(method, path, attributes = {}, env = {})
new_uri = URI.parse(path)
method.downcase! unless method.is_a? Symbol
new_uri.path = request_path if path.start_with?("?")
new_uri.path = "/" if new_uri.path.empty?
new_uri.path = request_path.sub(%r(/[^/]*$), '/') + new_uri.path unless new_uri.path.start_with?('/')
if path.empty?
new_uri.path = request_path
else
new_uri.path = request_path if path.start_with?("?")
new_uri.path = "/" if new_uri.path.empty?
new_uri.path = request_path.sub(%r(/[^/]*$), '/') + new_uri.path unless new_uri.path.start_with?('/')
end
new_uri.scheme ||= @current_scheme
new_uri.host ||= @current_host
new_uri.port ||= @current_port unless new_uri.default_port == @current_port

View File

@ -314,6 +314,12 @@ Capybara::SpecHelper.spec "node" do
expect(@session.current_url).to match(%r{/with_html$})
end
it "should go to the same page if href is blank" do
@session.find(:css, '#link_blank_href').click
sleep 1
expect(@session).to have_current_path('/with_html')
end
it "should be able to check a checkbox" do
@session.visit('form')
cbox = @session.find(:checkbox, 'form_terms_of_use')

View File

@ -119,4 +119,5 @@ banana</textarea>
<div>
<a id="link_placeholder">No href</a>
<a id="link_blank_href" href="">Blank href</a>
</div>