From 3ae11702ba3a718325033127e51bec05f7597289 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 26 Dec 2018 13:05:19 +0100 Subject: [PATCH] properly handle nameType and nameIdentifiers. #164 --- app/controllers/dois_controller.rb | 4 ++-- spec/factories/default.rb | 24 +++++++++++++++--------- spec/models/doi_spec.rb | 2 +- spec/requests/dois_spec.rb | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index d5ff4a4d5..5e36eac70 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -498,9 +498,9 @@ def safe_params :should_validate, :client, :creators, - { creators: [:type, :id, :name, :givenName, :familyName, :affiliation] }, + { creators: [:nameType, { nameIdentifiers: [:nameIdentifier, :nameIdentifierScheme] }, :name, :givenName, :familyName, :affiliation] }, :contributors, - { contributors: [:type, :id, :name, :givenName, :familyName, :affiliation, :contributorType] }, + { contributors: [:nameType, { nameIdentifiers: [:nameIdentifier, :nameIdentifierScheme] }, :name, :givenName, :familyName, :affiliation, :contributorType] }, :identifiers, { identifiers: [:identifier, :identifierType] }, :relatedIdentifiers, diff --git a/spec/factories/default.rb b/spec/factories/default.rb index 11d3bb357..514f507e0 100644 --- a/spec/factories/default.rb +++ b/spec/factories/default.rb @@ -36,52 +36,58 @@ }} creators { [ { - "type": "Person", + "nameType": "Personal", "name": "Benjamin Ollomo", "givenName": "Benjamin", "familyName": "Ollomo" }, { - "type": "Person", + "nameType": "Personal", "name": "Patrick Durand", "givenName": "Patrick", "familyName": "Durand" }, { - "type": "Person", + "nameType": "Personal", "name": "Franck Prugnolle", "givenName": "Franck", "familyName": "Prugnolle" }, { - "type": "Person", + "nameType": "Personal", "name": "Emmanuel J. P. Douzery", "givenName": "Emmanuel J. P.", "familyName": "Douzery" }, { - "type": "Person", + "nameType": "Personal", "name": "Céline Arnathau", "givenName": "Céline", "familyName": "Arnathau" }, { - "type": "Person", + "nameType": "Personal", "name": "Dieudonné Nkoghe", "givenName": "Dieudonné", "familyName": "Nkoghe" }, { - "type": "Person", + "nameType": "Personal", "name": "Eric Leroy", "givenName": "Eric", "familyName": "Leroy" }, { - "type": "Person", + "nameType": "Personal", "name": "François Renaud", "givenName": "François", - "familyName": "Renaud" + "familyName": "Renaud", + "nameIdentifiers": [ + { + "nameIdentifier": "https://orcid.org/0000-0003-1419-2405", + "nameIdentifierScheme": "ORCID" + } + ] } ] } titles {[ diff --git a/spec/models/doi_spec.rb b/spec/models/doi_spec.rb index 48a6482ea..28253097a 100644 --- a/spec/models/doi_spec.rb +++ b/spec/models/doi_spec.rb @@ -260,7 +260,7 @@ it "creators" do expect(subject.creators.length).to eq(8) - expect(subject.creators.first).to eq("familyName"=>"Ollomo", "givenName"=>"Benjamin", "name"=>"Benjamin Ollomo", "type"=>"Person") + expect(subject.creators.first).to eq("familyName"=>"Ollomo", "givenName"=>"Benjamin", "name"=>"Benjamin Ollomo", "nameType"=>"Personal") end it "dates" do diff --git a/spec/requests/dois_spec.rb b/spec/requests/dois_spec.rb index 05cfbe97f..2930bf9a2 100644 --- a/spec/requests/dois_spec.rb +++ b/spec/requests/dois_spec.rb @@ -780,7 +780,7 @@ "titles" => [{"title"=>"Eating your own Dog Food"}], "publisher" => "DataCite", "publicationYear" => 2016, - "creators" => [{"familyName"=>"Fenner", "givenName"=>"Martin", "id"=>"https://orcid.org/0000-0003-1419-2405", "name"=>"Fenner, Martin", "type"=>"Person"}], + "creators" => [{"familyName"=>"Fenner", "givenName"=>"Martin", "nameIdentifiers"=>[{ "nameIdentifier" => "https://orcid.org/0000-0003-1419-2405", "nameIdentifierScheme" => "ORCID" }], "name"=>"Fenner, Martin", "nameType"=>"Personal"}], "source" => "test", "event" => "publish" } @@ -794,7 +794,7 @@ expect(json.dig('data', 'attributes', 'url')).to eq("http://www.bl.uk/pdf/patspec.pdf") expect(json.dig('data', 'attributes', 'doi')).to eq("10.14454/10703") expect(json.dig('data', 'attributes', 'titles')).to eq([{"title"=>"Eating your own Dog Food"}]) - expect(json.dig('data', 'attributes', 'creators')).to eq( [{"familyName"=>"Fenner", "givenName"=>"Martin", "id"=>"https://orcid.org/0000-0003-1419-2405", "name"=>"Fenner, Martin", "type"=>"Person"}]) + expect(json.dig('data', 'attributes', 'creators')).to eq([{"familyName"=>"Fenner", "givenName"=>"Martin", "nameIdentifiers"=>[{"nameIdentifier"=>"https://orcid.org/0000-0003-1419-2405","nameIdentifierScheme"=>"ORCID"}], "name"=>"Fenner, Martin", "nameType"=>"Personal"}]) expect(json.dig('data', 'attributes', 'publisher')).to eq("DataCite") expect(json.dig('data', 'attributes', 'publicationYear')).to eq(2016) # expect(json.dig('data', 'attributes', 'schemaVersion')).to eq("http://datacite.org/schema/kernel-4")