Skip to content

Commit

Permalink
clearer error message for domain settings error. #690
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 3, 2021
1 parent c4fe223 commit 73942d5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,7 @@ def event=(value)

def check_url
unless url.blank? || client.blank? || match_url_with_domains(url: url, domains: client.domains)
errors.add(:url, "URL is not allowed by repository domain settings.")
errors.add(:url, "URL #{url} is not allowed by repository #{client.uid} domain settings.")
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def self.import_doi(id, options = {})
end

if doi.save
Rails.logger.info "Record for #{ra} DOI #{doi.doi}" +
Rails.logger.debug "Record for #{ra} DOI #{doi.doi}" +
(options[:refresh] ? " updated." : " created.")
else
Rails.logger.error "[Error saving #{ra} DOI #{doi.doi}]: " +
Expand All @@ -663,7 +663,7 @@ def self.import_doi(id, options = {})
doi
rescue ActiveRecord::RecordNotUnique => e
# handle race condition, no need to do anything else
Rails.logger.warn e.message
Rails.logger.debug e.message
end

def to_param
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/requests/datacite_dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@
post "/dois", valid_attributes, headers

expect(last_response.status).to eq(422)
expect(json.fetch("errors", nil)).to eq([{ "source" => "url", "title" => "URL is not allowed by repository domain settings." }])
expect(json.dig("errors", 0, "title")).to end_with("is not allowed by repository #{doi.client.uid} domain settings.")
end
end

Expand Down

0 comments on commit 73942d5

Please sign in to comment.