blob: cd5cefa0a9a5575374f5eabe1e109120375bdcea (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Setting assignees of an alert' do
include GraphqlHelpers
let_it_be(:project) { create(:project) }
let_it_be(:current_user) { create(:user) }
let_it_be(:alert) { create(:alert_management_alert, project: project) }
let(:input) { { assignee_usernames: [current_user.username] } }
let(:mutation) do
graphql_mutation(
:alert_set_assignees,
{ project_path: project.full_path, iid: alert.iid.to_s }.merge(input),
<<~QL
clientMutationId
errors
alert {
assignees {
nodes {
username
}
}
}
QL
)
end
let(:mutation_response) { graphql_mutation_response(:alert_set_assignees) }
before_all do
project.add_developer(current_user)
end
it 'updates the assignee of the alert' do
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
expect(mutation_response['alert']['assignees']['nodes'].first['username']).to eq(current_user.username)
expect(alert.reload.assignees).to contain_exactly(current_user)
end
context 'with operation_mode specified' do
let(:input) do
{
assignee_usernames: [current_user.username],
operation_mode: Types::MutationOperationModeEnum.enum[:remove]
}
end
before do
alert.assignees = [current_user]
end
it 'updates the assignee of the alert' do
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
expect(mutation_response['alert']['assignees']['nodes']).to be_empty
expect(alert.reload.assignees).to be_empty
end
end
end
|