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
ca1e2f89
Commit
ca1e2f89
authored
Dec 05, 2019
by
mo khan
Committed by
Ash McKenzie
Dec 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract method to make intention clearer
parent
dcce63fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
ee/app/services/software_license_policies/create_service.rb
ee/app/services/software_license_policies/create_service.rb
+5
-3
ee/app/services/software_license_policies/update_service.rb
ee/app/services/software_license_policies/update_service.rb
+7
-3
No files found.
ee/app/services/software_license_policies/create_service.rb
View file @
ca1e2f89
...
...
@@ -21,15 +21,17 @@ module SoftwareLicensePolicies
private
def
create_software_license_policy
approval_status
=
params
[
:approval_status
]
classification
=
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
policy
=
SoftwareLicense
.
create_policy_for!
(
project:
project
,
name:
params
[
:name
],
classification:
classification
classification:
map_from
(
params
[
:approval_status
])
)
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
policy
end
def
map_from
(
approval_status
)
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
end
end
end
ee/app/services/software_license_policies/update_service.rb
View file @
ca1e2f89
...
...
@@ -12,9 +12,7 @@ module SoftwareLicensePolicies
return
success
(
software_license_policy:
software_license_policy
)
unless
params
[
:approval_status
].
present?
begin
approval_status
=
params
[
:approval_status
]
classification
=
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
software_license_policy
.
update
(
classification:
classification
)
software_license_policy
.
update
(
classification:
map_from
(
params
[
:approval_status
]))
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
rescue
ArgumentError
=>
ex
return
error
(
ex
.
message
,
400
)
...
...
@@ -22,5 +20,11 @@ module SoftwareLicensePolicies
success
(
software_license_policy:
software_license_policy
)
end
private
def
map_from
(
approval_status
)
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
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