blob: 35bd7d47aed524a1944934a49e837d243efb023c (
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
68
69
70
71
72
73
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Groups::DependencyProxiesController do
let(:group) { create(:group) }
let(:user) { create(:user) }
before do
group.add_owner(user)
sign_in(user)
end
describe 'GET #show' do
context 'feature enabled' do
before do
enable_dependency_proxy
end
it 'returns 200 and renders the view' do
get :show, params: { group_id: group.to_param }
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('groups/dependency_proxies/show')
end
end
it 'returns 404 when feature is disabled' do
disable_dependency_proxy
get :show, params: { group_id: group.to_param }
expect(response).to have_gitlab_http_status(:not_found)
end
end
describe 'PUT #update' do
context 'feature enabled' do
before do
enable_dependency_proxy
end
it 'redirects back to show page' do
put :update, params: update_params
expect(response).to have_gitlab_http_status(:found)
end
end
it 'returns 404 when feature is disabled' do
put :update, params: update_params
expect(response).to have_gitlab_http_status(:not_found)
end
def update_params
{
group_id: group.to_param,
dependency_proxy_group_setting: { enabled: true }
}
end
end
def enable_dependency_proxy
stub_config(dependency_proxy: { enabled: true })
group.create_dependency_proxy_setting!(enabled: true)
end
def disable_dependency_proxy
group.create_dependency_proxy_setting!(enabled: false)
end
end
|