This project is archived and is in readonly mode.

#4939 ✓resolved
Elomar França

[Patch] ActiveResource::HttpMock overwrites Accept/Content-Type header

Reported by Elomar França | June 22nd, 2010 @ 11:56 PM | in 3.0.2

ActiveResource::HttpMock always overwrite the Accept/Content-Header parameter of the recorded response to "application/xml", making it impossible to mock two different responses to the same method/url but with different mime types.

ActiveResource::HttpMock.respond_to do |mock|
  mock.get "/people/1", {"Accept" => "application/xml"}, "XML"
  mock.get "/people/1", {"Accept" => "application/json"}, "Json"
end

@http.get("/people/1", {"Accept" => "application/json"}).body # > XML

This patch fixes that by 1) not overwriting the format header and 2) ignoring it on the response match on it's not set on the mock and add some basic tests to HttpMock, but I think the code can be improved.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages