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
0d5c00b0
Commit
0d5c00b0
authored
Dec 05, 2019
by
mo khan
Committed by
Ash McKenzie
Dec 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Map blacklisted to denied for legacy API
parent
69d4c55d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
14 deletions
+34
-14
ee/app/services/software_license_policies/create_service.rb
ee/app/services/software_license_policies/create_service.rb
+10
-1
ee/spec/services/software_license_policies/create_service_spec.rb
...services/software_license_policies/create_service_spec.rb
+24
-13
No files found.
ee/app/services/software_license_policies/create_service.rb
View file @
0d5c00b0
...
...
@@ -24,10 +24,19 @@ module SoftwareLicensePolicies
policy
=
SoftwareLicense
.
create_policy_for!
(
project:
project
,
name:
params
[
:name
],
classification:
params
[
:approval_status
]
classification:
map_from
(
params
[
:approval_status
])
)
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
policy
end
def
map_from
(
approval_status
)
case
approval_status
when
'blacklisted'
'denied'
else
approval_status
end
end
end
end
ee/spec/services/software_license_policies/create_service_spec.rb
View file @
0d5c00b0
...
...
@@ -36,10 +36,20 @@ describe SoftwareLicensePolicies::CreateService do
software_license_policy
=
project
.
software_license_policies
.
last
expect
(
software_license_policy
).
to
be_persisted
expect
(
software_license_policy
.
name
).
to
eq
(
params
[
:name
])
expect
(
software_license_policy
.
classification
).
to
eq
(
'
blacklist
ed'
)
expect
(
software_license_policy
.
classification
).
to
eq
(
'
deni
ed'
)
end
context
"when valid parameters are specified"
do
context
'when valid parameters are specified'
do
where
(
:approval_status
,
:expected_classification
)
do
[
[
'approved'
,
'approved'
],
[
'denied'
,
'denied'
],
[
'blacklisted'
,
'denied'
],
]
end
with_them
do
let
(
:params
)
{
{
name:
'MIT'
,
approval_status:
approval_status
}
}
let
(
:result
)
{
subject
.
execute
}
before
do
...
...
@@ -51,9 +61,10 @@ describe SoftwareLicensePolicies::CreateService do
specify
{
expect
(
result
[
:software_license_policy
]).
to
be_present
}
specify
{
expect
(
result
[
:software_license_policy
]).
to
be_persisted
}
specify
{
expect
(
result
[
:software_license_policy
].
name
).
to
eql
(
params
[
:name
])
}
specify
{
expect
(
result
[
:software_license_policy
].
classification
).
to
eql
(
'blacklisted'
)
}
specify
{
expect
(
result
[
:software_license_policy
].
classification
).
to
eql
(
expected_classification
)
}
specify
{
expect
(
RefreshLicenseComplianceChecksWorker
).
to
have_received
(
:perform_async
).
with
(
project
.
id
)
}
end
end
context
"when an argument error is raised"
do
before
do
...
...
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