blob: cc170c6544d6c1eb2e9e7b481a4b8b9bd35c3386 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
RSpec.shared_examples 'a destroyable issuable link' do
context 'when successfully removes an issuable link' do
before do
issuable_link.source.resource_parent.add_reporter(user)
issuable_link.target.resource_parent.add_reporter(user)
end
it 'removes related issue' do
expect { subject }.to change { issuable_link.class.count }.by(-1)
end
it 'creates notes' do
# Two-way notes creation
expect(SystemNoteService).to receive(:unrelate_issuable)
.with(issuable_link.source, issuable_link.target, user)
expect(SystemNoteService).to receive(:unrelate_issuable)
.with(issuable_link.target, issuable_link.source, user)
subject
end
it 'returns success message' do
is_expected.to eq(message: 'Relation was removed', status: :success)
end
end
context 'when failing to remove an issuable link' do
it 'does not remove relation' do
expect { subject }.not_to change { issuable_link.class.count }.from(1)
end
it 'does not create notes' do
expect(SystemNoteService).not_to receive(:unrelate_issuable)
end
it 'returns error message' do
is_expected.to eq(message: "No #{issuable_link.class.model_name.human.titleize} found", status: :error, http_status: 404)
end
end
end
|