tests: add iqdb queries controller tests.

This commit is contained in:
evazion
2017-02-06 16:06:23 -06:00
parent e26fb61ee9
commit 3edd814be5
4 changed files with 46 additions and 1 deletions

View File

@@ -16,5 +16,16 @@ module IqdbTestHelper
service = mock_sqs_service.new
Post.stubs(:iqdb_sqs_service).returns(service)
Danbooru.config.stubs(:iqdbs_auth_key).returns("hunter2")
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.complete_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
FakeWeb.register_uri(:get, url, body: body)
end
end