summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-06-14 12:54:59 -0500
committerDouwe Maan <douwe@selenight.nl>2017-06-14 13:01:15 -0500
commit338d9b257ecfa6f088daaeb9d93ea8991f8965d0 (patch)
tree5d46c40b24dbb0626d5b672de34d555dec073b71
parent5771b946c2e68fd4b9a8ff040c168b568b68a586 (diff)
downloadgitlab-ce-338d9b257ecfa6f088daaeb9d93ea8991f8965d0.tar.gz
Don't return nil for missing objects from parser cachedm-fix-parser-cache
-rw-r--r--changelogs/unreleased/dm-fix-parser-cache.yml4
-rw-r--r--lib/banzai/reference_parser/base_parser.rb2
-rw-r--r--spec/lib/banzai/reference_parser/base_parser_spec.rb2
3 files changed, 6 insertions, 2 deletions
diff --git a/changelogs/unreleased/dm-fix-parser-cache.yml b/changelogs/unreleased/dm-fix-parser-cache.yml
new file mode 100644
index 00000000000..31c163b7272
--- /dev/null
+++ b/changelogs/unreleased/dm-fix-parser-cache.yml
@@ -0,0 +1,4 @@
+---
+title: Don't return nil for missing objects from parser cache
+merge_request:
+author:
diff --git a/lib/banzai/reference_parser/base_parser.rb b/lib/banzai/reference_parser/base_parser.rb
index 1e2536231d8..279fca8d043 100644
--- a/lib/banzai/reference_parser/base_parser.rb
+++ b/lib/banzai/reference_parser/base_parser.rb
@@ -171,7 +171,7 @@ module Banzai
collection.where(id: to_query).each { |row| cache[row.id] = row }
end
- cache.values_at(*ids)
+ cache.values_at(*ids).compact
else
collection.where(id: ids)
end
diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb
index f4f42bfc3ed..76fab93821a 100644
--- a/spec/lib/banzai/reference_parser/base_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb
@@ -114,7 +114,7 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do
expect(hash).to eq({ link => user })
end
- it 'returns an empty Hash when entry does not exist in the database' do
+ it 'returns an empty Hash when entry does not exist in the database', :request_store do
link = double(:link)
expect(link).to receive(:has_attribute?).