提交 ad46884a 编写于 作者: J Jeremy Kemper

Integration tests support the OPTIONS http method

上级 6219bebb
## Rails 4.0.0 (unreleased) ##
* Integration tests support the `OPTIONS` method. *Jeremy Kemper*
* `expires_in` accepts a `must_revalidate` flag. If true, "must-revalidate"
is added to the Cache-Control header. *fxn*
......
......@@ -56,6 +56,12 @@ def head(path, parameters = nil, headers = nil)
process :head, path, parameters, headers
end
# Performs a OPTIONS request with the given parameters. See +#get+ for
# more details.
def options(path, parameters = nil, headers = nil)
process :options, path, parameters, headers
end
# Performs an XMLHttpRequest request with the given parameters, mirroring
# a request from the Prototype library.
#
......@@ -312,7 +318,7 @@ def reset!
@integration_session = Integration::Session.new(app)
end
%w(get post put head delete cookies assigns
%w(get post put head delete options cookies assigns
xml_http_request xhr get_via_redirect post_via_redirect).each do |method|
define_method(method) do |*args|
reset! unless integration_session
......
......@@ -105,6 +105,12 @@ def test_head
@session.head(path,params,headers)
end
def test_options
path = "/index"; params = "blah"; headers = {:location => 'blah'}
@session.expects(:process).with(:options,path,params,headers)
@session.options(path,params,headers)
end
def test_xml_http_request_get
path = "/index"; params = "blah"; headers = {:location => 'blah'}
headers_after_xhr = headers.merge(
......@@ -155,6 +161,16 @@ def test_xml_http_request_head
@session.xml_http_request(:head,path,params,headers)
end
def test_xml_http_request_options
path = "/index"; params = "blah"; headers = {:location => 'blah'}
headers_after_xhr = headers.merge(
"HTTP_X_REQUESTED_WITH" => "XMLHttpRequest",
"HTTP_ACCEPT" => "text/javascript, text/html, application/xml, text/xml, */*"
)
@session.expects(:process).with(:options,path,params,headers_after_xhr)
@session.xml_http_request(:options,path,params,headers)
end
def test_xml_http_request_override_accept
path = "/index"; params = "blah"; headers = {:location => 'blah', "HTTP_ACCEPT" => "application/xml"}
headers_after_xhr = headers.merge(
......@@ -212,7 +228,7 @@ def test_integration_methods_called
@integration_session.stubs(:generic_url_rewriter)
@integration_session.stubs(:process)
%w( get post head put delete ).each do |verb|
%w( get post head put delete options ).each do |verb|
assert_nothing_raised("'#{verb}' should use integration test methods") { __send__(verb, '/') }
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册