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
2ac65b13
Commit
2ac65b13
authored
Nov 05, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs
parent
ef6b8a8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
30 deletions
+101
-30
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+2
-2
ee/spec/factories/ci/builds.rb
ee/spec/factories/ci/builds.rb
+19
-3
ee/spec/serializers/merge_request_widget_entity_spec.rb
ee/spec/serializers/merge_request_widget_entity_spec.rb
+80
-25
No files found.
ee/app/models/ee/ci/pipeline.rb
View file @
2ac65b13
...
...
@@ -28,8 +28,8 @@ module EE
dependency_scanning:
%i[dependency_scanning]
,
container_scanning:
%i[container_scanning sast_container]
,
dast:
%i[dast]
,
performance:
%i[
:
merge_request_performance_metrics]
,
license_management:
nil
performance:
%i[merge_request_performance_metrics]
,
license_management:
%i[license_management]
}.
freeze
# Deprecated, to be removed in 12.0
...
...
ee/spec/factories/ci/builds.rb
View file @
2ac65b13
...
...
@@ -6,9 +6,25 @@ FactoryBot.define do
failure_reason
{
Ci
::
Build
.
failure_reasons
[
:protected_environment_failure
]
}
end
trait
:security_reports
do
after
(
:build
)
do
|
build
|
build
.
job_artifacts
<<
create
(
:ee_ci_job_artifact
,
:sast
,
job:
build
)
%i[sast performance license_management]
.
each
do
|
report_type
|
trait
"legacy_
#{
report_type
}
"
.
to_sym
do
success
artifacts
name
report_type
options
do
{
artifacts:
{
paths:
[
Ci
::
JobArtifact
::
DEFAULT_FILE_NAMES
[
report_type
]]
}
}
end
end
trait
report_type
do
after
(
:build
)
do
|
build
|
build
.
job_artifacts
<<
build
(
:ee_ci_job_artifact
,
report_type
,
job:
build
)
end
end
end
end
...
...
ee/spec/serializers/merge_request_widget_entity_spec.rb
View file @
2ac65b13
require
'spec_helper'
describe
MergeRequestWidgetEntity
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
:project
,
:repository
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
set
(
:user
)
{
create
(
:user
)
}
set
(
:project
)
{
create
:project
,
:repository
}
set
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
set
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
(
:request
)
{
double
(
'request'
,
current_user:
user
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
before
do
project
.
add_developer
(
user
)
...
...
@@ -39,6 +39,8 @@ describe MergeRequestWidgetEntity do
:dependency_scanning
|
:dependency_scanning
:sast_container
|
:container_scanning
:dast
|
:dast
:license_management
|
:license_management
:performance
|
:performance
end
with_them
do
...
...
@@ -54,7 +56,7 @@ describe MergeRequestWidgetEntity do
allow
(
pipeline
).
to
receive
(
:available_licensed_report_type?
).
and_return
(
true
)
end
context
"with
data
"
do
context
"with
new report artifacts
"
do
before
do
job
=
create
(
:ci_build
,
pipeline:
pipeline
)
create
(
:ci_job_artifact
,
file_type:
artifact_type
,
file_format:
Ci
::
JobArtifact
::
TYPE_AND_FORMAT_PAIRS
[
artifact_type
],
job:
job
)
...
...
@@ -65,7 +67,27 @@ describe MergeRequestWidgetEntity do
end
end
context
"without data"
do
context
"with legacy report artifacts"
do
before
do
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
name:
artifact_type
,
options:
{
artifacts:
{
paths:
[
Ci
::
JobArtifact
::
DEFAULT_FILE_NAMES
[
artifact_type
]]
}
}
)
end
it
"has data entry"
do
expect
(
subject
.
as_json
).
to
include
(
json_entry
)
end
end
context
"without artifacts"
do
it
"does not have data entry"
do
expect
(
subject
.
as_json
).
not_to
include
(
json_entry
)
end
...
...
@@ -76,34 +98,67 @@ describe MergeRequestWidgetEntity do
describe
'#license_management'
do
before
do
build
=
create
(
:ci_build
,
pipeline:
pipeline
)
create
(
:ee_ci_job_artifact
,
:license_management
,
job:
build
)
allow
(
merge_request
).
to
receive_messages
(
head_pipeline:
pipeline
,
target_project:
project
)
stub_licensed_features
(
license_management:
true
)
end
it
'should not be included, if license management features are off'
do
allow
(
merge_request
).
to
receive_messages
(
expose_license_management_data?:
false
)
it
'should not be included, if missing artifacts'
do
expect
(
subject
.
as_json
).
not_to
include
(
:license_management
)
end
it
'should be included, if license manage management features are on'
do
expect
(
subject
.
as_json
).
to
include
(
:license_management
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:head_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:base_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:managed_licenses_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:can_manage_licenses
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:license_management_full_report_path
)
end
context
'when report artifact is defined'
do
before
do
create
(
:ee_ci_build
,
:license_management
,
pipeline:
pipeline
)
end
it
'should be included'
do
expect
(
subject
.
as_json
).
to
include
(
:license_management
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:head_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:base_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:managed_licenses_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:can_manage_licenses
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:license_management_full_report_path
)
end
context
'when feature is not licensed'
do
before
do
stub_licensed_features
(
license_management:
false
)
end
it
'should not be included'
do
expect
(
subject
.
as_json
).
not_to
include
(
:license_management
)
end
end
it
'#license_management_settings_path should not be included for developers'
do
expect
(
subject
.
as_json
[
:license_management
]).
not_to
include
(
:license_management_settings_path
)
end
context
'when user is maintainer'
do
before
do
project
.
add_maintainer
(
user
)
end
it
'#license_management_settings_path should not be included for developers'
do
expect
(
subject
.
as_json
[
:license_management
]).
not_to
include
(
:license_management_settings_path
)
it
'#license_management_settings_path should be included for maintainers'
do
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:license_management_settings_path
)
end
end
end
it
'#license_management_settings_path should be included for maintainers'
do
stub_licensed_features
(
license_management:
true
)
project
.
add_maintainer
(
user
)
context
'when legacy artifact is defined'
do
before
do
create
(
:ee_ci_build
,
:legacy_license_management
,
pipeline:
pipeline
)
end
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:license_management_settings_path
)
it
'should be included, if license manage management features are on'
do
expect
(
subject
.
as_json
).
to
include
(
:license_management
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:head_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:base_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:managed_licenses_path
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:can_manage_licenses
)
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:license_management_full_report_path
)
end
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