Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#4939

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.

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

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. José Valim
    José Valim
    • Milestone cleared.
    • Assigned user set to José Valim

    June 24th, 2010 @ 01:27 AM

  2. Repository
    Repository
    • State changed from new to resolved

    (from [176c386409fd57bc03b9ebf1570a8955e21e0800]) Fix bug where ActiveResource::HttpMock would overwrite Accept/Content-Type header to application/xml [#4939 [Patch] ActiveResource::HttpMock overwrites Accept/Content-Type header state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/176c386409fd57bc03b9ebf1570a89...

    June 24th, 2010 @ 12:28 PM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM