File: issuable_participants_shared_examples.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (53 lines) | stat: -rw-r--r-- 1,692 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# frozen_string_literal: true

RSpec.shared_examples 'issuable participants' do
  context 'when resource parent is public' do
    context 'and users are referenced on notes' do
      let_it_be(:notes_author) { create(:user) }

      let(:note_params) { params.merge(author: notes_author) }

      before do
        create(:note, note_params)
      end

      it 'includes the issue author' do
        expect(issuable.participants).to include(issuable.author)
      end

      it 'includes the authors of the notes' do
        expect(issuable.participants).to include(notes_author)
      end

      context 'and note is confidential' do
        context 'and mentions users' do
          let_it_be(:guest_1) { create(:user) }
          let_it_be(:guest_2) { create(:user) }
          let_it_be(:reporter) { create(:user) }

          before do
            issuable_parent.add_guest(guest_1)
            issuable_parent.add_guest(guest_2)
            issuable_parent.add_reporter(reporter)

            confidential_note_params =
              note_params.merge(
                confidential: true,
                note: "mentions #{guest_1.to_reference} and #{guest_2.to_reference} and #{reporter.to_reference}"
              )

            regular_note_params =
              note_params.merge(note: "Mentions #{guest_2.to_reference}")

            create(:note, confidential_note_params)
            create(:note, regular_note_params)
          end

          it 'only includes users that can read the note as participants' do
            expect(issuable.participants).to contain_exactly(issuable.author, notes_author, reporter, guest_2)
          end
        end
      end
    end
  end
end