diff --git a/app/models/doi.rb b/app/models/doi.rb index 33a40ddfb..afd2f8012 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -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 diff --git a/app/models/event.rb b/app/models/event.rb index 16e982ec4..5fc8fbe38 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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}]: " + @@ -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 diff --git a/spec/fixtures/vcr_cassettes/DataciteDoisController/views/has_views_meta.yml b/spec/fixtures/vcr_cassettes/DataciteDoisController/views/has_views_meta.yml new file mode 100644 index 000000000..e92c9d30d --- /dev/null +++ b/spec/fixtures/vcr_cassettes/DataciteDoisController/views/has_views_meta.yml @@ -0,0 +1,55 @@ +--- +http_interactions: +- request: + method: get + uri: https://doi.org/ra/10.14454 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.7.2; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + response: + status: + code: 200 + message: '' + headers: + Date: + - Sun, 03 Jan 2021 19:42:13 GMT + Content-Type: + - application/json;charset=UTF-8 + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d6b9e658d262cb556d10dbfb44b8fb3911609702933; expires=Tue, 02-Feb-21 + 19:42:13 GMT; path=/; domain=.doi.org; HttpOnly; SameSite=Lax; Secure + Cf-Cache-Status: + - DYNAMIC + Cf-Request-Id: + - 076b5e9b15000063c54325b000000001 + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Report-To: + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=nYILO2MrAmy6cncBC5N%2Bz%2BMF6eN9hOa%2BL3RQ0PaLJH7OPJpzBhh1%2FbPXtSzA3JgVVUG%2BpFrofe%2Fk7dOc7Juu6Ag7IC8JSAK8"}],"group":"cf-nel","max_age":604800}' + Nel: + - '{"report_to":"cf-nel","max_age":604800}' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Server: + - cloudflare + Cf-Ray: + - 60bf33a4eee163c5-FRA + body: + encoding: ASCII-8BIT + string: |- + [ + { + "DOI": "10.14454", + "RA": "DataCite" + } + ] + http_version: null + recorded_at: Sun, 03 Jan 2021 19:42:13 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/requests/datacite_dois_spec.rb b/spec/requests/datacite_dois_spec.rb index e64006ed4..77f7440bb 100644 --- a/spec/requests/datacite_dois_spec.rb +++ b/spec/requests/datacite_dois_spec.rb @@ -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