Skip to content

Commit

Permalink
Fix tests that were unintentionally linking to other people based on …
Browse files Browse the repository at this point in the history
…orcid
  • Loading branch information
fbacall committed Jul 1, 2024
1 parent 5ea08e7 commit ee17e7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test/functional/data_files_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4236,7 +4236,7 @@ def register_content_blob(skip_provide_metadata:false)
creators: [someone],
contributor: FactoryBot.create(:person, first_name: 'Joe', last_name: 'Bloggs', orcid: 'https://orcid.org/0000-0002-1694-233X')
).latest_version
thing.assets_creators.create!(given_name: 'Phil', family_name: 'Collins', orcid: 'https://orcid.org/0000-0002-1694-233X')
thing.assets_creators.create!(given_name: 'Phil', family_name: 'Collins', orcid: 'https://orcid.org/0000-0001-9842-9718')

get :show, params: { id: thing.parent.id, version: thing.version, format: :datacite_xml }

Expand All @@ -4252,7 +4252,7 @@ def register_content_blob(skip_provide_metadata:false)
phil = parsed.xpath("//xmlns:resource/xmlns:creators/xmlns:creator[xmlns:creatorName/text()='Collins, Phil']").first
jane = parsed.xpath("//xmlns:resource/xmlns:creators/xmlns:creator[xmlns:creatorName/text()='Bloggs, Jane']").first
assert_equal 'Collins, Phil', phil.xpath('./xmlns:creatorName').first.text
assert_equal 'https://orcid.org/0000-0002-1694-233X', phil.xpath('./xmlns:nameIdentifier').first.text
assert_equal 'https://orcid.org/0000-0001-9842-9718', phil.xpath('./xmlns:nameIdentifier').first.text
assert_equal 'Bloggs, Jane', jane.xpath('./xmlns:creatorName').first.text
assert_nil jane.xpath('./xmlns:nameIdentifier').first
assert_equal 'ORCID', resource.xpath('./xmlns:creators/xmlns:creator/xmlns:nameIdentifier/@nameIdentifierScheme').first.text
Expand Down
10 changes: 7 additions & 3 deletions test/unit/datacite_metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class DataciteMetadataTest < ActiveSupport::TestCase
creators: [someone],
contributor: FactoryBot.create(:person, first_name: 'Joe', last_name: 'Bloggs', orcid: 'https://orcid.org/0000-0002-1694-233X')
).latest_version
thing.assets_creators.create!(given_name: 'Phil', family_name: 'Collins', orcid: 'https://orcid.org/0000-0002-1694-233X')
thing.assets_creators.create!(given_name: 'Phil', family_name: 'Collins', orcid: 'https://orcid.org/0000-0001-9842-9718')
thing.assets_creators.create!(orcid: 'https://orcid.org/0000-0002-1694-233X')

metadata = thing.datacite_metadata
xml = metadata.build
Expand All @@ -93,13 +94,16 @@ class DataciteMetadataTest < ActiveSupport::TestCase
resource = parsed.xpath('//xmlns:resource').first
assert_equal 'The title', resource.xpath('./xmlns:titles/xmlns:title').first.text
assert_equal 'The description', resource.xpath('./xmlns:descriptions/xmlns:description').first.text
assert_equal 2, resource.xpath('./xmlns:creators/xmlns:creator').length
assert_equal 3, resource.xpath('./xmlns:creators/xmlns:creator').length
phil = parsed.xpath("//xmlns:resource/xmlns:creators/xmlns:creator[xmlns:creatorName/text()='Collins, Phil']").first
jane = parsed.xpath("//xmlns:resource/xmlns:creators/xmlns:creator[xmlns:creatorName/text()='Bloggs, Jane']").first
joe = parsed.xpath("//xmlns:resource/xmlns:creators/xmlns:creator[xmlns:creatorName/text()='Bloggs, Joe']").first
assert_equal 'Collins, Phil', phil.xpath('./xmlns:creatorName').first.text
assert_equal 'https://orcid.org/0000-0002-1694-233X', phil.xpath('./xmlns:nameIdentifier').first.text
assert_equal 'https://orcid.org/0000-0001-9842-9718', phil.xpath('./xmlns:nameIdentifier').first.text
assert_equal 'Bloggs, Jane', jane.xpath('./xmlns:creatorName').first.text
assert_nil jane.xpath('./xmlns:nameIdentifier').first
assert_equal 'Bloggs, Joe', joe.xpath('./xmlns:creatorName').first.text
assert_equal 'https://orcid.org/0000-0002-1694-233X', joe.xpath('./xmlns:nameIdentifier').first.text
assert_equal 'ORCID', resource.xpath('./xmlns:creators/xmlns:creator/xmlns:nameIdentifier/@nameIdentifierScheme').first.text
assert_equal 'https://orcid.org', resource.xpath('./xmlns:creators/xmlns:creator/xmlns:nameIdentifier/@schemeURI').first.text
assert_equal thing.created_at.year.to_s, resource.xpath('./xmlns:publicationYear').first.text
Expand Down

0 comments on commit ee17e7b

Please sign in to comment.