Skip to content

Commit

Permalink
Merge pull request #682 from MITLibraries/pubdate_deprecation
Browse files Browse the repository at this point in the history
Deprecated datePublished nil date handling
  • Loading branch information
JPrevost authored Mar 27, 2023
2 parents 63a9918 + 50e689a commit 5eb9ec7
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/graphql/types/record_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def related_place
end

def publication_date
@object['dates'].map { |date| date['value'] if date['kind'] == 'Publication date' }.compact&.first
@object['dates']&.map { |date| date['value'] if date['kind'] == 'Publication date' }&.compact&.first
end

def file_formats
Expand Down
24 changes: 20 additions & 4 deletions test/controllers/graphql_controller_v2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def setup
assert_equal('mit alma',
json['data']['search']['aggregations']['source']
.first['key'])
assert_equal(1429210,
assert_equal(1_429_210,
json['data']['search']['aggregations']['source']
.first['docCount'])
end
Expand All @@ -250,12 +250,29 @@ def setup
assert_equal('mit alma',
json['data']['search']['aggregations']['source']
.first['key'])
assert_equal(1429210,
assert_equal(1_429_210,
json['data']['search']['aggregations']['source']
.first['docCount'])
end
end

test 'graphqlv2 deprecated datePublished does not error when no dates returned' do
VCR.use_cassette('graphql v2 datePublished does not error when no dates returned') do
post '/graphql', params: { query: '{
recordId(id: "dspace:1721.1-2789") {
publicationDate
source
sourceLink
title
}
}' }
assert_equal(200, response.status)
json = JSON.parse(response.body)
assert_equal('DSpace@MIT', json['data']['recordId']['source'])
assert_nil(json['data']['recordId']['dates'])
end
end

test 'graphqlv2 search with multiple subjects applied' do
skip 'opensearch model is not updated to allow this yet'
VCR.use_cassette('graphql v2 search multiple subjects') do
Expand Down Expand Up @@ -331,7 +348,7 @@ def setup
end
end

test 'graphqlv2 retrieve with not found recordid' do
test 'graphqlv2 retrieve with not found recordid' do
VCR.use_cassette('graphql v2 retrieve not found') do
post '/graphql', params: { query: '{
recordId(id: "totallylegitrecordid") {
Expand All @@ -346,7 +363,6 @@ def setup
end
end


test 'graphqlv2 holding location is not required' do
VCR.use_cassette('graphql v2 location') do
post '/graphql', params: { query: '{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5eb9ec7

Please sign in to comment.