Skip to content

Commit 8120e84

Browse files
committed
Support full records without pub_date or id
Why are these changes being introduced: * Some records don't have publication date information (which is expected) Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/TIMX-108 How does this address that need: * Adds nil protection for publication dates Document any side effects to this change: * After handling the publication date nil, an error occurred for identifier not being present. I believe this is unexpected and is a result of incomplete Alma mappings in dev1 at this time. Handling nils for identifers seemed fine to include even if the data will likely all include at least one identifier per record.
1 parent 3e87c87 commit 8120e84

File tree

4 files changed

+87
-2
lines changed

4 files changed

+87
-2
lines changed

app/helpers/record_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module RecordHelper
22
def doi(metadata)
3-
dois = metadata['identifiers'].select { |id| id['kind'].downcase == 'doi' }
3+
dois = metadata['identifiers']&.select { |id| id['kind'].downcase == 'doi' }
44
return unless dois.present?
55

66
dois.first['value']

app/views/record/_record.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2727
<% else %>
2828
29-
<% if @record['dates'].map{|date| date if date['kind'] == 'Publication date'}.compact.present? %>
29+
<% if @record['dates']&.map{|date| date if date['kind'] == 'Publication date'}&.compact.present? %>
3030
<span class="record-year">
3131
: Published <%= date_parse(publication_date(@record)) %>
3232
</span>

test/integration/error_resilience_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,15 @@ class ErrorResilienceTest < ActionDispatch::IntegrationTest
1515
end
1616
end
1717
end
18+
19+
# https://mitlibraries.atlassian.net/browse/TIMX-108
20+
# https://timdex-ui-pipeline-dev.herokuapp.com/record/alma:9935254980806761
21+
test 'records without publication dates display without errors' do
22+
VCR.use_cassette('alma record with no publication date',
23+
allow_playback_repeats: true,
24+
match_requests_on: %i[method uri body]) do
25+
get '/record/alma:9935254980806761'
26+
assert_response :success
27+
end
28+
end
1829
end

test/vcr_cassettes/alma_record_with_no_publication_date.yml

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)