Commit 705e1b57 authored by Tetiana Chupryna's avatar Tetiana Chupryna

Remove redundant key

parent 8a384e0b
......@@ -40,25 +40,6 @@ module EE
merge_request.enabled_reports
end
# TODO: remove after https://gitlab.com/gitlab-org/gitlab/issues/205304 is done
expose :license_management, if: -> (mr, _) { head_pipeline_downloadable_path_for_report_type(:license_management) } do
expose :managed_licenses_path do |merge_request|
expose_path(api_v4_projects_managed_licenses_path(id: merge_request.target_project.id))
end
expose :can_manage_licenses do |merge_request|
can?(current_user, :admin_software_license_policy, merge_request)
end
expose :license_management_settings_path, if: -> (mr, _) { can?(current_user, :admin_software_license_policy, mr.target_project) } do |merge_request|
license_management_settings_path(merge_request.target_project)
end
expose :license_management_full_report_path, if: -> (mr, _) { mr.head_pipeline } do |merge_request|
licenses_project_pipeline_path(merge_request.target_project, merge_request.head_pipeline)
end
end
expose :license_scanning, if: -> (mr, _) { head_pipeline_downloadable_path_for_report_type(:license_scanning) } do
expose :managed_licenses_path do |merge_request|
expose_path(api_v4_projects_managed_licenses_path(id: merge_request.target_project.id))
......
......@@ -99,82 +99,6 @@ describe MergeRequestWidgetEntity do
end
end
describe '#license_management', :request_store do
before do
allow(merge_request).to receive_messages(
head_pipeline: pipeline, target_project: project)
stub_licensed_features(license_management: true)
end
it 'is not included, if missing artifacts' do
expect(subject.as_json).not_to include(:license_management)
end
context 'when report artifact is defined' do
before do
create(:ee_ci_build, :license_management, pipeline: pipeline)
end
it 'is included' do
expect(subject.as_json).to include(:license_management)
expect(subject.as_json[:license_management]).to include(:managed_licenses_path)
expect(subject.as_json[:license_management]).to include(:can_manage_licenses)
expect(subject.as_json[:license_management]).to include(:license_management_full_report_path)
end
context 'when feature is not licensed' do
before do
stub_licensed_features(license_scanning: false)
end
it 'is not included' do
expect(subject.as_json).not_to include(:license_management)
end
end
it '#license_management_settings_path should not be included for developers' do
expect(subject.as_json[:license_management]).not_to include(:license_management_settings_path)
end
context 'when user is maintainer' do
before do
project.add_maintainer(user)
end
it '#license_management_settings_path should be included for maintainers' do
expect(subject.as_json[:license_management]).to include(:license_management_settings_path)
end
end
end
describe '#managed_licenses_path' do
let(:managed_licenses_path) { expose_path(api_v4_projects_managed_licenses_path(id: project.id)) }
before do
create(:ee_ci_build, :license_management, pipeline: pipeline)
end
it 'is a path for target project' do
expect(subject.as_json[:license_management][:managed_licenses_path]).to eq(managed_licenses_path)
end
context 'with fork' do
let(:source_project) { fork_project(project, user, repository: true) }
let(:fork_merge_request) { create(:merge_request, source_project: source_project, target_project: project) }
let(:subject_json) { described_class.new(fork_merge_request, current_user: user, request: request).as_json }
before do
allow(fork_merge_request).to receive_messages(head_pipeline: pipeline)
stub_licensed_features(license_management: true)
end
it 'is a path for target project' do
expect(subject_json[:license_management][:managed_licenses_path]).to eq(managed_licenses_path)
end
end
end
end
describe '#license_scanning', :request_store do
before do
allow(merge_request).to receive_messages(head_pipeline: pipeline, target_project: project)
......
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