diff options
| author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-07-04 11:34:35 +0200 |
|---|---|---|
| committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-07-04 11:34:35 +0200 |
| commit | dc551581d0e0e520a38375a564817e6668b761c3 (patch) | |
| tree | afa75e0232b3478cdf8bbf69b21bbc5153b107b8 /lib | |
| parent | 4c1a2a9b9977f68a05512ed1ff378ee0a2368aca (diff) | |
| download | gitlab-ce-dc551581d0e0e520a38375a564817e6668b761c3.tar.gz | |
Use serialize_keys as part of highlight diff cache
This assures that old cache is not used if we change format of
cached data.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/diff/file_collection/merge_request_diff.rb | 2 | ||||
| -rw-r--r-- | lib/gitlab/diff/line.rb | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/gitlab/diff/file_collection/merge_request_diff.rb b/lib/gitlab/diff/file_collection/merge_request_diff.rb index c358ae428cf..be25e1bab21 100644 --- a/lib/gitlab/diff/file_collection/merge_request_diff.rb +++ b/lib/gitlab/diff/file_collection/merge_request_diff.rb @@ -34,7 +34,7 @@ module Gitlab end def cache_key - [@merge_request_diff, 'highlighted-diff-files', diff_options] + [@merge_request_diff, 'highlighted-diff-files', Gitlab::Diff::Line::SERIALIZE_KEYS, diff_options] end private diff --git a/lib/gitlab/diff/line.rb b/lib/gitlab/diff/line.rb index 2b3ebfbb9ff..1faf7770634 100644 --- a/lib/gitlab/diff/line.rb +++ b/lib/gitlab/diff/line.rb @@ -1,6 +1,8 @@ module Gitlab module Diff class Line + SERIALIZE_KEYS = %i(line_code text type index old_pos new_pos).freeze + attr_reader :line_code, :type, :index, :old_pos, :new_pos attr_writer :rich_text attr_accessor :text @@ -19,13 +21,9 @@ module Gitlab new(hash[:text], hash[:type], hash[:index], hash[:old_pos], hash[:new_pos], line_code: hash[:line_code]) end - def serialize_keys - @serialize_keys ||= %i(line_code text type index old_pos new_pos) - end - def to_hash hash = {} - serialize_keys.each { |key| hash[key] = send(key) } # rubocop:disable GitlabSecurity/PublicSend + SERIALIZE_KEYS.each { |key| hash[key] = send(key) } # rubocop:disable GitlabSecurity/PublicSend hash end |
