Skip to content

Commit

Permalink
Wrap EAD abstract in HTML tag
Browse files Browse the repository at this point in the history
  • Loading branch information
marlo-longley committed Oct 12, 2022
1 parent 1e9ba42 commit bc3df00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
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

0 comments on commit bc3df00

Please sign in to comment.