Skip to content

Commit

Permalink
Merge pull request #995 from scientist-softserv/i436-fix-when-result-…
Browse files Browse the repository at this point in the history
…is-not-a-string

🐛 Account for when result is not a string
  • Loading branch information
kirkkwang authored Mar 12, 2024
2 parents 2514bd6 + e85c18a commit 48b6ee8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/concerns/bulkrax/has_matchers_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Bulkrax
module HasMatchersDecorator
def matched_metadata(multiple, name, result, object_multiple)
if name == 'based_near'
return result if result.blank?

result = if result.start_with?('http')
Hyrax::ControlledVocabularies::Location.new(RDF::URI.new(result))
else
Expand Down
12 changes: 12 additions & 0 deletions spec/models/concerns/bulkrax/has_matchers_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,17 @@
expect(subject.first.full_label).to eq 'Faketown, Kali4nia, United Steaks'
end
end

results = [[], nil, '', ' ']
results.each do |result|
context "when given a blank value (#{result.inspect})" do
let(:result) { result }

it 'returns the original value' do
expect(entry).not_to receive(:geonames_lookup)
expect(subject).to eq result
end
end
end
end
end

0 comments on commit 48b6ee8

Please sign in to comment.