Skip to content

Commit

Permalink
Merge 0a2e86f into fc2b5e1
Browse files Browse the repository at this point in the history
  • Loading branch information
ndushay committed Aug 27, 2019
2 parents fc2b5e1 + 0a2e86f commit b2990f2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/services/constituent_service.rb
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion app/services/item_query_service.rb
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/services/reset_content_metadata_service.rb
Expand Up @@ -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 = "<contentMetadata objectId='#{work.id}' type='#{@type}'/>"
work.save!
end
Expand Down
10 changes: 5 additions & 5 deletions spec/services/constituent_service_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b2990f2

Please sign in to comment.