[Posts] Fix the iqdb remove job

More faraday fallout. For delete requests, it expects this parameter to be iterable (if present)
This commit is contained in:
Earlopain 2024-05-07 21:52:54 +02:00
parent c60ee96133
commit d7ece18a1c
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
2 changed files with 5 additions and 4 deletions

View File

@ -15,9 +15,9 @@ module IqdbProxy
endpoint.present? endpoint.present?
end end
def make_request(path, request_type, params = {}) def make_request(path, request_type, body = nil)
conn = Faraday.new(Danbooru.config.faraday_options) conn = Faraday.new(Danbooru.config.faraday_options)
conn.send(request_type, endpoint + path, params.to_json, { content_type: "application/json" }) conn.send(request_type, endpoint + path, body&.to_json, { content_type: "application/json" })
rescue Faraday::Error rescue Faraday::Error
raise Error, "This service is temporarily unavailable. Please try again later." raise Error, "This service is temporarily unavailable. Please try again later."
end end

View File

@ -64,8 +64,9 @@ class PostTest < ActiveSupport::TestCase
end end
should "remove the post from iqdb" do should "remove the post from iqdb" do
@post.expects(:remove_iqdb_async).once request_stub = stub_request(:delete, "#{IqdbProxy.endpoint}/images/#{@post.id}")
@post.expunge! with_inline_jobs { @post.expunge! }
assert_requested request_stub
end end
context "that is status locked" do context "that is status locked" do