Merge commit 'hvolkmer/master'
Conflicts: lib/webrat/rails/rails_session.rb
This commit is contained in:
commit
420174829e
@ -54,7 +54,11 @@ module Webrat
|
||||
|
||||
def request_page(url, http_method, data)
|
||||
debug_log "REQUESTING PAGE: #{http_method.to_s.upcase} #{url} with #{data.inspect}"
|
||||
send "#{http_method}", url, data || {}
|
||||
if @current_url
|
||||
send "#{http_method}", url, data || {}, {"HTTP_REFERER" => @current_url}
|
||||
else
|
||||
send "#{http_method}", url, data || {}
|
||||
end
|
||||
|
||||
save_and_open_page if exception_caught?
|
||||
flunk("Page load was not successful (Code: #{response_code.inspect})") unless success_code?
|
||||
|
@ -14,24 +14,24 @@ module Webrat
|
||||
File.expand_path(File.join(RAILS_ROOT, "tmp"))
|
||||
end
|
||||
|
||||
def get(url, data)
|
||||
def get(url, data, headers = nil)
|
||||
update_protocol(url)
|
||||
@integration_session.get_via_redirect(remove_protocol(url), data)
|
||||
@integration_session.get_via_redirect(remove_protocol(url), data, headers)
|
||||
end
|
||||
|
||||
def post(url, data)
|
||||
def post(url, data, headers = nil)
|
||||
update_protocol(url)
|
||||
@integration_session.post_via_redirect(remove_protocol(url), data)
|
||||
@integration_session.post_via_redirect(remove_protocol(url), data, headers)
|
||||
end
|
||||
|
||||
def put(url, data)
|
||||
def put(url, data, headers = nil)
|
||||
update_protocol(url)
|
||||
@integration_session.put_via_redirect(remove_protocol(url), data)
|
||||
@integration_session.put_via_redirect(remove_protocol(url), data, headers)
|
||||
end
|
||||
|
||||
def delete(url, data)
|
||||
def delete(url, data, headers = nil)
|
||||
update_protocol(url)
|
||||
@integration_session.delete_via_redirect(remove_protocol(url), data)
|
||||
@integration_session.delete_via_redirect(remove_protocol(url), data, headers)
|
||||
end
|
||||
|
||||
def response_body
|
||||
|
@ -6,8 +6,9 @@ describe "reloads" do
|
||||
@session.response_body = "Hello world"
|
||||
end
|
||||
|
||||
it "should reload the page" do
|
||||
@session.should_receive(:get).with("/", {}).twice
|
||||
it "should reload the page with http referer" do
|
||||
@session.should_receive(:get).with("/", {})
|
||||
@session.should_receive(:get).with("/", {}, {"HTTP_REFERER"=>"/"})
|
||||
@session.visits("/")
|
||||
@session.reloads
|
||||
end
|
||||
|
@ -20,3 +20,17 @@ describe "visits" do
|
||||
lambda { @session.fills_in "foo", :with => "blah" }.should raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "visits with referer" do
|
||||
before do
|
||||
@session = Webrat::TestSession.new
|
||||
@session.instance_variable_set(:@current_url, "/old_url")
|
||||
@session.response_body = "Hello world"
|
||||
end
|
||||
|
||||
it "should use get with referer header" do
|
||||
@session.should_receive(:get).with("/", {}, {"HTTP_REFERER" => "/old_url"})
|
||||
@session.visits("/")
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user