Skip to content

Commit

Permalink
Merge branch 'master' into add_rake_fix_types
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhallett committed Sep 28, 2020
2 parents eee1300 + a47573a commit f739a00
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/datacite_dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,12 @@ def safe_params
xml = xml.strip
end

fail(ActionController::UnpermittedParameters, ["creators must be an Array"]) if p[:creators]&.respond_to?(:keys)
p[:creators]&.each do |c|
fail(ActionController::UnpermittedParameters, ["nameIdentifiers must be an Array"]) if c[:nameIdentifiers]&.respond_to?(:keys)
end

fail(ActionController::UnpermittedParameters, ["contributors must be an Array"]) if p[:contributors]&.respond_to?(:keys)
p[:contributors]&.each do |c|
fail(ActionController::UnpermittedParameters, ["nameIdentifiers must be an Array"]) if c[:nameIdentifiers]&.respond_to?(:keys)
end
Expand Down
66 changes: 66 additions & 0 deletions spec/fixtures/files/nasa_error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"data": {
"type":"dois",
"id":"10.14454/rdnt.1x18sn",
"attributes":{
"doi": "10.14454/rdnt.1x18sn",
"prefix":"10.14454",
"creators":[
{
"name":"Maskey, Manil",
"nameType":"Personal",
"givenName":"Manil",
"familyName":"Maskey"
},
{
"name":"Ramachandran, Rahul",
"nameType":"Personal",
"givenName":"Rahul",
"familyName":"Ramachandran"
},
{
"name":"Gurung, Iksha",
"nameType":"Personal",
"givenName":"Iksha",
"familyName":"Gurung"
},
{
"name":"Ramasubramanian, Muthukumaran",
"nameType":"Personal",
"givenName":"Muthukumaran",
"familyName":"Ramasubramanian"
}
],
"titles":{
"title":"Tropical Cyclone Satellite Imagery and Wind Speed Dataset"
},
"publisher": "Radiant MLHub",
"publicationYear": 2020,
"types":{
"resourceTypeGeneral":"Dataset"
},
"version":1.0,
"contributors":{
"nameType":"Organizational",
"name":"NASA Interagency Implementation and Advanced Concepts Team (IMPACT)",
"contributorType":"DataCurator"
},
"dates":{
"dateType":"Valid",
"date": "2000/2019"
},
"fundingReferences":{
"funderName":"NASA Earth Science Data Systems Program"
},
"rightsList":{
"rights":"CC BY 4.0",
"rightsUri":"https://creativecommons.org/licenses/by/4.0/"
},
"url":"http://registry.mlhub.earth/10.34911/rdnt.1x18sn",
"landingPage":{
"url":"http://registry.mlhub.earth/10.34911/rdnt.1x18sn"
},
"event":"publish"
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions spec/requests/datacite_dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,16 @@
end
end

context 'when the request has wrong object in nameIDentifiers' do
let(:valid_attributes) { JSON.parse(file_fixture('nasa_error.json').read) }


it 'fails to create a Doi' do
post '/dois', valid_attributes, headers

expect(last_response.status).to eq(422)
end
end


# context 'when the request is a large xml file' do
Expand Down

0 comments on commit f739a00

Please sign in to comment.