diff --git a/app/models/concerns/arclight/solr_document.rb b/app/models/concerns/arclight/solr_document.rb index 712ce74bc..6bb1b69fc 100644 --- a/app/models/concerns/arclight/solr_document.rb +++ b/app/models/concerns/arclight/solr_document.rb @@ -65,7 +65,12 @@ def extent end def abstract_or_scope - first('abstract_ssm') || first('scopecontent_ssm') + if first('abstract_ssm') + # EAD may contain raw #PCDATA not wrapped in an HTML tag + "

#{first('abstract_ssm')}

" + else + first('scopecontent_ssm') + end end def creator diff --git a/spec/models/concerns/arclight/solr_document_spec.rb b/spec/models/concerns/arclight/solr_document_spec.rb index 27c3dc678..821eefd72 100644 --- a/spec/models/concerns/arclight/solr_document_spec.rb +++ b/spec/models/concerns/arclight/solr_document_spec.rb @@ -41,6 +41,24 @@ end end + describe '#abstract_or_scope' do + let(:document) do + SolrDocument.new(abstract_ssm: 'I will be wrapped', scopecontent_ssm: '

I am wrapped

') + end + + it 'returns abstract_ssm wrapped in a

tag' do + expect(document.abstract_or_scope).to eq '

I will be wrapped

' + end + + context 'when abstract_ssm is not present' do + let(:document) { SolrDocument.new(scopecontent_ssm: '

I am wrapped

') } + + it 'returns scopecontent_ssm' do + expect(document.abstract_or_scope).to eq '

I am wrapped

' + end + end + end + describe 'digital objects' do let(:document) do SolrDocument.new(