diff --git a/app/services/constituent_service.rb b/app/services/constituent_service.rb index 584dbcaeb4..00deba1ee2 100644 --- a/app/services/constituent_service.rb +++ b/app/services/constituent_service.rb @@ -29,7 +29,7 @@ def add(child_druids:) attr_reader :parent_druid def add_constituent(child_druid:) - child = ItemQueryService.find_modifiable_work(child_druid) + child = ItemQueryService.find_modifiable_item(child_druid) child.contentMetadata.ng_xml.search('//resource').each do |resource| parent.contentMetadata.add_virtual_resource(child.id, resource) end @@ -38,6 +38,6 @@ def add_constituent(child_druid:) end def parent - @parent ||= ItemQueryService.find_modifiable_work(parent_druid) + @parent ||= ItemQueryService.find_modifiable_item(parent_druid) end end diff --git a/app/services/item_query_service.rb b/app/services/item_query_service.rb index 8a3075ec76..7fbb4aca84 100644 --- a/app/services/item_query_service.rb +++ b/app/services/item_query_service.rb @@ -12,7 +12,7 @@ def initialize(id:, work_relation: default_work_relation) delegate :allows_modification?, to: :work # @raises [RuntimeError] if the item is not modifiable - def self.find_modifiable_work(druid) + def self.find_modifiable_item(druid) query_service = ItemQueryService.new(id: druid) query_service.work do |work| raise "Item #{work.pid} is not open for modification" unless query_service.allows_modification? diff --git a/app/services/reset_content_metadata_service.rb b/app/services/reset_content_metadata_service.rb index 1118df0b8f..1708c070bb 100644 --- a/app/services/reset_content_metadata_service.rb +++ b/app/services/reset_content_metadata_service.rb @@ -8,7 +8,7 @@ def initialize(druid:, type: 'image') end def reset - work = ItemQueryService.find_modifiable_work(@druid) + work = ItemQueryService.find_modifiable_item(@druid) work.contentMetadata.content = "" work.save! end diff --git a/spec/services/constituent_service_spec.rb b/spec/services/constituent_service_spec.rb index aaf6b60784..6940eec082 100644 --- a/spec/services/constituent_service_spec.rb +++ b/spec/services/constituent_service_spec.rb @@ -59,9 +59,9 @@ # Used in ContentMetadataDS#add_virtual_resource allow(parent.contentMetadata).to receive(:pid).and_return('druid:parent1') - allow(ItemQueryService).to receive(:find_modifiable_work).with('druid:parent1').and_return(parent) - allow(ItemQueryService).to receive(:find_modifiable_work).with('druid:child1').and_return(child1) - allow(ItemQueryService).to receive(:find_modifiable_work).with('druid:child2').and_return(child2) + allow(ItemQueryService).to receive(:find_modifiable_item).with('druid:parent1').and_return(parent) + allow(ItemQueryService).to receive(:find_modifiable_item).with('druid:child1').and_return(child1) + allow(ItemQueryService).to receive(:find_modifiable_item).with('druid:child2').and_return(child2) allow(Dor::Services::Client).to receive(:object).and_return(client) end @@ -90,7 +90,7 @@ context 'when the parent is closed for modification' do before do - allow(ItemQueryService).to receive(:find_modifiable_work).with(parent.id).and_raise('nope') + allow(ItemQueryService).to receive(:find_modifiable_item).with(parent.id).and_raise('nope') end it 'merges nothing' do @@ -102,7 +102,7 @@ context 'when the child is closed for modification' do before do - allow(ItemQueryService).to receive(:find_modifiable_work).with(child2.id).and_raise('not modifiable') + allow(ItemQueryService).to receive(:find_modifiable_item).with(child2.id).and_raise('not modifiable') end it 'merges all the chidren before an error is encountered' do