Skip to content

Commit

Permalink
fix example with invalid datetime. #326
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 1, 2019
1 parent c20ea80 commit 7be7cf1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/fixtures/files/datacite_no_series_information.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<publisher>Keck Institute for Space Studies</publisher>
<publicationYear>2016</publicationYear>
<dates>
<date dateType="Available">2016-03-09 20:28:15</date>
<date dateType="Available">2016-03-09</date>
</dates>
<language>English</language>
<resourceType resourceTypeGeneral="Text">Discussion Paper</resourceType>
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/files/datacite_series_information.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<publisher>Keck Institute for Space Studies</publisher>
<publicationYear>2016</publicationYear>
<dates>
<date dateType="Available">2016-03-09 20:28:15</date>
<date dateType="Available">2016-03-09</date>
</dates>
<language>English</language>
<resourceType resourceTypeGeneral="Text">Discussion Paper</resourceType>
Expand Down
12 changes: 12 additions & 0 deletions spec/models/doi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,23 @@
expect(doi.errors.details).to be_empty
end

it "datetime" do
doi.dates = [{ "date" => "2019-08-01T20:28:15" }]
expect(doi.save).to be true
expect(doi.errors.details).to be_empty
end

it "invalid" do
doi.dates = [{ "date" => "08/01/2019" }]
expect(doi.save).to be false
expect(doi.errors.details).to eq(:dates=>[{:error=>"Date 08/01/2019 is not in a supported format."}])
end

it "invalid datetime" do
doi.dates = [{ "date" => "2019-08-01 20:28:15" }]
expect(doi.save).to be false
expect(doi.errors.details).to eq(:dates => [{:error=>"Date 2019-08-01 20:28:15 is not in a supported format."}])
end
end

describe "metadata" do
Expand Down

0 comments on commit 7be7cf1

Please sign in to comment.