Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
75087619
Commit
75087619
authored
Jan 22, 2020
by
Peter Leitzen
Committed by
Jan Provaznik
Jan 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cop HaveGitlabHttpStatus in EE shared examples
55 files inspected, 41 offenses detected, 41 offenses corrected
parent
ad66b824
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
42 additions
and
41 deletions
+42
-41
.rubocop.yml
.rubocop.yml
+1
-0
ee/spec/support/shared_examples/controllers/concerns/project_vulnerability_findings_actions_shared_examples.rb
...project_vulnerability_findings_actions_shared_examples.rb
+2
-2
ee/spec/support/shared_examples/controllers/concerns/security_dashboards_permissions_shared_examples.rb
...ncerns/security_dashboards_permissions_shared_examples.rb
+3
-3
ee/spec/support/shared_examples/controllers/multiple_issue_board_show_shared_examples.rb
.../controllers/multiple_issue_board_show_shared_examples.rb
+5
-5
ee/spec/support/shared_examples/controllers/recent_boards_shared_examples.rb
...red_examples/controllers/recent_boards_shared_examples.rb
+2
-2
ee/spec/support/shared_examples/features/insights_shared_examples.rb
...port/shared_examples/features/insights_shared_examples.rb
+3
-3
ee/spec/support/shared_examples/requests/api/assignee_board_list_shared_examples.rb
...mples/requests/api/assignee_board_list_shared_examples.rb
+3
-3
ee/spec/support/shared_examples/requests/api/milestone_board_list_shared_examples.rb
...ples/requests/api/milestone_board_list_shared_examples.rb
+3
-3
ee/spec/support/shared_examples/requests/api/milestone_burndown_shared_examples.rb
...amples/requests/api/milestone_burndown_shared_examples.rb
+2
-2
ee/spec/support/shared_examples/requests/api/multiple_and_scoped_issue_boards_shared_examples.rb
...s/api/multiple_and_scoped_issue_boards_shared_examples.rb
+5
-5
ee/spec/support/shared_examples/requests/api/project_approval_rules_api_shared_examples.rb
...equests/api/project_approval_rules_api_shared_examples.rb
+10
-10
ee/spec/support/shared_examples/requests/api/vulnerabilities_shared_examples.rb
..._examples/requests/api/vulnerabilities_shared_examples.rb
+3
-3
No files found.
.rubocop.yml
View file @
75087619
...
...
@@ -347,6 +347,7 @@ RSpec/HaveGitlabHttpStatus:
Enabled
:
true
Include
:
-
'
spec/support/shared_examples/**/*'
-
'
ee/spec/support/shared_examples/**/*'
Style/MultilineWhenThen
:
Enabled
:
false
...
...
ee/spec/support/shared_examples/controllers/concerns/project_vulnerability_findings_actions_shared_examples.rb
View file @
75087619
...
...
@@ -30,7 +30,7 @@ RSpec.shared_examples ProjectVulnerabilityFindingsActions do
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
length
).
to
eq
2
expect
(
json_response
.
first
[
'id'
]).
to
be
(
critical_vulnerability
.
id
)
expect
(
response
).
to
match_response_schema
(
'vulnerabilities/occurrence_list'
,
dir:
'ee'
)
...
...
@@ -130,7 +130,7 @@ RSpec.shared_examples ProjectVulnerabilityFindingsActions do
end
it
'returns vulnerability findings counts for all report types'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'high'
]).
to
eq
(
3
)
expect
(
json_response
[
'low'
]).
to
eq
(
2
)
expect
(
json_response
[
'medium'
]).
to
eq
(
2
)
...
...
ee/spec/support/shared_examples/controllers/concerns/security_dashboards_permissions_shared_examples.rb
View file @
75087619
...
...
@@ -16,7 +16,7 @@ RSpec.shared_examples SecurityDashboardsPermissions do
security_dashboard_action
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
...
...
@@ -31,7 +31,7 @@ RSpec.shared_examples SecurityDashboardsPermissions do
security_dashboard_action
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
...
...
@@ -41,7 +41,7 @@ RSpec.shared_examples SecurityDashboardsPermissions do
security_dashboard_action
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
...
...
ee/spec/support/shared_examples/controllers/multiple_issue_board_show_shared_examples.rb
View file @
75087619
...
...
@@ -8,14 +8,14 @@ RSpec.shared_examples 'multiple issue boards show' do
it
'lets user view board1'
do
show
(
board1
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
assigns
(
:board
)).
to
eq
(
board1
)
end
it
'lets user view board2'
do
show
(
board2
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
assigns
(
:board
)).
to
eq
(
board2
)
end
end
...
...
@@ -28,7 +28,7 @@ RSpec.shared_examples 'multiple issue boards show' do
it
'let user view the default shown board'
do
show
(
board2
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
assigns
(
:board
)).
to
eq
(
board2
)
end
...
...
@@ -36,9 +36,9 @@ RSpec.shared_examples 'multiple issue boards show' do
show
(
board1
)
if
parent
.
is_a?
(
Project
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
else
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
...
...
ee/spec/support/shared_examples/controllers/recent_boards_shared_examples.rb
View file @
75087619
...
...
@@ -35,10 +35,10 @@ RSpec.shared_examples 'redirects to last visited board' do
if
parent
.
is_a?
(
Group
)
expect
(
response
).
to
render_template
:index
expect
(
response
.
content_type
).
to
eq
'text/html'
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
else
expect
(
response
.
content_type
).
to
eq
'text/html'
expect
(
response
).
to
have_gitlab_http_status
(
302
)
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
end
end
end
...
...
ee/spec/support/shared_examples/features/insights_shared_examples.rb
View file @
75087619
...
...
@@ -20,7 +20,7 @@ RSpec.shared_examples 'Insights page' do
it
'has correct title'
do
visit
route
expect
(
page
).
to
have_gitlab_http_status
(
200
)
expect
(
page
).
to
have_gitlab_http_status
(
:ok
)
expect
(
page
).
to
have_content
(
'Insights'
)
end
...
...
@@ -52,7 +52,7 @@ RSpec.shared_examples 'Insights page' do
it
'returns 404'
do
visit
route
expect
(
page
).
to
have_gitlab_http_status
(
404
)
expect
(
page
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
...
...
@@ -66,7 +66,7 @@ RSpec.shared_examples 'Insights page' do
it
'returns 404'
do
visit
route
expect
(
page
).
to
have_gitlab_http_status
(
404
)
expect
(
page
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
...
...
ee/spec/support/shared_examples/requests/api/assignee_board_list_shared_examples.rb
View file @
75087619
...
...
@@ -6,7 +6,7 @@ RSpec.shared_examples 'assignee board list' do
other_user
=
create
(
:user
)
post
api
(
url
,
user
),
params:
{
assignee_id:
other_user
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
.
dig
(
'message'
,
'error'
)).
to
eq
(
'User not found!'
)
end
...
...
@@ -15,7 +15,7 @@ RSpec.shared_examples 'assignee board list' do
post
api
(
url
,
user
),
params:
{
assignee_id:
user
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
.
dig
(
'message'
,
'list_type'
))
.
to
contain_exactly
(
'Assignee lists not available with your current license'
)
end
...
...
@@ -25,7 +25,7 @@ RSpec.shared_examples 'assignee board list' do
post
api
(
url
,
user
),
params:
{
assignee_id:
user
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
.
dig
(
'assignee'
,
'id'
)).
to
eq
(
user
.
id
)
end
end
...
...
ee/spec/support/shared_examples/requests/api/milestone_board_list_shared_examples.rb
View file @
75087619
...
...
@@ -6,7 +6,7 @@ RSpec.shared_examples 'milestone board list' do
other_milestone
=
create
(
:milestone
)
post
api
(
url
,
user
),
params:
{
milestone_id:
other_milestone
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
.
dig
(
'message'
,
'error'
)).
to
eq
(
'Milestone not found!'
)
end
...
...
@@ -15,7 +15,7 @@ RSpec.shared_examples 'milestone board list' do
post
api
(
url
,
user
),
params:
{
milestone_id:
milestone
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
.
dig
(
'message'
,
'list_type'
))
.
to
contain_exactly
(
'Milestone lists not available with your current license'
)
end
...
...
@@ -25,7 +25,7 @@ RSpec.shared_examples 'milestone board list' do
post
api
(
url
,
user
),
params:
{
milestone_id:
milestone
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
json_response
.
dig
(
'milestone'
,
'id'
)).
to
eq
(
milestone
.
id
)
end
end
...
...
ee/spec/support/shared_examples/requests/api/milestone_burndown_shared_examples.rb
View file @
75087619
...
...
@@ -7,7 +7,7 @@ RSpec.shared_examples 'group and project milestone burndowns' do |route_definiti
it
'returns burndown events list'
do
get
api
(
resource_route
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'created_at'
].
to_time
).
to
eq
(
Date
.
today
.
middle_of_day
)
expect
(
json_response
.
first
[
'weight'
]).
to
eq
(
5
)
...
...
@@ -22,7 +22,7 @@ RSpec.shared_examples 'group and project milestone burndowns' do |route_definiti
get
api
(
resource_route
,
outside_user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
ee/spec/support/shared_examples/requests/api/multiple_and_scoped_issue_boards_shared_examples.rb
View file @
75087619
...
...
@@ -13,7 +13,7 @@ RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
it
'creates a board'
do
post
api
(
root_url
,
user
),
params:
{
name:
"new board"
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/board'
,
dir:
"ee"
)
end
...
...
@@ -25,7 +25,7 @@ RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
it
'updates a board'
do
put
api
(
url
,
user
),
params:
{
name:
'new name'
,
weight:
4
,
labels:
'foo, bar'
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/board'
,
dir:
"ee"
)
...
...
@@ -43,14 +43,14 @@ RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
.
and
not_change
{
board
.
reload
.
weight
}
.
and
not_change
{
board
.
reload
.
labels
.
map
(
&
:title
).
sort
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/board'
,
dir:
"ee"
)
end
it
'allows removing optional attributes'
do
put
api
(
url
,
user
),
params:
{
name:
'new name'
,
assignee_id:
nil
,
milestone_id:
nil
,
weight:
nil
,
labels:
nil
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/board'
,
dir:
"ee"
)
board
.
reload
...
...
@@ -69,7 +69,7 @@ RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
it
'deletes a board'
do
delete
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
end
...
...
ee/spec/support/shared_examples/requests/api/project_approval_rules_api_shared_examples.rb
View file @
75087619
...
...
@@ -13,7 +13,7 @@ RSpec.shared_examples 'an API endpoint for creating project approval rule' do
it
'returns 400 status'
do
post
api
(
url
,
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
...
...
@@ -21,7 +21,7 @@ RSpec.shared_examples 'an API endpoint for creating project approval rule' do
it
'returns 403'
do
post
api
(
url
,
user2
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
...
...
@@ -29,7 +29,7 @@ RSpec.shared_examples 'an API endpoint for creating project approval rule' do
it
'returns 201 status'
do
post
api
(
url
,
current_user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
schema
,
dir:
'ee'
)
end
...
...
@@ -68,7 +68,7 @@ RSpec.shared_examples 'an API endpoint for creating project approval rule' do
post
api
(
url
,
current_user
),
params:
params
.
merge
(
name:
rule_name
)
end
.
to
change
{
ApprovalProjectRule
.
report_approver
.
count
}.
from
(
0
).
to
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
end
end
end
...
...
@@ -109,7 +109,7 @@ RSpec.shared_examples 'an API endpoint for updating project approval rule' do
put
api
(
url
,
current_user
),
params:
{
users:
[],
groups:
[]
}.
to_json
,
headers:
{
CONTENT_TYPE
:
'application/json'
}
end
.
to
change
{
approval_rule
.
users
.
count
+
approval_rule
.
groups
.
count
}.
from
(
2
).
to
(
0
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
schema
,
dir:
'ee'
)
end
end
...
...
@@ -123,7 +123,7 @@ RSpec.shared_examples 'an API endpoint for updating project approval rule' do
expect
(
approval_rule
.
users
).
to
contain_exactly
(
approver
)
expect
(
approval_rule
.
groups
).
to
be_empty
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
...
...
@@ -149,7 +149,7 @@ RSpec.shared_examples 'an API endpoint for updating project approval rule' do
put
api
(
url
,
user2
),
params:
{
users:
[],
groups:
[]
}.
to_json
,
headers:
{
CONTENT_TYPE
:
'application/json'
}
end
.
not_to
change
{
approval_rule
.
approvers
.
size
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
...
...
@@ -159,7 +159,7 @@ RSpec.shared_examples 'an API endpoint for deleting project approval rule' do
delete
api
(
url
,
user
)
expect
(
ApprovalProjectRule
.
exists?
(
id:
approval_rule
.
id
)).
to
eq
(
false
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
context
'when approval rule not found'
do
...
...
@@ -169,7 +169,7 @@ RSpec.shared_examples 'an API endpoint for deleting project approval rule' do
it
'returns not found'
do
delete
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
...
...
@@ -177,7 +177,7 @@ RSpec.shared_examples 'an API endpoint for deleting project approval rule' do
it
'returns forbidden'
do
delete
api
(
url
,
user2
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
ee/spec/support/shared_examples/requests/api/vulnerabilities_shared_examples.rb
View file @
75087619
...
...
@@ -9,7 +9,7 @@ RSpec.shared_examples 'forbids access to vulnerability API endpoint in case of d
it
'responds with "not found"'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
...
...
@@ -21,7 +21,7 @@ RSpec.shared_examples 'forbids access to vulnerability API endpoint in case of d
it
'responds with 403 Forbidden'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
...
...
@@ -32,6 +32,6 @@ RSpec.shared_examples 'responds with "not found" for an unknown vulnerability ID
it
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment