Skip to content

Commit

Permalink
slightly changed wording
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcam-src committed Aug 15, 2024
1 parent 6462ef7 commit 834507f
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions spec/services/tasks/dimensions_ingest_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 834507f

Please sign in to comment.