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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::FeatureFlagsUserListsController do
let_it_be(:project) { create(:project) }
let_it_be(:reporter) { create(:user) }
let_it_be(:developer) { create(:user) }
before_all do
project.add_reporter(reporter)
project.add_developer(developer)
end
def request_params(extra_params = {})
{ namespace_id: project.namespace, project_id: project }.merge(extra_params)
end
describe 'GET #new' do
it 'redirects when the user is unauthenticated' do
get(:new, params: request_params)
expect(response).to redirect_to(new_user_session_path)
end
it 'returns not found if the user does not belong to the project' do
user = create(:user)
sign_in(user)
get(:new, params: request_params)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns not found for a reporter' do
sign_in(reporter)
get(:new, params: request_params)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'renders the new page for a developer' do
sign_in(developer)
get(:new, params: request_params)
expect(response).to have_gitlab_http_status(:ok)
end
end
describe 'GET #edit' do
before do
sign_in(developer)
end
it 'renders the edit page for a developer' do
list = create(:operations_feature_flag_user_list, project: project)
get(:edit, params: request_params(iid: list.iid))
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns not found with an iid that does not exist' do
list = create(:operations_feature_flag_user_list, project: project)
get(:edit, params: request_params(iid: list.iid + 1))
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns not found for a list belonging to a another project' do
other_project = create(:project)
list = create(:operations_feature_flag_user_list, project: other_project)
get(:edit, params: request_params(iid: list.iid))
expect(response).to have_gitlab_http_status(:not_found)
end
end
describe 'GET #show' do
before do
sign_in(developer)
end
it 'renders the page for a developer' do
list = create(:operations_feature_flag_user_list, project: project)
get(:show, params: request_params(iid: list.iid))
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns not found with an iid that does not exist' do
list = create(:operations_feature_flag_user_list, project: project)
get(:show, params: request_params(iid: list.iid + 1))
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns not found for a list belonging to a another project' do
other_project = create(:project)
list = create(:operations_feature_flag_user_list, project: other_project)
get(:show, params: request_params(iid: list.iid))
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
|