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