diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-16 18:06:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-16 18:06:26 +0300 |
commit | 84727c8209a4412e21111a07f99b0438b03232de (patch) | |
tree | 1fcfa02b01548c3cdc561186870a1c807f227f0b /spec/lib/gitlab/discussions_diff | |
parent | d2798d607e11e0ebae83ae909404834388733428 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/discussions_diff')
-rw-r--r-- | spec/lib/gitlab/discussions_diff/file_collection_spec.rb | 39 |
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 |