Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Default to loading unknown objects as a Dor::Item instance
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 11, 2016
1 parent 82705a1 commit 9d397b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/dor/models/identifiable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def adapt_to_cmodel
else
super
end
rescue ActiveFedora::ModelNotAsserted
self.adapt_to(Dor::Item)
end

private
Expand Down
8 changes: 8 additions & 0 deletions spec/dor/identifiable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,5 +345,13 @@ class IdentifiableItem < ActiveFedora::Base
expect(item.adapt_to_cmodel.class).to eq Dor::Agreement
end
end

context 'for an object without identityMetadata or a RELS-EXT model' do
let(:item) { item_from_foxml(read_fixture('foxml_empty.xml'), Dor::Abstract) }

it 'defaults to Dor::Item' do
expect(item.adapt_to_cmodel.class).to eq Dor::Item
end
end
end
end

0 comments on commit 9d397b1

Please sign in to comment.