diff --git a/app/models/work_item.rb b/app/models/work_item.rb index bff150a2..684f0710 100644 --- a/app/models/work_item.rb +++ b/app/models/work_item.rb @@ -289,7 +289,7 @@ def self.create_restore_request_for_file(generic_file, requested_by) restore_item.node = nil restore_item.pid = 0 restore_item.needs_admin_review = false - restore_item.size = item.size + restore_item.size = generic_file.size restore_item.stage_started_at = nil restore_item.queued_at = nil restore_item.save! diff --git a/spec/models/work_item_spec.rb b/spec/models/work_item_spec.rb index 6a4afa62..d4555c33 100644 --- a/spec/models/work_item_spec.rb +++ b/spec/models/work_item_spec.rb @@ -207,6 +207,8 @@ def setup_item(subject) before do test_obj = FactoryBot.create(:intellectual_object, identifier: 'abc/123') FactoryBot.create(:generic_file, identifier: 'abc/123/doc.pdf', intellectual_object_id: test_obj.id) + FactoryBot.create(:generic_file, identifier: 'abc/123/txt.pdf', intellectual_object_id: test_obj.id) + FactoryBot.create(:generic_file, identifier: 'abc/123/ppt.pdf', intellectual_object_id: test_obj.id) 3.times do ingest_date = ingest_date + 1.days FactoryBot.create(:work_item, object_identifier: 'abc/123', @@ -224,6 +226,7 @@ def setup_item(subject) end it 'should create a restoration request when asked' do + test_obj = IntellectualObject.where(identifier: 'abc/123').first wi = WorkItem.create_restore_request('abc/123', 'mikey@example.com') wi.work_item_state = FactoryBot.build(:work_item_state, work_item: wi) wi.action.should == Pharos::Application::PHAROS_ACTIONS['restore'] @@ -238,6 +241,7 @@ def setup_item(subject) wi.pid.should == 0 wi.needs_admin_review.should == false wi.id.should_not be_nil + wi.size.should == test_obj.gf_size end it 'should create a file restoration request when asked' do @@ -257,6 +261,7 @@ def setup_item(subject) wi.needs_admin_review.should == false wi.id.should_not be_nil wi.generic_file_identifier.should == test_file.identifier + wi.size.should == test_file.size end it 'should create a glacier restoration request when asked' do