Commit ca1e2f89 authored by mo khan's avatar mo khan Committed by Ash McKenzie

Extract method to make intention clearer

parent dcce63fc
......@@ -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
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment