summaryrefslogtreecommitdiff
path: root/lib/gitlab
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-11 03:07:31 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-11 03:07:31 +0000
commit9caed104bc903734d996161ba13a579f2be49d7c (patch)
treed7c3e6a534dfa85128f1011c4fb16f7f697d3f80 /lib/gitlab
parenta59c9590f5171f3638a1b2abeff55157aedc577b (diff)
downloadgitlab-ce-9caed104bc903734d996161ba13a579f2be49d7c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/json_cache.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/gitlab/json_cache.rb b/lib/gitlab/json_cache.rb
index 9aa71db6b18..4314c131ada 100644
--- a/lib/gitlab/json_cache.rb
+++ b/lib/gitlab/json_cache.rb
@@ -80,15 +80,10 @@ module Gitlab
# when the new_record? method incorrectly returns false.
#
# See https://gitlab.com/gitlab-org/gitlab/issues/9903#note_145329964
- klass
- .allocate
- .init_with(
- "attributes" => attributes_for(klass, raw),
- "new_record" => new_record?(raw, klass)
- )
+ klass.allocate.init_with(encode_for(klass, raw))
end
- def attributes_for(klass, raw)
+ def encode_for(klass, raw)
# We have models that leave out some fields from the JSON export for
# security reasons, e.g. models that include the CacheMarkdownField.
# The ActiveRecord::AttributeSet we build from raw does know about
@@ -96,7 +91,10 @@ module Gitlab
missing_attributes = (klass.columns.map(&:name) - raw.keys)
missing_attributes.each { |column| raw[column] = nil }
- klass.attributes_builder.build_from_database(raw, {})
+ coder = {}
+ klass.new(raw).encode_with(coder)
+ coder["new_record"] = new_record?(raw, klass)
+ coder
end
def new_record?(raw, klass)