From ee17e7b6caa0733be1f922ec7eb98c78379ee67c Mon Sep 17 00:00:00 2001 From: Finn Bacall Date: Mon, 1 Jul 2024 16:16:28 +0100 Subject: [PATCH] Fix tests that were unintentionally linking to other people based on orcid --- test/functional/data_files_controller_test.rb | 4 ++-- test/unit/datacite_metadata_test.rb | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/functional/data_files_controller_test.rb b/test/functional/data_files_controller_test.rb index 5d5a242b0b..c6d13b7e96 100644 --- a/test/functional/data_files_controller_test.rb +++ b/test/functional/data_files_controller_test.rb @@ -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 } @@ -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 diff --git a/test/unit/datacite_metadata_test.rb b/test/unit/datacite_metadata_test.rb index c43c76154e..676d93c6c2 100644 --- a/test/unit/datacite_metadata_test.rb +++ b/test/unit/datacite_metadata_test.rb @@ -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 @@ -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