Skip to content

Commit

Permalink
schemaOrgId is string
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 23, 2018
1 parent eb5565a commit 24cd277
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 56 deletions.
1 change: 0 additions & 1 deletion app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ def safe_params
:downloadLatency,
:hasSchemaOrg,
:schemaOrgId,
{ schemaOrgId: ["@type", :value, :propertyID] },
:dcIdentifier,
:citationDoi,
:bodyHasPid
Expand Down
5 changes: 1 addition & 4 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,7 @@ class Doi < ActiveRecord::Base
redirectUrls: { type: :keyword },
downloadLatency: { type: :scaled_float, scaling_factor: 100 },
hasSchemaOrg: { type: :boolean },
schemaOrgId: { type: :object, properties: {
"@type": { type: :keyword },
value: { type: :keyword },
propertyID: { type: :keyword }}},
schemaOrgId: { type: :keyword },
dcIdentifier: { type: :keyword },
citationDoi: { type: :keyword },
bodyHasPid: { type: :boolean }
Expand Down
102 changes: 51 additions & 51 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1850,61 +1850,61 @@
end
end

context 'landing page schema-org-id hash' do
let(:url) { "https://blog.datacite.org/re3data-science-europe/" }
let(:xml) { Base64.strict_encode64(file_fixture('datacite.xml').read) }
let(:landingPage) { {
"checked" => Time.zone.now.utc.iso8601,
"status" => 200,
"url" => url,
"contentType" => "text/html",
"error" => nil,
"redirectCount" => 0,
"redirectUrls" => [],
"downloadLatency" => 200,
"hasSchemaOrg" => true,
"schemaOrgId" => [
{
"@type" => "PropertyValue",
"value" => "http://dx.doi.org/10.4225/06/564AB348340D5",
"propertyID" => "URL"
}
],
"dcIdentifier" => nil,
"citationDoi" => nil,
"bodyHasPid" => true
} }
let(:valid_attributes) do
{
"data" => {
"type" => "dois",
"attributes" => {
"doi" => "10.14454/10703",
"url" => url,
"xml" => xml,
"landingPage" => landingPage,
"event" => "publish"
}
}
}
end
# context 'landing page schema-org-id hash' do
# let(:url) { "https://blog.datacite.org/re3data-science-europe/" }
# let(:xml) { Base64.strict_encode64(file_fixture('datacite.xml').read) }
# let(:landingPage) { {
# "checked" => Time.zone.now.utc.iso8601,
# "status" => 200,
# "url" => url,
# "contentType" => "text/html",
# "error" => nil,
# "redirectCount" => 0,
# "redirectUrls" => [],
# "downloadLatency" => 200,
# "hasSchemaOrg" => true,
# "schemaOrgId" => [
# {
# "@type" => "PropertyValue",
# "value" => "http://dx.doi.org/10.4225/06/564AB348340D5",
# "propertyID" => "URL"
# }
# ],
# "dcIdentifier" => nil,
# "citationDoi" => nil,
# "bodyHasPid" => true
# } }
# let(:valid_attributes) do
# {
# "data" => {
# "type" => "dois",
# "attributes" => {
# "doi" => "10.14454/10703",
# "url" => url,
# "xml" => xml,
# "landingPage" => landingPage,
# "event" => "publish"
# }
# }
# }
# end

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

it 'creates a Doi' do
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', 'landingPage')).to eq(landingPage)
end
# it 'creates a Doi' do
# 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', 'landingPage')).to eq(landingPage)
# end

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

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

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

0 comments on commit 24cd277

Please sign in to comment.