Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/diff_discussion_spec.rb')
-rw-r--r--spec/models/diff_discussion_spec.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/models/diff_discussion_spec.rb b/spec/models/diff_discussion_spec.rb
index 998204626d3..7a57f895b8a 100644
--- a/spec/models/diff_discussion_spec.rb
+++ b/spec/models/diff_discussion_spec.rb
@@ -128,11 +128,20 @@ RSpec.describe DiffDiscussion do
end
describe '#cache_key' do
+ let(:notes_sha) { Digest::SHA1.hexdigest("#{diff_note.post_processed_cache_key}") }
+ let(:position_sha) { Digest::SHA1.hexdigest(diff_note.position.to_json) }
+
it 'returns the cache key with the position sha' do
- notes_sha = Digest::SHA1.hexdigest("#{diff_note.id}")
- position_sha = Digest::SHA1.hexdigest(diff_note.position.to_json)
+ expect(subject.cache_key).to eq("#{described_class::CACHE_VERSION}:#{subject.id}:#{notes_sha}::#{position_sha}:")
+ end
- expect(subject.cache_key).to eq("#{described_class::CACHE_VERSION}:#{diff_note.latest_cached_markdown_version}:#{subject.id}:#{notes_sha}:#{diff_note.updated_at}::#{position_sha}")
+ context 'when first note of discussion has diff_note_position' do
+ let!(:diff_note_position) { create(:diff_note_position, note: diff_note) }
+ let(:positions_sha) { Digest::SHA1.hexdigest(diff_note_position.position.to_json) }
+
+ it 'includes sha of diff_note_positions position' do
+ expect(subject.cache_key).to eq("#{described_class::CACHE_VERSION}:#{subject.id}:#{notes_sha}::#{position_sha}:#{positions_sha}")
+ end
end
end
end