Merge branch 'master' of git@github.com:brynary/webrat
This commit is contained in:
commit
c7765a1e6c
@ -6,6 +6,7 @@
|
||||
* Support button elements (Patch from Nick Sieger)
|
||||
* Support matching select options by regexp (Patch from Kyle Hargraves)
|
||||
* Support relative links, including href="?foo=bar" (Patch from Kyle Hargraves)
|
||||
* Support links to fully qualified URLs starting with http:// or https:// (Luke Melia)
|
||||
|
||||
* Bug fixes
|
||||
|
||||
@ -27,7 +28,7 @@
|
||||
* Added reloads method to reload the page (Patch from Kamal Fariz Mahyuddi)
|
||||
* Prevent making a request if clicking on local anchor link (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)
|
||||
to within a given css selector (Patch from Luke Melia)
|
||||
* Allow specifying the input name/label when doing a select (Patch from David Chelimsky)
|
||||
* Raise a specific exception if the developer tries to manipulate form elements before loading a page (Patch from James Deville)
|
||||
* Add support for alternate POST, PUT and DELETE link clicking (Patch from Kyle Hargraves)
|
||||
|
@ -10,6 +10,7 @@ module Webrat
|
||||
method ||= http_method
|
||||
return if href =~ /^#/ && method == :get
|
||||
|
||||
update_protocol(href)
|
||||
Page.new(@page.session, absolute_href, method, authenticity_token.blank? ? {} : {"authenticity_token" => authenticity_token})
|
||||
end
|
||||
|
||||
@ -26,9 +27,19 @@ module Webrat
|
||||
def href
|
||||
@element["href"]
|
||||
end
|
||||
|
||||
def update_protocol(href)
|
||||
if href =~ /^https:/
|
||||
@page.session.https!(true)
|
||||
elsif href =~ /^http:/
|
||||
@page.session.https!(false)
|
||||
end
|
||||
end
|
||||
|
||||
def absolute_href
|
||||
if href =~ /^\?/
|
||||
if href =~ %r{^https?://www.example.com(/.*)}
|
||||
$LAST_MATCH_INFO.captures.first
|
||||
elsif href =~ /^\?/
|
||||
"#{@page.url}#{href}"
|
||||
elsif href !~ /^\//
|
||||
"#{@page.url}/#{href}"
|
||||
|
@ -199,6 +199,23 @@ describe "clicks_link" do
|
||||
@session.expects(:get_via_redirect).with("/page/sub", {})
|
||||
@session.clicks_link "Jump to sub page"
|
||||
end
|
||||
|
||||
it "should follow fully qualified local links" do
|
||||
@response.stubs(:body).returns(<<-EOS)
|
||||
<a href="http://www.example.com/page/sub">Jump to sub page</a>
|
||||
EOS
|
||||
@session.expects(:get_via_redirect).with("/page/sub", {})
|
||||
@session.clicks_link "Jump to sub page"
|
||||
end
|
||||
|
||||
it "should follow fully qualified secure local links" do
|
||||
@response.stubs(:body).returns(<<-EOS)
|
||||
<a href="https://www.example.com/page/sub">Jump to sub page</a>
|
||||
EOS
|
||||
@session.expects(:https!).with(true)
|
||||
@session.expects(:get_via_redirect).with("/page/sub", {})
|
||||
@session.clicks_link "Jump to sub page"
|
||||
end
|
||||
|
||||
it "should follow query parameters" do
|
||||
@session.current_page.stubs(:url).returns("/page")
|
||||
|
Loading…
Reference in New Issue
Block a user