summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/services/resource_events/synthetic_notes_builder_shared_examples.rb
blob: 1383346644a16374b66979bfedeff2372fce4c19 (plain)
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
# frozen_string_literal: true

RSpec.shared_examples 'filters by paginated notes' do |event_type|
  let(:event) { create(event_type, issue: create(:issue)) }

  before do
    create(event_type, issue: event.issue)
  end

  it 'only returns given notes' do
    paginated_notes = { event_type.to_s.pluralize => [double(ids: [event.id])] }
    notes = described_class.new(event.issue, user, paginated_notes: paginated_notes).execute

    expect(notes.size).to eq(1)
    expect(notes.first.event).to eq(event)
  end

  context 'when paginated notes is empty' do
    it 'does not return any notes' do
      notes = described_class.new(event.issue, user, paginated_notes: {}).execute

      expect(notes.size).to eq(0)
    end
  end
end