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/lib/gitlab/discussions_diff/file_collection_spec.rb')
-rw-r--r--spec/lib/gitlab/discussions_diff/file_collection_spec.rb39
1 files changed, 28 insertions, 11 deletions
diff --git a/spec/lib/gitlab/discussions_diff/file_collection_spec.rb b/spec/lib/gitlab/discussions_diff/file_collection_spec.rb
index 0489206458b..6ef1e41450f 100644
--- a/spec/lib/gitlab/discussions_diff/file_collection_spec.rb
+++ b/spec/lib/gitlab/discussions_diff/file_collection_spec.rb
@@ -22,11 +22,13 @@ describe Gitlab::DiscussionsDiff::FileCollection do
note_diff_file_b.id => file_b_caching_content })
.and_call_original
- subject.load_highlight([note_diff_file_a.id, note_diff_file_b.id])
+ subject.load_highlight
end
it 'does not write cache for already cached file' do
- subject.load_highlight([note_diff_file_a.id])
+ file_a_caching_content = diff_note_a.diff_file.highlighted_diff_lines.map(&:to_hash)
+ Gitlab::DiscussionsDiff::HighlightCache
+ .write_multiple({ note_diff_file_a.id => file_a_caching_content })
file_b_caching_content = diff_note_b.diff_file.highlighted_diff_lines.map(&:to_hash)
@@ -35,27 +37,42 @@ describe Gitlab::DiscussionsDiff::FileCollection do
.with({ note_diff_file_b.id => file_b_caching_content })
.and_call_original
- subject.load_highlight([note_diff_file_a.id, note_diff_file_b.id])
+ subject.load_highlight
end
- it 'does not err when given ID does not exist in @collection' do
- expect { subject.load_highlight([999]) }.not_to raise_error
+ it 'does not write cache for resolved notes' do
+ diff_note_a.update_column(:resolved_at, Time.now)
+
+ file_b_caching_content = diff_note_b.diff_file.highlighted_diff_lines.map(&:to_hash)
+
+ expect(Gitlab::DiscussionsDiff::HighlightCache)
+ .to receive(:write_multiple)
+ .with({ note_diff_file_b.id => file_b_caching_content })
+ .and_call_original
+
+ subject.load_highlight
end
it 'loaded diff files have highlighted lines loaded' do
- subject.load_highlight([note_diff_file_a.id])
+ subject.load_highlight
- diff_file = subject.find_by_id(note_diff_file_a.id)
+ diff_file_a = subject.find_by_id(note_diff_file_a.id)
+ diff_file_b = subject.find_by_id(note_diff_file_b.id)
- expect(diff_file.highlight_loaded?).to be(true)
+ expect(diff_file_a).to be_highlight_loaded
+ expect(diff_file_b).to be_highlight_loaded
end
it 'not loaded diff files does not have highlighted lines loaded' do
- subject.load_highlight([note_diff_file_a.id])
+ diff_note_a.update_column(:resolved_at, Time.now)
+
+ subject.load_highlight
- diff_file = subject.find_by_id(note_diff_file_b.id)
+ diff_file_a = subject.find_by_id(note_diff_file_a.id)
+ diff_file_b = subject.find_by_id(note_diff_file_b.id)
- expect(diff_file.highlight_loaded?).to be(false)
+ expect(diff_file_a).not_to be_highlight_loaded
+ expect(diff_file_b).to be_highlight_loaded
end
end
end