Skip to content

Commit bee45c2

Browse files
authored
Merge pull request #79 from MITLibraries/timx-108-pub-data
Support full records without pub_date or id
2 parents 3e87c87 + 8120e84 commit bee45c2

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)