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
1f7344e1
Commit
1f7344e1
authored
Jul 22, 2019
by
Can Eldem
Committed by
Fatih Acet
Jul 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Move License Management reports logic for the Merge Request widget to the backend"
parent
f1f83f32
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
0 deletions
+96
-0
ee/app/controllers/ee/projects/merge_requests_controller.rb
ee/app/controllers/ee/projects/merge_requests_controller.rb
+4
-0
ee/app/views/projects/merge_requests/show.html.haml
ee/app/views/projects/merge_requests/show.html.haml
+1
-0
ee/changelogs/unreleased/12020-move-lm-reports-comparision-to-backend.yml
...released/12020-move-lm-reports-comparision-to-backend.yml
+5
-0
ee/config/routes/project.rb
ee/config/routes/project.rb
+1
-0
ee/spec/controllers/projects/merge_requests_controller_spec.rb
...ec/controllers/projects/merge_requests_controller_spec.rb
+85
-0
No files found.
ee/app/controllers/ee/projects/merge_requests_controller.rb
View file @
1f7344e1
...
...
@@ -42,6 +42,10 @@ module EE
render_approvals_json
end
def
license_management_reports
reports_response
(
merge_request
.
compare_license_management_reports
)
end
def
metrics_reports
reports_response
(
merge_request
.
compare_metrics_reports
)
end
...
...
ee/app/views/projects/merge_requests/show.html.haml
View file @
1f7344e1
...
...
@@ -16,3 +16,4 @@
window
.
gl
.
mrWidgetData
.
vulnerability_feedback_help_path
=
'
#{
help_page_path
(
"user/application_security/index"
)
}
'
;
window
.
gl
.
mrWidgetData
.
approvals_help_path
=
'
#{
help_page_path
(
"user/project/merge_requests/merge_request_approvals"
)
}
'
;
window
.
gl
.
mrWidgetData
.
visual_review_app_available
=
'
#{
@project
.
feature_available?
(
:visual_review_app
)
}
'
===
'
true
'
;
window
.
gl
.
mrWidgetData
.
license_management_comparsion_path
=
'
#{
license_management_reports_project_merge_request_path
(
@project
,
@merge_request
)
if
@project
.
feature_available?
(
:license_management
)
}
'
ee/changelogs/unreleased/12020-move-lm-reports-comparision-to-backend.yml
0 → 100644
View file @
1f7344e1
---
title
:
Expose licence management reports comparison
merge_request
:
14723
author
:
type
:
changed
ee/config/routes/project.rb
View file @
1f7344e1
...
...
@@ -68,6 +68,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources
:merge_requests
,
only:
[],
constraints:
{
id:
/\d+/
}
do
member
do
get
:metrics_reports
get
:license_management_reports
end
end
...
...
ee/spec/controllers/projects/merge_requests_controller_spec.rb
View file @
1f7344e1
...
...
@@ -379,6 +379,91 @@ describe Projects::MergeRequestsController do
end
end
describe
'GET #license_management_reports'
do
let
(
:merge_request
)
{
create
(
:ee_merge_request
,
:with_license_management_reports
,
source_project:
project
,
author:
create
(
:user
))
}
let
(
:params
)
do
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
merge_request
.
iid
}
end
subject
{
get
:license_management_reports
,
params:
params
,
format: :json
}
before
do
allow_any_instance_of
(
::
MergeRequest
).
to
receive
(
:compare_reports
)
.
with
(
::
Ci
::
CompareLicenseManagementReportsService
).
and_return
(
comparison_status
)
end
context
'when comparison is being processed'
do
let
(
:comparison_status
)
{
{
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 comparison is done'
do
let
(
:comparison_status
)
{
{
status: :parsed
,
data:
{
new_licenses:
[],
existing_licenses:
[],
removed_licenses:
[]
}
}
}
it
'does not send polling interval'
do
expect
(
::
Gitlab
::
PollingInterval
).
not_to
receive
(
:set_header
)
subject
end
it
'returns 200 HTTP status'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
eq
({
"new_licenses"
=>
[],
"existing_licenses"
=>
[],
"removed_licenses"
=>
[]
})
end
end
context
'when user created corrupted test reports'
do
let
(
:comparison_status
)
{
{
status: :error
,
status_reason:
'Failed to parse license management 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'
=>
'Failed to parse license management reports'
})
end
end
context
'when something went wrong on our system'
do
let
(
:comparison_status
)
{
{}
}
it
'does not send polling interval'
do
expect
(
::
Gitlab
::
PollingInterval
).
not_to
receive
(
:set_header
)
subject
end
it
'returns 500 HTTP status'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:internal_server_error
)
expect
(
json_response
).
to
eq
({
'status_reason'
=>
'Unknown error'
})
end
end
end
describe
'GET #metrics_reports'
do
let
(
:merge_request
)
{
create
(
:ee_merge_request
,
:with_metrics_reports
,
source_project:
project
,
author:
create
(
:user
))
}
...
...
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