blob: 748a3acf17bf4e565bc3587371dc731381936f2c (
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
|
# frozen_string_literal: true
RSpec.shared_examples IntegrationsActions do
let(:integration) do
create(:datadog_integration,
integration_attributes.merge(
api_url: 'http://example.com',
api_key: 'secret'
)
)
end
describe 'GET #edit' do
before do
get :edit, params: routing_params
end
it 'assigns the integration' do
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:integration)).to eq(integration)
end
end
describe 'PUT #update' do
let(:params) do
{
datadog_env: 'env',
datadog_service: 'service'
}
end
before do
put :update, params: routing_params.merge(integration: params)
end
it 'updates the integration with the provided params and redirects to the form' do
expect(response).to redirect_to(routing_params.merge(action: :edit))
expect(integration.reload).to have_attributes(params)
end
context 'when sending a password field' do
let(:params) { super().merge(api_key: 'new') }
it 'updates the integration with the password and other params' do
expect(response).to be_redirect
expect(integration.reload).to have_attributes(params)
end
end
context 'when sending a blank password field' do
let(:params) { super().merge(api_key: '') }
it 'ignores the password field and saves the other params' do
expect(response).to be_redirect
expect(integration.reload).to have_attributes(params.merge(api_key: 'secret'))
end
end
end
end
|