Prevent making a request if clicking on local anchor link
This commit is contained in:
parent
db3fe608ea
commit
407617b0be
@ -1,5 +1,6 @@
|
||||
== Trunk
|
||||
|
||||
* Prevent making a request if clicking on local anchor link (Patch from Kamal Fariz Mahyuddi)
|
||||
* Serialize empty text field values just like browsers (Patch from Kamal Fariz Mahyuddi)
|
||||
* Added clicks_link_within(selector, link_text), allowing restricting link search
|
||||
to within a given css selector (Path from Luke Melia)
|
||||
|
@ -241,7 +241,7 @@ module ActionController
|
||||
http_method = http_method_from_js(onclick)
|
||||
authenticity_token = authenticity_token_value(onclick)
|
||||
|
||||
request_page(http_method, href, authenticity_token.blank? ? {} : {"authenticity_token" => authenticity_token})
|
||||
request_page(http_method, href, authenticity_token.blank? ? {} : {"authenticity_token" => authenticity_token}) unless href =~ /^#/ && http_method == :get
|
||||
end
|
||||
|
||||
def find_field_by_name_or_label(name_or_label) # :nodoc:
|
||||
|
@ -181,5 +181,13 @@ class ClicksLinkTest < Test::Unit::TestCase
|
||||
@session.expects(:get_via_redirect).with("/page2", {})
|
||||
@session.clicks_link_within "#container", "Link"
|
||||
end
|
||||
|
||||
|
||||
def test_should_not_make_request_when_link_is_local_anchor
|
||||
@response.stubs(:body).returns(<<-EOS)
|
||||
<a href="#section-1">Jump to Section 1</a>
|
||||
EOS
|
||||
# Don't know why @session.expects(:get_via_redirect).never doesn't work here
|
||||
@session.expects(:send).with('get_via_redirect', '#section-1', {}).never
|
||||
@session.clicks_link "Jump to Section 1"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user