Skip to content

Commit

Permalink
properly handle nameType and nameIdentifiers. #164
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 26, 2018
1 parent bcaa93f commit 3ae1170
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 15 additions & 9 deletions spec/factories/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {[
Expand Down
2 changes: 1 addition & 1 deletion spec/models/doi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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")
Expand Down

0 comments on commit 3ae1170

Please sign in to comment.