Commit a4d2f61d authored by Mark Florian's avatar Mark Florian

Merge branch 'mf-license-check-for-full-codequality-report' into 'master'

Add license check for full code quality report

See merge request gitlab-org/gitlab!53258
parents 58acfc19 628515db
...@@ -21,6 +21,7 @@ class License < ApplicationRecord ...@@ -21,6 +21,7 @@ class License < ApplicationRecord
contribution_analytics contribution_analytics
description_diffs description_diffs
elastic_search elastic_search
full_codequality_report
group_activity_analytics group_activity_analytics
group_bulk_edit group_bulk_edit
group_webhooks group_webhooks
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- licenses_api_path = licenses_project_pipeline_path(project, pipeline) if project.feature_available?(:license_scanning) - licenses_api_path = licenses_project_pipeline_path(project, pipeline) if project.feature_available?(:license_scanning)
- vulnerabilities_endpoint_path = expose_path(api_v4_projects_vulnerability_findings_path(id: project.id, params: { pipeline_id: pipeline.id })) - vulnerabilities_endpoint_path = expose_path(api_v4_projects_vulnerability_findings_path(id: project.id, params: { pipeline_id: pipeline.id }))
- vulnerability_exports_endpoint_path = expose_path(api_v4_security_projects_vulnerability_exports_path(id: project.id)) - vulnerability_exports_endpoint_path = expose_path(api_v4_security_projects_vulnerability_exports_path(id: project.id))
- codequality_report_download_path = pipeline.downloadable_path_for_report_type(:codequality) - codequality_report_download_path = pipeline.downloadable_path_for_report_type(:codequality) if project.feature_available?(:full_codequality_report)
- if pipeline.expose_security_dashboard? - if pipeline.expose_security_dashboard?
#js-tab-security.build-security.tab-pane #js-tab-security.build-security.tab-pane
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
= _("Licenses") = _("Licenses")
%span.badge.badge-pill.js-licenses-counter.hidden{ data: { qa_selector: 'licenses_counter' } } %span.badge.badge-pill.js-licenses-counter.hidden{ data: { qa_selector: 'licenses_counter' } }
- if pipeline.downloadable_path_for_report_type(:codequality) - if project.feature_available?(:full_codequality_report) && pipeline.downloadable_path_for_report_type(:codequality)
%li.js-codequality-tab-link %li.js-codequality-tab-link
= link_to codequality_report_project_pipeline_path(project, pipeline), data: { target: '#js-tab-codequality', action: 'codequality_report', toggle: 'tab', 'track-event': 'click_button', 'track-label': 'get_codequality_report' }, class: 'codequality-tab' do = link_to codequality_report_project_pipeline_path(project, pipeline), data: { target: '#js-tab-codequality', action: 'codequality_report', toggle: 'tab', 'track-event': 'click_button', 'track-label': 'get_codequality_report' }, class: 'codequality-tab' do
= _('Code Quality') = _('Code Quality')
---
title: Add license check for full code quality report
merge_request: 53258
author:
type: fixed
...@@ -169,34 +169,53 @@ RSpec.describe 'Pipeline', :js do ...@@ -169,34 +169,53 @@ RSpec.describe 'Pipeline', :js do
describe 'GET /:project/pipelines/:id/codequality_report', :aggregate_failures do describe 'GET /:project/pipelines/:id/codequality_report', :aggregate_failures do
shared_examples_for 'full codequality report' do shared_examples_for 'full codequality report' do
context 'with no code quality artifact' do context 'when licensed' do
before do before do
create(:ee_ci_build, pipeline: pipeline) stub_licensed_features(full_codequality_report: true)
visit project_pipeline_path(project, pipeline)
end end
it 'does not show code quality tab' do context 'with code quality artifact' do
expect(page).not_to have_content('Code Quality') before do
expect(page).not_to have_css('#js-tab-codequality') create(:ee_ci_build, :codequality, pipeline: pipeline)
visit codequality_report_project_pipeline_path(project, pipeline)
end
it 'shows code quality tab pane as active, quality issue with link to file, and events for data tracking' do
expect(page).to have_content('Code Quality')
expect(page).to have_css('#js-tab-codequality')
expect(page).to have_content('Method `new_array` has 12 arguments (exceeds 4 allowed). Consider refactoring.')
expect(find_link('foo.rb:10')[:href]).to end_with(project_blob_path(project, File.join(pipeline.commit.id, 'foo.rb')) + '#L10')
expect(page).to have_selector('[data-track-event="click_button"]')
expect(page).to have_selector('[data-track-label="get_codequality_report"]')
end
end
context 'with no code quality artifact' do
before do
create(:ee_ci_build, pipeline: pipeline)
visit project_pipeline_path(project, pipeline)
end
it 'does not show code quality tab' do
expect(page).not_to have_content('Code Quality')
expect(page).not_to have_css('#js-tab-codequality')
end
end end
end end
context 'with code quality artifact' do context 'when unlicensed' do
before do before do
stub_licensed_features(full_codequality_report: false)
create(:ee_ci_build, :codequality, pipeline: pipeline) create(:ee_ci_build, :codequality, pipeline: pipeline)
visit codequality_report_project_pipeline_path(project, pipeline) visit project_pipeline_path(project, pipeline)
wait_for_requests
end end
it 'shows code quality tab pane as active, quality issue with link to file, and events for data tracking' do it 'does not show code quality tab' do
expect(page).to have_content('Code Quality') expect(page).not_to have_content('Code Quality')
expect(page).to have_css('#js-tab-codequality') expect(page).not_to have_css('#js-tab-codequality')
expect(page).to have_content('Method `new_array` has 12 arguments (exceeds 4 allowed). Consider refactoring.')
expect(find_link('foo.rb:10')[:href]).to end_with(project_blob_path(project, File.join(pipeline.commit.id, 'foo.rb')) + '#L10')
expect(page).to have_selector('[data-track-event="click_button"]')
expect(page).to have_selector('[data-track-label="get_codequality_report"]')
end end
end 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