Fix bug in support for HTTPS with Rails LM/BH
This commit is contained in:
parent
206e65b92f
commit
dd8243108a
|
@ -44,11 +44,9 @@ module Webrat
|
|||
end
|
||||
|
||||
def absolute_href
|
||||
if href =~ %r{^https?://www.example.com(/.*)}
|
||||
$LAST_MATCH_INFO.captures.first
|
||||
elsif href =~ /^\?/
|
||||
if href =~ /^\?/
|
||||
"#{@session.current_url}#{href}"
|
||||
elsif href !~ /^\//
|
||||
elsif href !~ %r{^https?://www.example.com(/.*)} && (href !~ /^\//)
|
||||
"#{@session.current_url}/#{href}"
|
||||
else
|
||||
href
|
||||
|
|
|
@ -16,22 +16,22 @@ module Webrat
|
|||
|
||||
def get(url, data)
|
||||
update_protocol(url)
|
||||
@integration_session.get_via_redirect(url, data)
|
||||
@integration_session.get_via_redirect(remove_protocol(url), data)
|
||||
end
|
||||
|
||||
def post(url, data)
|
||||
update_protocol(url)
|
||||
@integration_session.post_via_redirect(url, data)
|
||||
@integration_session.post_via_redirect(remove_protocol(url), data)
|
||||
end
|
||||
|
||||
def put(url, data)
|
||||
update_protocol(url)
|
||||
@integration_session.put_via_redirect(url, data)
|
||||
@integration_session.put_via_redirect(remove_protocol(url), data)
|
||||
end
|
||||
|
||||
def delete(url, data)
|
||||
update_protocol(url)
|
||||
@integration_session.delete_via_redirect(url, data)
|
||||
@integration_session.delete_via_redirect(remove_protocol(url), data)
|
||||
end
|
||||
|
||||
def response_body
|
||||
|
@ -44,6 +44,14 @@ module Webrat
|
|||
|
||||
protected
|
||||
|
||||
def remove_protocol(href)
|
||||
if href =~ %r{^https?://www.example.com(/.*)}
|
||||
$LAST_MATCH_INFO.captures.first
|
||||
else
|
||||
href
|
||||
end
|
||||
end
|
||||
|
||||
def update_protocol(href)
|
||||
if href =~ /^https:/
|
||||
@integration_session.https!(true)
|
||||
|
|
|
@ -255,7 +255,7 @@ describe "clicks_link" do
|
|||
@session.response_body = <<-EOS
|
||||
<a href="http://www.example.com/page/sub">Jump to sub page</a>
|
||||
EOS
|
||||
@session.should_receive(:get).with("/page/sub", {})
|
||||
@session.should_receive(:get).with("http://www.example.com/page/sub", {})
|
||||
@session.clicks_link "Jump to sub page"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue