blob: a285cebc8053a0c6c0fcbc460adcea80cce41008 (
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
66
67
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Creating a new HTTP Integration' do
include GraphqlHelpers
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project) }
let(:variables) do
{
project_path: project.full_path,
active: false,
name: 'New HTTP Integration'
}
end
let(:mutation) do
graphql_mutation(:http_integration_create, variables) do
<<~QL
clientMutationId
errors
integration {
id
type
name
active
token
url
apiUrl
}
QL
end
end
let(:mutation_response) { graphql_mutation_response(:http_integration_create) }
before do
project.add_maintainer(current_user)
end
it 'creates a new integration' do
post_graphql_mutation(mutation, current_user: current_user)
new_integration = ::AlertManagement::HttpIntegration.last!
integration_response = mutation_response['integration']
expect(response).to have_gitlab_http_status(:success)
expect(integration_response['id']).to eq(GitlabSchema.id_from_object(new_integration).to_s)
expect(integration_response['type']).to eq('HTTP')
expect(integration_response['name']).to eq(new_integration.name)
expect(integration_response['active']).to eq(new_integration.active)
expect(integration_response['token']).to eq(new_integration.token)
expect(integration_response['url']).to eq(new_integration.url)
expect(integration_response['apiUrl']).to eq(nil)
end
[:project_path, :active, :name].each do |argument|
context "without required argument #{argument}" do
before do
variables.delete(argument)
end
it_behaves_like 'an invalid argument to the mutation', argument_name: argument
end
end
end
|