From 11d42cbf2a06e6a5ab3c0bc127f8125fe2ed316f Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 28 May 2020 06:22:52 +0200 Subject: [PATCH] make sure affiliation is a hash --- app/models/doi.rb | 4 +-- spec/fixtures/files/rwth.xml | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/files/rwth.xml diff --git a/app/models/doi.rb b/app/models/doi.rb index bdad3e987..68d276a03 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -1511,7 +1511,7 @@ def provider_id_and_name def affiliation_id Array.wrap(creators).reduce([]) do |sum, creator| Array.wrap(creator.fetch("affiliation", nil)).each do |affiliation| - sum << ror_from_url(affiliation.fetch("affiliationIdentifier", nil)) if affiliation.fetch("affiliationIdentifierScheme", nil) == "ROR" && affiliation.fetch("affiliationIdentifier", nil).present? + sum << ror_from_url(affiliation.fetch("affiliationIdentifier", nil)) if affiliation.is_a?(Hash) && affiliation.fetch("affiliationIdentifierScheme", nil) == "ROR" && affiliation.fetch("affiliationIdentifier", nil).present? end sum @@ -1521,7 +1521,7 @@ def affiliation_id def affiliation_id_and_name Array.wrap(creators).reduce([]) do |sum, creator| Array.wrap(creator.fetch("affiliation", nil)).each do |affiliation| - sum << "#{ror_from_url(affiliation.fetch("affiliationIdentifier", nil)).to_s}:#{affiliation.fetch("name", nil).to_s}" if affiliation.fetch("affiliationIdentifierScheme", nil) == "ROR" && affiliation.fetch("affiliationIdentifier", nil).present? + sum << "#{ror_from_url(affiliation.fetch("affiliationIdentifier", nil)).to_s}:#{affiliation.fetch("name", nil).to_s}" if affiliation.is_a?(Hash) && affiliation.fetch("affiliationIdentifierScheme", nil) == "ROR" && affiliation.fetch("affiliationIdentifier", nil).present? end sum diff --git a/spec/fixtures/files/rwth.xml b/spec/fixtures/files/rwth.xml new file mode 100644 index 000000000..4da7118ea --- /dev/null +++ b/spec/fixtures/files/rwth.xml @@ -0,0 +1,57 @@ + + + + 2017 + + + International journal of engine research, (2017). doi:10.1177/1468087417731043 + Published by Sage Publ., London + + 10.18154/RWTH-2017-08354 + en + 2017 + RWTH Aachen University + + 1468-0874 + 2041-3149 + 10.1177/1468087417731043 + + Journal article + + 620 + + + Autoregressive modeling of cycle-to-cycle correlations in homogeneous charge compression ignition combustion + + + + Andert, Jakob + 0000-0002-6754-1907 + RWTH Aachen + + + Wick, Maximilian + RWTH Aachen + + + Lehrheuer, Bastian + RWTH Aachen + + + Sohn, Christian + RWTH Aachen + + + Albin Rajasingham, Thivaharan + 0000-0002-6765-7010 + RWTH Aachen + + + Pischinger, Stefan + 0000-0002-0222-3457 + RWTH Aachen + + + \ No newline at end of file