refactor iqdb query support

This commit is contained in:
Albert Yi
2018-06-14 17:03:41 -07:00
parent 97d0dca8a4
commit 9510dead9f
11 changed files with 134 additions and 125 deletions

View File

@@ -7,28 +7,12 @@ class IqdbQueriesControllerTest < ActionDispatch::IntegrationTest
as_user do
@posts = FactoryBot.create_list(:post, 2)
end
mock_iqdb_service!
end
context "create action" do
should "render with a post_id" do
mock_iqdb_matches!(@posts[0], @posts)
post_auth iqdb_queries_path, @user, params: { post_id: @posts[0].id, format: "js" }
assert_response :success
end
should "render with an url" do
mock_iqdb_matches!(@posts[0].source, @posts)
post_auth iqdb_queries_path, @user, params: { url: @posts[0].source }
assert_response :success
end
should "render for a json response" do
mock_iqdb_matches!(@posts[0].source, @posts)
get_auth iqdb_queries_path, @user, params: { url: @posts[0].source, format: "json" }
context "show action" do
should "render with matches" do
json = @posts.map {|x| [x.id, 1]}.to_json
get_auth iqdb_queries_path, @user, params: { matches: json }
assert_response :success
end
end