Permalink
Browse files

HTTP Accept header

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
1 parent 7ecb968 commit 790ebf8eab39da1b4d62146fe10f4a77f5daca8c @edgarjs edgarjs committed with NZKoz Sep 17, 2008
Showing with 11 additions and 3 deletions.
  1. +1 −1 activeresource/lib/active_resource/connection.rb
  2. +10 −2 activeresource/test/connection_test.rb
@@ -199,7 +199,7 @@ def default_header
# Builds headers for request to remote service.
def build_request_headers(headers, http_method=nil)
- authorization_header.update(default_header).update(headers).update(http_format_header(http_method))
+ authorization_header.update(default_header).update(http_format_header(http_method)).update(headers)
end
# Sets authorization header
@@ -168,12 +168,20 @@ def test_delete_with_header
assert_equal 200, response.code
end
- uses_mocha('test_timeout') do
+ uses_mocha('test_timeout, test_accept_http_header') do
def test_timeout
@http = mock('new Net::HTTP')
@conn.expects(:http).returns(@http)
@http.expects(:get).raises(Timeout::Error, 'execution expired')
- assert_raises(ActiveResource::TimeoutError) { @conn.get('/people_timeout.xml') }
+ assert_raise(ActiveResource::TimeoutError) { @conn.get('/people_timeout.xml') }
+ end
+
+ def test_accept_http_header
+ @http = mock('new Net::HTTP')
+ @conn.expects(:http).returns(@http)
+ path = '/people/1.xml'
+ @http.expects(:get).with(path, {'Accept' => 'application/xhtml+xml'}).returns(ActiveResource::Response.new(@matz, 200, {'Content-Type' => 'text/xhtml'}))
+ assert_nothing_raised(Mocha::ExpectationError) { @conn.get(path, {'Accept' => 'application/xhtml+xml'}) }
end
end

0 comments on commit 790ebf8

Please sign in to comment.