Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/models/concerns/arclight/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ def extent
end

def abstract_or_scope
first('abstract_ssm') || first('scopecontent_ssm')
if first('abstract_ssm')
# EAD <abstract> may contain raw #PCDATA not wrapped in an HTML tag
"<p>#{first('abstract_ssm')}</p>"
else
first('scopecontent_ssm')
end
end

def creator
Expand Down
18 changes: 18 additions & 0 deletions spec/models/concerns/arclight/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@
end
end

describe '#abstract_or_scope' do
let(:document) do
SolrDocument.new(abstract_ssm: 'I will be wrapped', scopecontent_ssm: '<p>I am wrapped</p>')
end

it 'returns abstract_ssm wrapped in a <p> tag' do
expect(document.abstract_or_scope).to eq '<p>I will be wrapped</p>'
end

context 'when abstract_ssm is not present' do
let(:document) { SolrDocument.new(scopecontent_ssm: '<p>I am wrapped</p>') }

it 'returns scopecontent_ssm' do
expect(document.abstract_or_scope).to eq '<p>I am wrapped</p>'
end
end
end

describe 'digital objects' do
let(:document) do
SolrDocument.new(
Expand Down