metadata: add ability to search exif metadata.
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
This commit is contained in:
@@ -9,6 +9,26 @@ class MediaMetadataControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user