From 834507fcee4d17c4d94dd9f2799d4534518b00eb Mon Sep 17 00:00:00 2001 From: David Campbell Date: Thu, 15 Aug 2024 14:28:42 -0400 Subject: [PATCH] slightly changed wording --- .../tasks/dimensions_ingest_service_spec.rb | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/spec/services/tasks/dimensions_ingest_service_spec.rb b/spec/services/tasks/dimensions_ingest_service_spec.rb index 7084c33d7..393ce8d21 100644 --- a/spec/services/tasks/dimensions_ingest_service_spec.rb +++ b/spec/services/tasks/dimensions_ingest_service_spec.rb @@ -321,23 +321,24 @@ 'state_code' => 'US-AZ' } } - it 'returns a hash with author metadata' do - non_unc_affiliated_author = test_publications.first['authors'].find { |author| author['id'] != unc_grid_id } - # Ensure the author has multiple non-unc affiliations - non_unc_affiliated_author['affiliations'].append(non_unc_affiliation) - author_hash = service.author_to_hash(non_unc_affiliated_author, 0) - # Check that the author hash contains the expected metadata from the first affiliation - expect(author_hash).to eq( - { - 'name' => "#{[non_unc_affiliated_author['last_name'], non_unc_affiliated_author['first_name']].compact.join(', ')}", - 'other_affiliation' => non_unc_affiliated_author['affiliations'][0]['raw_affiliation'], - 'orcid' => "https://orcid.org/#{non_unc_affiliated_author['orcid'][0]}", - 'index' => '1' - } - ) - end context 'when an author has multiple affiliations' do + it 'uses their first affiliation to populate the author hash if no UNC affiliation exists' do + non_unc_affiliated_author = test_publications.first['authors'].find { |author| author['id'] != unc_grid_id } + # Ensure the author has multiple non-unc affiliations + non_unc_affiliated_author['affiliations'].append(non_unc_affiliation) unless non_unc_affiliated_author['affiliations'].size > 1 + author_hash = service.author_to_hash(non_unc_affiliated_author, 0) + # Check that the author hash contains the expected metadata from the first affiliation + expect(author_hash).to eq( + { + 'name' => "#{[non_unc_affiliated_author['last_name'], non_unc_affiliated_author['first_name']].compact.join(', ')}", + 'other_affiliation' => non_unc_affiliated_author['affiliations'][0]['raw_affiliation'], + 'orcid' => "https://orcid.org/#{non_unc_affiliated_author['orcid'][0]}", + 'index' => '1' + } + ) + end + it 'prioritizes retrieval of the UNC affiliation even if it is not the first one' do first_publication_authors = test_publications.first['authors'] # Retrieve the first UNC-affiliated author and their first UNC-affiliation