Skip to content

Commit

Permalink
fix schema 3 validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Sep 16, 2020
1 parent 4073275 commit a679a78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/validators/xml_schema_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/datacite_dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a679a78

Please sign in to comment.