Skip to content

Commit

Permalink
Merge pull request #4517 from sul-dlss/reject-missing-citation
Browse files Browse the repository at this point in the history
Reject oclc citation entries that are missing the citationText and/or style keys
  • Loading branch information
cbeer authored Dec 13, 2024
2 parents bf9a619 + d423158 commit 8fc707b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/citations/oclc_citation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion spec/models/citations/oclc_citation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8fc707b

Please sign in to comment.