1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Merge pull request #1492 from jnicklas/javascript_void

javascript:void(0) href fix
This commit is contained in:
Thomas Walpole 2015-03-17 10:49:14 -07:00
commit 74d9d53c3d
3 changed files with 4 additions and 1 deletions

View file

@ -27,7 +27,7 @@ class Capybara::RackTest::Browser
end
def follow(method, path, attributes = {})
return if path.gsub(/^#{request_path}/, '').start_with?('#')
return if path.gsub(/^#{request_path}/, '').start_with?('#') || path.downcase.start_with?('javascript:')
process_and_follow_redirects(method, path, attributes, {'HTTP_REFERER' => current_url})
end

View file

@ -116,6 +116,8 @@ Capybara::SpecHelper.spec '#click_link' do
expect(@session.find_field("test_field").value).to eq('blah')
@session.click_link('Blank Anchor')
expect(@session.find_field("test_field").value).to eq('blah')
@session.click_link('Blank JS Anchor')
expect(@session.find_field("test_field").value).to eq('blah')
end
it "should do nothing on URL+anchor links for the same page" do

View file

@ -45,6 +45,7 @@ banana</textarea>
<a>No Href</a>
<a href="">Blank Href</a>
<a href="#">Blank Anchor</a>
<a href="javascript:void(0)">Blank JS Anchor</a>
<a href="#anchor">Normal Anchor</a>
<a href="/with_simple_html#anchor">Anchor on different page</a>
<a href="/with_html#anchor">Anchor on same page</a>