From 9caed104bc903734d996161ba13a579f2be49d7c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 11 Dec 2019 03:07:31 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- lib/gitlab/json_cache.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/gitlab') 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) -- cgit v1.2.1