diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/models/note_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r-- | spec/models/note_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 328d3ba7dda..4b574540500 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -1622,6 +1622,50 @@ RSpec.describe Note do expect(described_class.with_suggestions).not_to include(note_without_suggestion) end end + + describe '.inc_relations_for_view' do + subject { note.noteable.notes.inc_relations_for_view(noteable) } + + context 'when noteable can not have diffs' do + let_it_be(:note) { create(:note_on_issue) } + let(:noteable) { note.noteable } + + it 'does not include additional associations' do + expect { subject.reload }.to match_query_count(0).for_model(NoteDiffFile).and( + match_query_count(0).for_model(DiffNotePosition)) + end + + context 'when noteable is not set' do + let(:noteable) { nil } + + it 'includes additional diff associations' do + expect { subject.reload }.to match_query_count(1).for_model(NoteDiffFile).and( + match_query_count(1).for_model(DiffNotePosition)) + end + end + + context 'when skip_notes_diff_include flag is disabled' do + before do + stub_feature_flags(skip_notes_diff_include: false) + end + + it 'includes additional diff associations' do + expect { subject.reload }.to match_query_count(1).for_model(NoteDiffFile).and( + match_query_count(1).for_model(DiffNotePosition)) + end + end + end + + context 'when noteable can have diffs' do + let_it_be(:note) { create(:note_on_commit) } + let(:noteable) { note.noteable } + + it 'includes additional diff associations' do + expect { subject.reload }.to match_query_count(1).for_model(NoteDiffFile).and( + match_query_count(1).for_model(DiffNotePosition)) + end + end + end end describe 'banzai_render_context' do |