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
91fa166b
Commit
91fa166b
authored
May 13, 2020
by
Maxime Orefice
Committed by
Rémy Coutable
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add accessibility_reports endpoint to MergeRequest
parent
3d1694ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
151 additions
and
1 deletion
+151
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+15
-1
config/routes/merge_requests.rb
config/routes/merge_requests.rb
+1
-0
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+135
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
91fa166b
...
...
@@ -14,7 +14,13 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
skip_before_action
:merge_request
,
only:
[
:index
,
:bulk_update
]
before_action
:whitelist_query_limiting
,
only:
[
:assign_related_issues
,
:update
]
before_action
:authorize_update_issuable!
,
only:
[
:close
,
:edit
,
:update
,
:remove_wip
,
:sort
]
before_action
:authorize_read_actual_head_pipeline!
,
only:
[
:test_reports
,
:exposed_artifacts
,
:coverage_reports
,
:terraform_reports
]
before_action
:authorize_read_actual_head_pipeline!
,
only:
[
:test_reports
,
:exposed_artifacts
,
:coverage_reports
,
:terraform_reports
,
:accessibility_reports
]
before_action
:set_issuables_index
,
only:
[
:index
]
before_action
:authenticate_user!
,
only:
[
:assign_related_issues
]
before_action
:check_user_can_push_to_source_branch!
,
only:
[
:rebase
]
...
...
@@ -136,6 +142,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
reports_response
(
@merge_request
.
compare_test_reports
)
end
def
accessibility_reports
if
@merge_request
.
has_accessibility_reports?
reports_response
(
@merge_request
.
compare_accessibility_reports
)
else
head
:no_content
end
end
def
coverage_reports
if
@merge_request
.
has_coverage_reports?
reports_response
(
@merge_request
.
find_coverage_reports
)
...
...
config/routes/merge_requests.rb
View file @
91fa166b
...
...
@@ -14,6 +14,7 @@ resources :merge_requests, concerns: :awardable, except: [:new, :create, :show],
post
:rebase
get
:test_reports
get
:exposed_artifacts
get
:accessibility_reports
get
:coverage_reports
get
:terraform_reports
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
91fa166b
...
...
@@ -1341,6 +1341,141 @@ describe Projects::MergeRequestsController do
end
end
describe
'GET accessibility_reports'
do
let
(
:merge_request
)
do
create
(
:merge_request
,
:with_diffs
,
:with_merge_request_pipeline
,
target_project:
project
,
source_project:
project
)
end
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
:success
,
project:
merge_request
.
source_project
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
end
before
do
allow_any_instance_of
(
MergeRequest
)
.
to
receive
(
:compare_accessibility_reports
)
.
and_return
(
accessibility_comparison
)
allow_any_instance_of
(
MergeRequest
)
.
to
receive
(
:actual_head_pipeline
)
.
and_return
(
pipeline
)
end
subject
do
get
:accessibility_reports
,
params:
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
merge_request
.
iid
},
format: :json
end
context
'permissions on a public project with private CI/CD'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
:builds_private
)
}
let
(
:accessibility_comparison
)
{
{
status: :parsed
,
data:
{
summary:
1
}
}
}
context
'while signed out'
do
before
do
sign_out
(
user
)
end
it
'responds with a 404'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
.
body
).
to
be_blank
end
end
context
'while signed in as an unrelated user'
do
before
do
sign_in
(
create
(
:user
))
end
it
'responds with a 404'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
.
body
).
to
be_blank
end
end
end
context
'when feature flag is disabled'
do
let
(
:accessibility_comparison
)
{
{
status: :parsed
,
data:
{
summary:
1
}
}
}
before
do
stub_feature_flags
(
accessibility_report_view:
false
)
end
it
'returns 204 HTTP status'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
context
'when pipeline has jobs with accessibility reports'
do
before
do
allow_any_instance_of
(
MergeRequest
)
.
to
receive
(
:has_accessibility_reports?
)
.
and_return
(
true
)
end
context
'when processing accessibility reports is in progress'
do
let
(
:accessibility_comparison
)
{
{
status: :parsing
}
}
it
'sends polling interval'
do
expect
(
Gitlab
::
PollingInterval
).
to
receive
(
:set_header
)
subject
end
it
'returns 204 HTTP status'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
context
'when processing accessibility reports is completed'
do
let
(
:accessibility_comparison
)
{
{
status: :parsed
,
data:
{
summary:
1
}
}
}
it
'returns accessibility reports'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
eq
({
'summary'
=>
1
})
end
end
context
'when user created corrupted accessibility reports'
do
let
(
:accessibility_comparison
)
{
{
status: :error
,
status_reason:
'This merge request does not have accessibility reports'
}
}
it
'does not send polling interval'
do
expect
(
Gitlab
::
PollingInterval
).
not_to
receive
(
:set_header
)
subject
end
it
'returns 400 HTTP status'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
eq
({
'status_reason'
=>
'This merge request does not have accessibility reports'
})
end
end
end
end
describe
'POST remove_wip'
do
before
do
merge_request
.
title
=
merge_request
.
wip_title
...
...
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