mirror of
https://github.com/github/rails.git
synced 2026-01-15 01:28:17 -05:00
Make ActiveResource#exists? work [#3020 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
committed by
Pratik Naik
parent
29a5549b34
commit
323f58f19f
@@ -75,7 +75,8 @@ module ActiveResource
|
||||
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
|
||||
@@ -155,7 +156,7 @@ module ActiveResource
|
||||
# Execute 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
|
||||
|
||||
|
||||
|
||||
@@ -965,6 +965,14 @@ class BaseTest < Test::Unit::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user