Files
danbooru/test/test_helpers/iqdb_test_helper.rb
evazion fbab273c81 Upgrade http.rb gem to 5.0.4.
Fixes a bug where the Foundation source strategy failed because http.rb
automatically sent a `Content-Length: 0` header with all GET requests,
which caused Foundation to return a 400 Bad Request error. This behavior
was fixed in http.rb 5.x.

http.rb 5.x has a breaking change where it now includes the request object
inside the response object, which we have to handle in a few places.
2022-02-22 00:17:05 -06:00

8 lines
345 B
Ruby

module IqdbTestHelper
def mock_iqdb_matches(matches)
Danbooru.config.stubs(:iqdb_url).returns("http://localhost:5588")
response = HTTP::Response.new(status: 200, body: matches.to_json, headers: { "Content-Type": "application/json" }, version: "1.1", request: nil)
HTTP::Client.any_instance.stubs(:post).returns(response)
end
end