Usage: * https://danbooru.donmai.us/media_metadata?search[has_metadata]=true * https://danbooru.donmai.us/media_metadata?search[has_metadata]=false * https://danbooru.donmai.us/media_metadata?search[metadata_has_key]=GIF:GIFVersion * https://danbooru.donmai.us/media_metadata?search[metadata][GIF:GIFVersion]=89a * https://danbooru.donmai.us/media_metadata?search[metadata][GIF:GIFVersion]&search[metadata][GIF:BackgroundColor]=0
35 lines
1.3 KiB
Ruby
35 lines
1.3 KiB
Ruby
require 'test_helper'
|
|
|
|
class MediaMetadataControllerTest < ActionDispatch::IntegrationTest
|
|
context "The media metadata controller" do
|
|
context "index action" do
|
|
should "render" do
|
|
create(:media_metadata)
|
|
get media_metadata_path, as: :json
|
|
|
|
assert_response :success
|
|
end
|
|
|
|
context "searching" do
|
|
setup do
|
|
@jpg = create(:media_metadata, file: "test/files/test.jpg")
|
|
@gif = create(:media_metadata, file: "test/files/test.gif")
|
|
@png = create(:media_metadata, file: "test/files/test.png")
|
|
end
|
|
|
|
should respond_to_search(has_metadata: true).with { [@png, @gif, @jpg] }
|
|
|
|
should respond_to_search(metadata_has_key: "File:ColorComponents").with { [@jpg] }
|
|
should respond_to_search(metadata: { "File:ColorComponents": 3 }).with { [@jpg] }
|
|
should respond_to_search(metadata: { "File:ColorComponents": "3" }).with { [@jpg] }
|
|
|
|
should respond_to_search(metadata_has_key: "GIF:GIFVersion").with { [@gif] }
|
|
should respond_to_search(metadata: { "GIF:GIFVersion": "89a" }).with { [@gif] }
|
|
|
|
should respond_to_search(metadata_has_key: "PNG:ColorType").with { [@png] }
|
|
should respond_to_search(metadata: { "PNG:ColorType": "RGB" }).with { [@png] }
|
|
end
|
|
end
|
|
end
|
|
end
|