Commit 0146f8ef authored by mo khan's avatar mo khan Committed by Ash McKenzie

Ensure the old API returns the old values

parent 8c3a1891
......@@ -14,7 +14,7 @@ class SoftwareLicensePolicy < ApplicationRecord
attr_readonly :software_license
enum classification: {
denied: 0,
denied: 0,
approved: 1
}
......
......@@ -861,7 +861,9 @@ module EE
class ManagedLicense < Grape::Entity
expose :id, :name
expose :classification, as: :approval_status
expose :classification, as: :approval_status do |policy|
policy.denied? ? 'blacklisted' : policy.classification
end
end
class ProjectAlias < Grape::Entity
......
......@@ -38,7 +38,7 @@ describe API::ManagedLicenses do
expect(json_response).to be_a(Array)
expect(json_response.first['id']).to eq(software_license_policy.id)
expect(json_response.first['name']).to eq(software_license_policy.name)
expect(json_response.first['approval_status']).to eq(software_license_policy.classification)
expect(json_response.first['approval_status']).to eq('approved')
end
end
......@@ -51,7 +51,7 @@ describe API::ManagedLicenses do
expect(json_response).to be_a(Array)
expect(json_response.first['id']).to eq(software_license_policy.id)
expect(json_response.first['name']).to eq(software_license_policy.name)
expect(json_response.first['approval_status']).to eq(software_license_policy.classification)
expect(json_response.first['approval_status']).to eq('approved')
end
end
......@@ -92,7 +92,7 @@ describe API::ManagedLicenses do
expect(response).to match_response_schema('software_license_policy', dir: 'ee')
expect(json_response['id']).to eq(software_license_policy.id)
expect(json_response['name']).to eq(software_license_policy.name)
expect(json_response['approval_status']).to eq(software_license_policy.classification)
expect(json_response['approval_status']).to eq('approved')
end
it 'returns project managed license details using the license name as key' do
......@@ -103,7 +103,7 @@ describe API::ManagedLicenses do
expect(response).to match_response_schema('software_license_policy', dir: 'ee')
expect(json_response['id']).to eq(software_license_policy.id)
expect(json_response['name']).to eq(software_license_policy.name)
expect(json_response['approval_status']).to eq(software_license_policy.classification)
expect(json_response['approval_status']).to eq('approved')
end
it 'responds with 404 Not Found if requesting non-existing managed license' do
......@@ -121,7 +121,7 @@ describe API::ManagedLicenses do
expect(response).to match_response_schema('software_license_policy', dir: 'ee')
expect(json_response['id']).to eq(software_license_policy.id)
expect(json_response['name']).to eq(software_license_policy.name)
expect(json_response['approval_status']).to eq(software_license_policy.classification)
expect(json_response['approval_status']).to eq('approved')
end
end
......@@ -220,10 +220,10 @@ describe API::ManagedLicenses do
# Check that response is equal to the updated object
expect(json_response['id']).to eq(initial_id)
expect(json_response['name']).to eq(updated_software_license_policy.name)
expect(json_response['approval_status']).to eq(updated_software_license_policy.classification)
expect(json_response['approval_status']).to eq('blacklisted')
# Check that the approval status was updated
expect(updated_software_license_policy.classification).to eq('blacklisted')
expect(updated_software_license_policy).to be_denied
# Check that response is equal to the old object except for the approval status
expect(initial_id).to eq(updated_software_license_policy.id)
......
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