Skip to content
This repository
Browse code

HTTP Accept header

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
commit 790ebf8eab39da1b4d62146fe10f4a77f5daca8c 1 parent 7ecb968
Edgar Suarez edgarjs authored NZKoz committed
2  activeresource/lib/active_resource/connection.rb
@@ -199,7 +199,7 @@ def default_header
199 199
200 200 # Builds headers for request to remote service.
201 201 def build_request_headers(headers, http_method=nil)
202   - authorization_header.update(default_header).update(headers).update(http_format_header(http_method))
  202 + authorization_header.update(default_header).update(http_format_header(http_method)).update(headers)
203 203 end
204 204
205 205 # Sets authorization header
12 activeresource/test/connection_test.rb
@@ -168,12 +168,20 @@ def test_delete_with_header
168 168 assert_equal 200, response.code
169 169 end
170 170
171   - uses_mocha('test_timeout') do
  171 + uses_mocha('test_timeout, test_accept_http_header') do
172 172 def test_timeout
173 173 @http = mock('new Net::HTTP')
174 174 @conn.expects(:http).returns(@http)
175 175 @http.expects(:get).raises(Timeout::Error, 'execution expired')
176   - assert_raises(ActiveResource::TimeoutError) { @conn.get('/people_timeout.xml') }
  176 + assert_raise(ActiveResource::TimeoutError) { @conn.get('/people_timeout.xml') }
  177 + end
  178 +
  179 + def test_accept_http_header
  180 + @http = mock('new Net::HTTP')
  181 + @conn.expects(:http).returns(@http)
  182 + path = '/people/1.xml'
  183 + @http.expects(:get).with(path, {'Accept' => 'application/xhtml+xml'}).returns(ActiveResource::Response.new(@matz, 200, {'Content-Type' => 'text/xhtml'}))
  184 + assert_nothing_raised(Mocha::ExpectationError) { @conn.get(path, {'Accept' => 'application/xhtml+xml'}) }
177 185 end
178 186 end
179 187

0 comments on commit 790ebf8

Please sign in to comment.
Something went wrong with that request. Please try again.