Skip to content

Commit

Permalink
support schema-org-id hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 18, 2018
1 parent c545ddd commit ac9c4fc
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def safe_params
"download-latency",
"has-schema-org",
"schema-org-id",
{ "schema-org-id" => ["@type", "value", "propertyID"] },
"dc-identifier",
"citation-doi",
"body-has-pid"
Expand Down
66 changes: 66 additions & 0 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,72 @@
expect(json.dig('data', 'attributes', 'state')).to eq("registered")
end
end

context 'landing page schema-org-id hash' do
let(:url) { "https://blog.datacite.org/re3data-science-europe/" }
let(:xml) { "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48cmVzb3VyY2UgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSIgeG1sbnM9Imh0dHA6Ly9kYXRhY2l0ZS5vcmcvc2NoZW1hL2tlcm5lbC00IiB4c2k6c2NoZW1hTG9jYXRpb249Imh0dHA6Ly9kYXRhY2l0ZS5vcmcvc2NoZW1hL2tlcm5lbC00IGh0dHA6Ly9zY2hlbWEuZGF0YWNpdGUub3JnL21ldGEva2VybmVsLTQvbWV0YWRhdGEueHNkIj48aWRlbnRpZmllciBpZGVudGlmaWVyVHlwZT0iRE9JIj4xMC4yNTQ5OS94dWRhMnB6cmFocm9lcXBlZnZucTV6dDZkYzwvaWRlbnRpZmllcj48Y3JlYXRvcnM+PGNyZWF0b3I+PGNyZWF0b3JOYW1lPklhbiBQYXJyeTwvY3JlYXRvck5hbWU+PG5hbWVJZGVudGlmaWVyIHNjaGVtZVVSST0iaHR0cDovL29yY2lkLm9yZy8iIG5hbWVJZGVudGlmaWVyU2NoZW1lPSJPUkNJRCI+MDAwMC0wMDAxLTYyMDItNTEzWDwvbmFtZUlkZW50aWZpZXI+PC9jcmVhdG9yPjwvY3JlYXRvcnM+PHRpdGxlcz48dGl0bGU+U3VibWl0dGVkIGNoZW1pY2FsIGRhdGEgZm9yIEluQ2hJS2V5PVlBUFFCWFFZTEpSWFNBLVVIRkZGQU9ZU0EtTjwvdGl0bGU+PC90aXRsZXM+PHB1Ymxpc2hlcj5Sb3lhbCBTb2NpZXR5IG9mIENoZW1pc3RyeTwvcHVibGlzaGVyPjxwdWJsaWNhdGlvblllYXI+MjAxNzwvcHVibGljYXRpb25ZZWFyPjxyZXNvdXJjZVR5cGUgcmVzb3VyY2VUeXBlR2VuZXJhbD0iRGF0YXNldCI+U3Vic3RhbmNlPC9yZXNvdXJjZVR5cGU+PHJpZ2h0c0xpc3Q+PHJpZ2h0cyByaWdodHNVUkk9Imh0dHBzOi8vY3JlYXRpdmVjb21tb25zLm9yZy9zaGFyZS15b3VyLXdvcmsvcHVibGljLWRvbWFpbi9jYzAvIj5ObyBSaWdodHMgUmVzZXJ2ZWQ8L3JpZ2h0cz48L3JpZ2h0c0xpc3Q+PC9yZXNvdXJjZT4=" }
let(:link_check_result) { {
"error" => nil,
"redirect-count" => 0,
"redirect-urls" => [],
"download-latency" => 200,
"has-schema-org" => true,
"schema-org-id" => [
{
"@type" => "PropertyValue",
"value" => "http://dx.doi.org/10.4225/06/564AB348340D5",
"propertyID" => "URL"
}
],
"dc-identifier" => nil,
"citation-doi" => nil,
"body-has-pid" => true
} }
let(:valid_attributes) do
{
"data" => {
"type" => "dois",
"attributes" => {
"doi" => "10.14454/10703",
"url" => url,
"xml" => xml,
"last-landing-page" => url,
"last-landing-page-status" => 200,
"last-landing-page-status-check" => Time.zone.now,
"last-landing-page-content-type" => "text/html",
"last-landing-page-status-result" => link_check_result,
"event" => "register"
},
"relationships"=> {
"client"=> {
"data"=> {
"type"=> "clients",
"id"=> client.symbol.downcase
}
}
}
}
}
end

before { post '/dois', params: valid_attributes.to_json, headers: headers }

it 'creates a Doi' do
puts response.body
expect(json.dig('data', 'attributes', 'url')).to eq(url)
expect(json.dig('data', 'attributes', 'doi')).to eq("10.14454/10703")
expect(json.dig('data', 'attributes', 'landing-page', 'status')).to eq(200)
expect(json.dig('data', 'attributes', 'landing-page', 'result')).to eq(link_check_result)
end

it 'returns status code 201' do
expect(response).to have_http_status(201)
end

it 'sets state to registered' do
expect(json.dig('data', 'attributes', 'state')).to eq("registered")
end
end
end

describe 'DELETE /dois/:id' do
Expand Down

0 comments on commit ac9c4fc

Please sign in to comment.