Commit 169d4e31 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '26574-rename-license-report-comparer' into 'master'

Rename LicenseManagement classes

See merge request gitlab-org/gitlab!18122
parents 5fbc646f b59088b5
......@@ -31,7 +31,7 @@ module EE
if report_exists
format.html { render_show }
format.json do
data = LicenseManagementReportsSerializer.new(project: project, current_user: current_user).represent(pipeline&.license_scanning_report&.licenses)
data = LicenseScanningReportsSerializer.new(project: project, current_user: current_user).represent(pipeline&.license_scanning_report&.licenses)
render json: data, status: :ok
end
else
......
......@@ -159,7 +159,7 @@ module EE
return { status: :error, status_reason: 'This merge request does not have license management reports' }
end
compare_reports(::Ci::CompareLicenseManagementReportsService, current_user)
compare_reports(::Ci::CompareLicenseScanningReportsService, current_user)
end
def has_metrics_reports?
......
# frozen_string_literal: true
class LicenseManagementReportsSerializer < BaseSerializer
entity LicenseManagementReportLicenseEntity
end
# frozen_string_literal: true
class LicenseScanningReportsSerializer < BaseSerializer
entity LicenseScanningReportLicenseEntity
end
# frozen_string_literal: true
class LicenseManagementReportsComparerEntity < Grape::Entity
expose :new_licenses, using: LicenseManagementReportLicenseEntity
expose :existing_licenses, using: LicenseManagementReportLicenseEntity
expose :removed_licenses, using: LicenseManagementReportLicenseEntity
end
# frozen_string_literal: true
class LicenseManagementReportsComparerSerializer < BaseSerializer
entity LicenseManagementReportsComparerEntity
end
# frozen_string_literal: true
class LicenseManagementReportDependencyEntity < Grape::Entity
class LicenseScanningReportDependencyEntity < Grape::Entity
expose :name
end
# frozen_string_literal: true
class LicenseManagementReportLicenseEntity < Grape::Entity
class LicenseScanningReportLicenseEntity < Grape::Entity
include RequestAwareEntity
expose :name
expose :classification
expose :dependencies, using: LicenseManagementReportDependencyEntity
expose :dependencies, using: LicenseScanningReportDependencyEntity
expose :count
expose :url
......
# frozen_string_literal: true
class LicenseScanningReportsComparerEntity < Grape::Entity
expose :new_licenses, using: LicenseScanningReportLicenseEntity
expose :existing_licenses, using: LicenseScanningReportLicenseEntity
expose :removed_licenses, using: LicenseScanningReportLicenseEntity
end
# frozen_string_literal: true
class LicenseScanningReportsComparerSerializer < BaseSerializer
entity LicenseScanningReportsComparerEntity
end
# frozen_string_literal: true
module Ci
class CompareLicenseManagementReportsService < ::Ci::CompareReportsBaseService
class CompareLicenseScanningReportsService < ::Ci::CompareReportsBaseService
def comparer_class
Gitlab::Ci::Reports::LicenseManagement::ReportsComparer
Gitlab::Ci::Reports::LicenseScanning::ReportsComparer
end
def serializer_class
LicenseManagementReportsComparerSerializer
LicenseScanningReportsComparerSerializer
end
def get_report(pipeline)
......
......@@ -3,7 +3,7 @@
module Gitlab
module Ci
module Reports
module LicenseManagement
module LicenseScanning
class ReportsComparer
include Gitlab::Utils::StrongMemoize
......
......@@ -709,7 +709,7 @@ describe Projects::MergeRequestsController do
before do
allow_any_instance_of(::MergeRequest).to receive(:compare_reports)
.with(::Ci::CompareLicenseManagementReportsService, project.users.first).and_return(comparison_status)
.with(::Ci::CompareLicenseScanningReportsService, project.users.first).and_return(comparison_status)
end
context 'when comparison is being processed' do
......@@ -746,7 +746,7 @@ describe Projects::MergeRequestsController do
end
context 'when user created corrupted test reports' do
let(:comparison_status) { { status: :error, status_reason: 'Failed to parse license management reports' } }
let(:comparison_status) { { status: :error, status_reason: 'Failed to parse license scanning reports' } }
it 'does not send polling interval' do
expect(::Gitlab::PollingInterval).not_to receive(:set_header)
......@@ -758,7 +758,7 @@ describe Projects::MergeRequestsController do
subject
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq({ 'status_reason' => 'Failed to parse license management reports' })
expect(json_response).to eq({ 'status_reason' => 'Failed to parse license scanning reports' })
end
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe Gitlab::Ci::Reports::LicenseManagement::ReportsComparer do
describe Gitlab::Ci::Reports::LicenseScanning::ReportsComparer do
let(:report_1) { build :ci_reports_license_management_report, :report_1 }
let(:report_2) { build :ci_reports_license_management_report, :report_2 }
let(:report_comparer) { described_class.new(report_1, report_2) }
......
......@@ -400,7 +400,7 @@ describe MergeRequest do
end
it 'returns status and data' do
expect_any_instance_of(Ci::CompareLicenseManagementReportsService)
expect_any_instance_of(Ci::CompareLicenseScanningReportsService)
.to receive(:execute).with(base_pipeline, head_pipeline).and_call_original
subject
......@@ -408,7 +408,7 @@ describe MergeRequest do
context 'when cached results is not latest' do
before do
allow_any_instance_of(Ci::CompareLicenseManagementReportsService)
allow_any_instance_of(Ci::CompareLicenseScanningReportsService)
.to receive(:latest?).and_return(false)
end
......
......@@ -2,8 +2,8 @@
require 'spec_helper'
describe LicenseManagementReportDependencyEntity do
include LicenseManagementReportHelper
describe LicenseScanningReportDependencyEntity do
include LicenseScanningReportHelper
let(:dependency) { create_dependency }
let(:entity) { described_class.new(dependency) }
......
......@@ -2,8 +2,8 @@
require 'spec_helper'
describe LicenseManagementReportLicenseEntity do
include LicenseManagementReportHelper
describe LicenseScanningReportLicenseEntity do
include LicenseScanningReportHelper
let(:user) { build(:user) }
let(:project) { build(:project, :repository) }
......
......@@ -2,8 +2,8 @@
require 'spec_helper'
describe LicenseManagementReportsComparerEntity do
include LicenseManagementReportHelper
describe LicenseScanningReportsComparerEntity do
include LicenseScanningReportHelper
let(:user) { build(:user) }
let(:project) { build(:project, :repository) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe Ci::CompareLicenseManagementReportsService do
describe Ci::CompareLicenseScanningReportsService do
let(:current_user) { project.users.take }
let(:service) { described_class.new(project, current_user) }
let(:project) { create(:project, :repository) }
......@@ -14,7 +14,7 @@ describe Ci::CompareLicenseManagementReportsService do
describe '#execute' do
subject { service.execute(base_pipeline, head_pipeline) }
context 'when head pipeline has license management reports' do
context 'when head pipeline has license scanning reports' do
let!(:base_pipeline) { nil }
let!(:head_pipeline) { create(:ee_ci_pipeline, :with_license_management_report, project: project) }
......@@ -49,7 +49,7 @@ describe Ci::CompareLicenseManagementReportsService do
end
end
context 'when head pipeline has corrupted license management reports' do
context 'when head pipeline has corrupted license scanning reports' do
let!(:base_pipeline) { create(:ee_ci_pipeline, :with_corrupted_license_management_report, project: project) }
let!(:head_pipeline) { create(:ee_ci_pipeline, :with_corrupted_license_management_report, project: project) }
......
# frozen_string_literal: true
module LicenseManagementReportHelper
module LicenseScanningReportHelper
def create_report(dependencies)
Gitlab::Ci::Reports::LicenseScanning::Report.new.tap do |report|
dependencies.each do |license_name, dependencies|
......@@ -28,7 +28,7 @@ module LicenseManagementReportHelper
end
def create_comparer
Gitlab::Ci::Reports::LicenseManagement::ReportsComparer.new(create_report1, create_report2)
Gitlab::Ci::Reports::LicenseScanning::ReportsComparer.new(create_report1, create_report2)
end
def create_license
......
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