Refactoring rails session
This commit is contained in:
parent
ce9235f0fa
commit
d4f775ca9c
@ -17,23 +17,19 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get(url, data, headers = nil)
|
def get(url, data, headers = nil)
|
||||||
update_protocol(url)
|
do_request(:get, url, data, headers)
|
||||||
@integration_session.get_via_redirect(remove_protocol(url), data, headers)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def post(url, data, headers = nil)
|
def post(url, data, headers = nil)
|
||||||
update_protocol(url)
|
do_request(:post, url, data, headers)
|
||||||
@integration_session.post_via_redirect(remove_protocol(url), data, headers)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def put(url, data, headers = nil)
|
def put(url, data, headers = nil)
|
||||||
update_protocol(url)
|
do_request(:delete, url, data, headers)
|
||||||
@integration_session.put_via_redirect(remove_protocol(url), data, headers)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(url, data, headers = nil)
|
def delete(url, data, headers = nil)
|
||||||
update_protocol(url)
|
do_request(:delete, url, data, headers)
|
||||||
@integration_session.delete_via_redirect(remove_protocol(url), data, headers)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_body
|
def response_body
|
||||||
@ -45,6 +41,11 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def do_request(http_method, url, data, headers)
|
||||||
|
update_protocol(url)
|
||||||
|
@integration_session.request_via_redirect(http_method, remove_protocol(url), data, headers)
|
||||||
|
end
|
||||||
|
|
||||||
def remove_protocol(href)
|
def remove_protocol(href)
|
||||||
if href =~ %r{^https?://www.example.com(/.*)}
|
if href =~ %r{^https?://www.example.com(/.*)}
|
||||||
|
Loading…
Reference in New Issue
Block a user