Fix #5221: Trying to upload an unsupported url shows ai tags error.
This commit is contained in:
@@ -245,6 +245,19 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_equal(source2, upload.source)
|
||||
end
|
||||
|
||||
should "save the AI tags" do
|
||||
mock_autotagger_evaluate({ "1girl": 0.5 })
|
||||
upload = assert_successful_upload("test/files/test.jpg")
|
||||
|
||||
assert_equal(1, upload.media_assets.first.ai_tags.count)
|
||||
end
|
||||
|
||||
should "save the EXIF metadata" do
|
||||
upload = assert_successful_upload("test/files/test.jpg")
|
||||
|
||||
assert_equal(true, upload.media_assets.first.media_metadata.present?)
|
||||
end
|
||||
|
||||
context "uploading a file from your computer" do
|
||||
should_upload_successfully("test/files/test.jpg")
|
||||
should_upload_successfully("test/files/test.png")
|
||||
|
||||
@@ -23,6 +23,7 @@ class ActiveSupport::TestCase
|
||||
extend PostArchiveTestHelper
|
||||
extend PoolArchiveTestHelper
|
||||
include ReportbooruHelper
|
||||
include AutotaggerHelper
|
||||
include DownloadTestHelper
|
||||
include IqdbTestHelper
|
||||
include UploadTestHelper
|
||||
|
||||
11
test/test_helpers/autotagger_helper.rb
Normal file
11
test/test_helpers/autotagger_helper.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module AutotaggerHelper
|
||||
def mock_autotagger_evaluate(tags, http: Danbooru::Http.any_instance)
|
||||
tags.keys.each { |name| create(:tag, name: name) }
|
||||
|
||||
Danbooru.config.stubs(:autotagger_url).returns("http://localhost:5000")
|
||||
body = [{ filename: "test.jpg", tags: tags }]
|
||||
|
||||
response = HTTP::Response.new(status: 200, body: body.to_json, version: "1.1", request: nil, headers: { "Content-Type": "application/json" })
|
||||
http.stubs(:post).with("http://localhost:5000/evaluate", anything).returns(response)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user