From 7be7cf19cdd94644e733aad6b61fed2472492c23 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 1 Aug 2019 11:03:01 +0200 Subject: [PATCH] fix example with invalid datetime. #326 --- .../files/datacite_no_series_information.xml | 2 +- spec/fixtures/files/datacite_series_information.xml | 2 +- spec/models/doi_spec.rb | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/fixtures/files/datacite_no_series_information.xml b/spec/fixtures/files/datacite_no_series_information.xml index eb905ae95..c70451d46 100644 --- a/spec/fixtures/files/datacite_no_series_information.xml +++ b/spec/fixtures/files/datacite_no_series_information.xml @@ -16,7 +16,7 @@ Keck Institute for Space Studies 2016 - 2016-03-09 20:28:15 + 2016-03-09 English Discussion Paper diff --git a/spec/fixtures/files/datacite_series_information.xml b/spec/fixtures/files/datacite_series_information.xml index bb3ae8016..1db33bc49 100644 --- a/spec/fixtures/files/datacite_series_information.xml +++ b/spec/fixtures/files/datacite_series_information.xml @@ -16,7 +16,7 @@ Keck Institute for Space Studies 2016 - 2016-03-09 20:28:15 + 2016-03-09 English Discussion Paper diff --git a/spec/models/doi_spec.rb b/spec/models/doi_spec.rb index 30330078e..1813c1cc6 100644 --- a/spec/models/doi_spec.rb +++ b/spec/models/doi_spec.rb @@ -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