iqdb: switch to Danbooru::Http.

This commit is contained in:
evazion
2020-06-14 01:06:51 -05:00
parent a4df18e650
commit cd501fe27b
4 changed files with 37 additions and 60 deletions

View File

@@ -21,11 +21,9 @@ module IqdbTestHelper
Danbooru.config.stubs(:iqdbs_server).returns("http://localhost:3004")
end
def mock_iqdb_matches!(post_or_source, matches)
source = post_or_source.is_a?(Post) ? post_or_source.preview_file_url : post_or_source
url = "http://localhost:3004/similar?key=hunter2&url=#{CGI.escape source}&ref"
body = matches.map { |post| { post_id: post.id } }.to_json
stub_request(:get, url).to_return(body: body)
def mock_iqdb_matches(matches)
Danbooru.config.stubs(:iqdbs_server).returns("http://localhost:3004")
response = HTTP::Response.new(status: 200, body: matches.to_json, headers: { "Content-Type": "application/json" }, version: "1.1")
HTTP::Client.any_instance.stubs(:post).returns(response)
end
end