Commit b3b7e642 authored by Bruno Nocera Zanette's avatar Bruno Nocera Zanette

add "find_by_metadata" action to ItemResource

parent 60deeb18
......@@ -19,6 +19,13 @@ module Dspace
end
end
action :find_by_metadata, 'POST /rest/items/find-by-metadata-field' do
body { |object| JSON.generate(object.to_h) }
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_items(JSON.parse(response.body))
end
end
action :metadata, 'GET /rest/items/:id/metadata' do
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_metadatas(JSON.parse(response.body))
......
......@@ -15,6 +15,12 @@ RSpec.describe Dspace::Resources::ItemResource, resource_kit: true do
end
end
it 'find item by metadata field' do
expect(resource).to have_action(:find_by_metadata).that_handles(200).at_path('/rest/items/find-by-metadata-field').with_verb(:post) do |handled|
expect(handled).to all(be_kind_of(Dspace::Item))
end
end
it 'Delete item' do
expect(resource).to have_action(:delete).that_handles(200).at_path('/rest/items/:id').with_verb(:delete) do |handled|
expect(handled).to eq(true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment