提交 1fc1986d 编写于 作者: J Jatinder Singh 提交者: Pratik Naik

Make ActiveResource#exists? work [#3020 state:resolved]

Signed-off-by: NPratik Naik <pratiknaik@gmail.com>
上级 0ec64bea
......@@ -13,7 +13,8 @@ class Connection
HTTP_FORMAT_HEADER_NAMES = { :get => 'Accept',
:put => 'Content-Type',
:post => 'Content-Type',
:delete => 'Accept'
:delete => 'Accept',
:head => 'Accept'
}
attr_reader :site, :user, :password, :timeout, :proxy, :ssl_options
......@@ -93,7 +94,7 @@ def post(path, body = '', headers = {})
# Executes a HEAD request.
# Used to obtain meta-information about resources, such as whether they exist and their size (via response headers).
def head(path, headers = {})
request(:head, path, build_request_headers(headers))
request(:head, path, build_request_headers(headers, :head))
end
......
......@@ -966,6 +966,14 @@ def to_param
end
end
def test_exists_without_http_mock
http = Net::HTTP.new(Person.site.host, Person.site.port)
ActiveResource::Connection.any_instance.expects(:http).returns(http)
http.expects(:request).returns(ActiveResource::Response.new(""))
assert Person.exists?('not-mocked')
end
def test_to_xml
matz = Person.find(1)
xml = matz.encode
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册