diff --git a/app/models/citations/oclc_citation.rb b/app/models/citations/oclc_citation.rb index bc197894e..5151e8000 100644 --- a/app/models/citations/oclc_citation.rb +++ b/app/models/citations/oclc_citation.rb @@ -40,7 +40,7 @@ def group_citations_by_oclc_number # into data like: { oclc_number => { citation_style => citation_text } } def transform_grouped_citations(grouped_citations) grouped_citations.transform_values do |citations| - citations.to_h { |citation| [searchworks_style_code(citation['style']), citation['citationText']&.html_safe] } # rubocop:disable Rails/OutputSafety + citations.to_h { |citation| [searchworks_style_code(citation['style']), citation['citationText']&.html_safe] }.compact # rubocop:disable Rails/OutputSafety end end diff --git a/spec/models/citations/oclc_citation_spec.rb b/spec/models/citations/oclc_citation_spec.rb index 5710c9817..15c393180 100644 --- a/spec/models/citations/oclc_citation_spec.rb +++ b/spec/models/citations/oclc_citation_spec.rb @@ -11,7 +11,8 @@ before do allow(OclcDiscoveryClient).to receive(:new).and_return(oclc_client) allow(oclc_client).to receive(:citations).and_return( - ['entries' => [{ 'oclcNumber' => '12345', 'style' => 'apa', 'citationText' => 'Citation Content' }]] + ['entries' => [{ 'oclcNumber' => '12345', 'style' => 'apa', 'citationText' => 'Citation Content' }, + { 'oclcNumber' => '12345', 'resultType' => 'problem', 'type' => 'UNSUPPORTED_MATERIAL_FORMAT_TYPE' }]] ) allow(Settings.oclc_discovery.citations).to receive(:enabled).and_return(oclc_enabled) end