summaryrefslogtreecommitdiff
path: root/spec/models/note_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/models/note_spec.rb
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
downloadgitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r--spec/models/note_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 2afe9a0f29b..0afdae2fc93 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -1538,4 +1538,24 @@ RSpec.describe Note do
expect(attachment).not_to be_exist
end
end
+
+ describe '#post_processed_cache_key' do
+ let(:note) { build(:note) }
+
+ it 'returns cache key and author cache key by default' do
+ expect(note.post_processed_cache_key).to eq("#{note.cache_key}:#{note.author.cache_key}")
+ end
+
+ context 'when note has redacted_note_html' do
+ let(:redacted_note_html) { 'redacted note html' }
+
+ before do
+ note.redacted_note_html = redacted_note_html
+ end
+
+ it 'returns cache key with redacted_note_html sha' do
+ expect(note.post_processed_cache_key).to eq("#{note.cache_key}:#{note.author.cache_key}:#{Digest::SHA1.hexdigest(redacted_note_html)}")
+ end
+ end
+ end
end