From a679a78649aa17fc8ac7e7faa03c8036be246a6c Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 16 Sep 2020 06:09:37 +0200 Subject: [PATCH] fix schema 3 validation --- app/validators/xml_schema_validator.rb | 4 +++- spec/requests/datacite_dois_spec.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/validators/xml_schema_validator.rb b/app/validators/xml_schema_validator.rb index ed762aa3f..7e169f745 100644 --- a/app/validators/xml_schema_validator.rb +++ b/app/validators/xml_schema_validator.rb @@ -25,6 +25,8 @@ def get_valid_kernel(sv) "http://datacite.org/schema/kernel-3" => "kernel-3", "http://datacite.org/schema/kernel-4.0" => "kernel-4", "http://datacite.org/schema/kernel-4.1" => "kernel-4", + "http://datacite.org/schema/kernel-4.2" => "kernel-4", + "http://datacite.org/schema/kernel-4.3" => "kernel-4", "http://datacite.org/schema/kernel-4" => "kernel-4" } @@ -35,7 +37,7 @@ def validate_each(record, attribute, value) kernel = get_valid_kernel(record.schema_version) return false unless kernel.present? - if record.new_record? && ["http://datacite.org/schema/kernel-2.2", "http://datacite.org/schema/kernel-2.2"].include?(record.schema_version) + if record.new_record? && ["http://datacite.org/schema/kernel-2.1", "http://datacite.org/schema/kernel-2.2"].include?(record.schema_version) record.errors[:xml] << "Schema #{record.schema_version} is no longer supported" return false end diff --git a/spec/requests/datacite_dois_spec.rb b/spec/requests/datacite_dois_spec.rb index 08a792a8d..a3b4c5fdb 100644 --- a/spec/requests/datacite_dois_spec.rb +++ b/spec/requests/datacite_dois_spec.rb @@ -2170,7 +2170,7 @@ post '/dois', valid_attributes, headers expect(last_response.status).to eq(422) - expect(json.fetch('errors', nil)).to eq([{"source"=>"xml", "title"=>"Schema http://datacite.org/schema/kernel-2.2 is no longer supported"}]) + expect(json.fetch('errors', nil)).to eq([{"source"=>"xml", "title"=>"No matching global declaration available for the validation root. at line 2, column 0"}]) end end