summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/common_system_notes_examples.rb
blob: da5a4f3e31918bcb0a6049de6c5bbd7384a50b7c (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
26
27
shared_examples 'system note creation' do |update_params, note_text|
  subject { described_class.new(project, user).execute(issuable, old_labels: []) }

  before do
    issuable.assign_attributes(update_params)
    issuable.save
  end

  it 'creates 1 system note with the correct content' do
    expect { subject }.to change { Note.count }.from(0).to(1)

    note = Note.last
    expect(note.note).to match(note_text)
    expect(note.noteable_type).to eq(issuable.class.name)
  end
end

shared_examples 'WIP notes creation' do |wip_action|
  subject { described_class.new(project, user).execute(issuable, old_labels: []) }

  it 'creates WIP toggle and title change notes' do
    expect { subject }.to change { Note.count }.from(0).to(2)

    expect(Note.first.note).to match("#{wip_action} as a **Work In Progress**")
    expect(Note.second.note).to match('changed title')
  end
end