From c73683cff56c36c75c89ad8fa8f14d5da220f6b0 Mon Sep 17 00:00:00 2001 From: Huzaifa Iftikhar <hiftikhar@gitlab.com> Date: Tue, 21 Nov 2023 06:10:37 +0000 Subject: [PATCH] Remove feature flag adherence_report_ui and compliance_adherence_report Changelog: other EE: true --- .../development/adherence_report_ui.yml | 8 -- .../compliance_adherence_report.yml | 8 -- .../compliance/compliance_center/index.md | 6 +- .../compliance_dashboard_bundle.js | 3 - .../components/reports_app.vue | 12 ++- .../compliance_dashboard/router.js | 3 +- .../services/approval_rules/update_service.rb | 6 +- ee/app/services/ee/projects/create_service.rb | 2 - .../update_service.rb | 4 - .../compliance_dashboards/show.html.haml | 1 - .../security/compliance_dashboards_spec.rb | 68 +++--------- .../components/reports_app_spec.js | 4 +- .../approval_rules/update_service_spec.rb | 29 +---- .../update_service_spec.rb | 78 ++++---------- .../services/projects/create_service_spec.rb | 100 ++++-------------- .../show.html.haml_spec.rb | 38 ------- 16 files changed, 77 insertions(+), 293 deletions(-) delete mode 100644 config/feature_flags/development/adherence_report_ui.yml delete mode 100644 config/feature_flags/development/compliance_adherence_report.yml diff --git a/config/feature_flags/development/adherence_report_ui.yml b/config/feature_flags/development/adherence_report_ui.yml deleted file mode 100644 index 7db4fbb756fe5..0000000000000 --- a/config/feature_flags/development/adherence_report_ui.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: adherence_report_ui -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122374 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/414495 -milestone: '16.1' -type: development -group: group::compliance -default_enabled: true diff --git a/config/feature_flags/development/compliance_adherence_report.yml b/config/feature_flags/development/compliance_adherence_report.yml deleted file mode 100644 index f67ff7bdec35e..0000000000000 --- a/config/feature_flags/development/compliance_adherence_report.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: compliance_adherence_report -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124167 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/416988 -milestone: '16.2' -type: development -group: group::compliance -default_enabled: true diff --git a/doc/user/compliance/compliance_center/index.md b/doc/user/compliance/compliance_center/index.md index 4a42a70a7e7f1..e17f5c1ec3921 100644 --- a/doc/user/compliance/compliance_center/index.md +++ b/doc/user/compliance/compliance_center/index.md @@ -16,11 +16,7 @@ See report and manage standards adherence, violations, and compliance frameworks > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125875) GraphQL APIs in GitLab 16.2 [with a flag](../../../administration/feature_flags.md) named `compliance_adherence_report`. Disabled by default. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125444) standards adherence dashboard in GitLab 16.3 [with a flag](../../../administration/feature_flags.md) named `adherence_report_ui`. Disabled by default. > - [Enabled](https://gitlab.com/gitlab-org/gitlab/-/issues/414495) in GitLab 16.5. - -FLAG: -On self-managed GitLab, by default this feature is available. To hide the feature per project or for your entire instance, an administrator can -[disable the feature flags](../../../administration/feature_flags.md) named `compliance_adherence_report` and `adherence_report_ui`. On GitLab.com, -this feature is available. +> - [Feature flag `compliance_adherence_report` and `adherence_report_ui`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137398) removed in GitLab 16.7. Standards adherence dashboard lists the adherence status of projects complying to GitLab standard. diff --git a/ee/app/assets/javascripts/compliance_dashboard/compliance_dashboard_bundle.js b/ee/app/assets/javascripts/compliance_dashboard/compliance_dashboard_bundle.js index 7d0ccfa53bbbf..4ddbd32d0c0e7 100644 --- a/ee/app/assets/javascripts/compliance_dashboard/compliance_dashboard_bundle.js +++ b/ee/app/assets/javascripts/compliance_dashboard/compliance_dashboard_bundle.js @@ -21,7 +21,6 @@ export default () => { rootAncestorPath, pipelineConfigurationFullPathEnabled, pipelineConfigurationEnabled, - adherenceReportUiEnabled, complianceFrameworkReportUiEnabled, } = el.dataset; @@ -36,7 +35,6 @@ export default () => { mergeCommitsCsvExportPath, groupPath, rootAncestorPath, - adherenceReportUiEnabled: parseBoolean(adherenceReportUiEnabled), complianceFrameworkReportUiEnabled: parseBoolean(complianceFrameworkReportUiEnabled), }); @@ -50,7 +48,6 @@ export default () => { canAddEdit, pipelineConfigurationFullPathEnabled: parseBoolean(pipelineConfigurationFullPathEnabled), pipelineConfigurationEnabled: parseBoolean(pipelineConfigurationEnabled), - adherenceReportUiEnabled: parseBoolean(adherenceReportUiEnabled), complianceFrameworkReportUiEnabled: parseBoolean(complianceFrameworkReportUiEnabled), }, render: (createElement) => diff --git a/ee/app/assets/javascripts/compliance_dashboard/components/reports_app.vue b/ee/app/assets/javascripts/compliance_dashboard/components/reports_app.vue index b714409de8d3a..8ce9dcd7e64be 100644 --- a/ee/app/assets/javascripts/compliance_dashboard/components/reports_app.vue +++ b/ee/app/assets/javascripts/compliance_dashboard/components/reports_app.vue @@ -27,7 +27,7 @@ export default { GlTooltip: GlTooltipDirective, }, mixins: [Tracking.mixin()], - inject: ['adherenceReportUiEnabled', 'complianceFrameworkReportUiEnabled'], + inject: ['complianceFrameworkReportUiEnabled'], props: { mergeCommitsCsvExportPath: { type: String, @@ -62,9 +62,12 @@ export default { return Boolean(this.frameworksCsvExportPath) && this.isProjectsReport; }, tabIndex() { - const adherenceTab = this.adherenceReportUiEnabled ? [ROUTE_STANDARDS_ADHERENCE] : []; - - const currentTabs = [...adherenceTab, ROUTE_VIOLATIONS, ROUTE_FRAMEWORKS, ROUTE_PROJECTS]; + const currentTabs = [ + ROUTE_STANDARDS_ADHERENCE, + ROUTE_VIOLATIONS, + ROUTE_FRAMEWORKS, + ROUTE_PROJECTS, + ]; return currentTabs.indexOf(this.$route.name); }, @@ -161,7 +164,6 @@ export default { <gl-tabs :value="tabIndex" content-class="gl-p-0" lazy> <gl-tab - v-if="adherenceReportUiEnabled" :title="$options.i18n.standardsAdherenceTab" :title-link-attributes="standardsAdherenceTabLinkAttributes" data-testid="standards-adherence-tab-content" diff --git a/ee/app/assets/javascripts/compliance_dashboard/router.js b/ee/app/assets/javascripts/compliance_dashboard/router.js index 0bc037b8a4af2..986269380ac90 100644 --- a/ee/app/assets/javascripts/compliance_dashboard/router.js +++ b/ee/app/assets/javascripts/compliance_dashboard/router.js @@ -15,14 +15,13 @@ import StandardsReport from './components/standards_adherence_report/report.vue' export function createRouter(basePath, props) { const { - adherenceReportUiEnabled, complianceFrameworkReportUiEnabled, mergeCommitsCsvExportPath, groupPath, rootAncestorPath, } = props; - const defaultRoute = adherenceReportUiEnabled ? ROUTE_STANDARDS_ADHERENCE : ROUTE_VIOLATIONS; + const defaultRoute = ROUTE_STANDARDS_ADHERENCE; const frameworkReport = complianceFrameworkReportUiEnabled ? FrameworksReport : ProjectsReport; const routes = [ diff --git a/ee/app/services/approval_rules/update_service.rb b/ee/app/services/approval_rules/update_service.rb index 44238c286a74c..e3d1a099ff1d9 100644 --- a/ee/app/services/approval_rules/update_service.rb +++ b/ee/app/services/approval_rules/update_service.rb @@ -27,10 +27,8 @@ def success merge_request_activity_counter .track_approval_rule_edited_action(user: current_user) - if ::Feature.enabled?(:compliance_adherence_report, project.group) - ::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker - .perform_async({ 'project_id' => rule.project.id, 'user_id' => current_user&.id }) - end + ::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker + .perform_async({ 'project_id' => rule.project.id, 'user_id' => current_user&.id }) super end diff --git a/ee/app/services/ee/projects/create_service.rb b/ee/app/services/ee/projects/create_service.rb index 3234f4ed36744..51564204d9887 100644 --- a/ee/app/services/ee/projects/create_service.rb +++ b/ee/app/services/ee/projects/create_service.rb @@ -157,8 +157,6 @@ def set_default_compliance_framework end def run_compliance_standards_checks - return unless ::Feature.enabled?(:compliance_adherence_report, project.group) - ::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker .perform_async({ 'project_id' => project.id, 'user_id' => current_user.id }) diff --git a/ee/app/services/merge_request_approval_settings/update_service.rb b/ee/app/services/merge_request_approval_settings/update_service.rb index c533acaad029f..01c9a7ab91d8a 100644 --- a/ee/app/services/merge_request_approval_settings/update_service.rb +++ b/ee/app/services/merge_request_approval_settings/update_service.rb @@ -72,8 +72,6 @@ def run_compliance_standards_checks end def run_compliance_checks_for_group - return unless Feature.enabled?(:compliance_adherence_report, container) - ::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorGroupWorker .perform_async({ 'group_id' => container.id, 'user_id' => current_user&.id }) @@ -82,8 +80,6 @@ def run_compliance_checks_for_group end def run_compliance_checks_for_project - return unless Feature.enabled?(:compliance_adherence_report, container.root_ancestor) - ::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker .perform_async({ 'project_id' => container.id, 'user_id' => current_user&.id }) diff --git a/ee/app/views/groups/security/compliance_dashboards/show.html.haml b/ee/app/views/groups/security/compliance_dashboards/show.html.haml index e9c964904fb41..7664baed0e5ef 100644 --- a/ee/app/views/groups/security/compliance_dashboards/show.html.haml +++ b/ee/app/views/groups/security/compliance_dashboards/show.html.haml @@ -11,5 +11,4 @@ pipeline_configuration_full_path_enabled: can?(current_user, :admin_compliance_pipeline_configuration, @group), base_path: group_security_compliance_dashboard_path(@group), pipeline_configuration_enabled: @group.licensed_feature_available?(:compliance_pipeline_configuration).to_s, - adherence_report_ui_enabled: Feature.enabled?(:adherence_report_ui, @group).to_s, compliance_framework_report_ui_enabled: Feature.enabled?(:compliance_framework_report_ui, @group).to_s } } diff --git a/ee/spec/features/groups/security/compliance_dashboards_spec.rb b/ee/spec/features/groups/security/compliance_dashboards_spec.rb index 55a07d8faf6b8..688342f91e44c 100644 --- a/ee/spec/features/groups/security/compliance_dashboards_spec.rb +++ b/ee/spec/features/groups/security/compliance_dashboards_spec.rb @@ -8,12 +8,10 @@ let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, :repository, :public, namespace: group) } let_it_be(:project_2) { create(:project, :repository, :public, namespace: group) } - let(:adherence_ff) { false } let(:compliance_framework_ff) { false } before do stub_feature_flags(compliance_framework_report_ui: compliance_framework_ff) - stub_feature_flags(adherence_report_ui: adherence_ff) stub_licensed_features(group_level_compliance_dashboard: true) group.add_owner(user) sign_in(user) @@ -24,50 +22,28 @@ visit group_security_compliance_dashboard_path(group) end - context 'with feature flag `adherence_report_ui` enabled' do - let(:adherence_ff) { true } - - it 'has the `Standards Adherence` tab selected by default' do - page.within('.gl-tabs') do - expect(find('[aria-selected="true"]').text).to eq('Standards Adherence') - end - end - - context 'when `Violations` tab is clicked' do - it 'has the violations tab selected' do - page.within('.gl-tabs') do - click_link _('Violations') - - expect(find('[aria-selected="true"]').text).to eq('Violations') - end - end - end - - context 'when `Projects` tab is clicked' do - it 'has the projects tab selected' do - page.within('.gl-tabs') do - click_link _('Projects') - - expect(find('[aria-selected="true"]').text).to eq('Projects') - end - end + it 'has the `Standards Adherence` tab selected by default' do + page.within('.gl-tabs') do + expect(find('[aria-selected="true"]').text).to eq('Standards Adherence') end end - context 'with feature flag `adherence_report_ui` disabled' do - it 'has the `Violations` tab selected by default' do + context 'when `Violations` tab is clicked' do + it 'has the violations tab selected' do page.within('.gl-tabs') do + click_link _('Violations') + expect(find('[aria-selected="true"]').text).to eq('Violations') end end + end - context 'when `Projects` tab is clicked' do - it 'has the projects tab selected' do - page.within('.gl-tabs') do - click_link _('Projects') + context 'when `Projects` tab is clicked' do + it 'has the projects tab selected' do + page.within('.gl-tabs') do + click_link _('Projects') - expect(find('[aria-selected="true"]').text).to eq('Projects') - end + expect(find('[aria-selected="true"]').text).to eq('Projects') end end end @@ -116,18 +92,8 @@ visit group_security_compliance_dashboard_path(group) end - context 'with feature flag `adherence_report_ui` enabled' do - let(:adherence_ff) { true } - - it 'shows the standards adherence tab by default' do - expect(page).to have_current_path(expected_path) - end - end - - context 'with feature flag `adherence_report_ui` disabled' do - it 'does not show the standards adherence tab' do - expect(page).not_to have_current_path(expected_path) - end + it 'shows the standards adherence tab by default' do + expect(page).to have_current_path(expected_path) end end @@ -145,7 +111,7 @@ context 'when there are no compliance violations' do before do - visit group_security_compliance_dashboard_path(group) + visit group_security_compliance_dashboard_path(group, vueroute: :violations) end it 'shows an empty state' do @@ -179,7 +145,7 @@ merge_request.metrics.update!(merged_at: merged_at) merge_request_2.metrics.update!(merged_at: 7.days.ago) - visit group_security_compliance_dashboard_path(group) + visit group_security_compliance_dashboard_path(group, vueroute: :violations) wait_for_requests end diff --git a/ee/spec/frontend/compliance_dashboard/components/reports_app_spec.js b/ee/spec/frontend/compliance_dashboard/components/reports_app_spec.js index e5763ee2c234d..0bb81f910f0ef 100644 --- a/ee/spec/frontend/compliance_dashboard/components/reports_app_spec.js +++ b/ee/spec/frontend/compliance_dashboard/components/reports_app_spec.js @@ -52,7 +52,6 @@ describe('ComplianceReportsApp component', () => { 'router-view': stubComponent({}), }, provide: { - adherenceReportUiEnabled: false, complianceFrameworkReportUiEnabled: false, ...provide, }, @@ -62,7 +61,7 @@ describe('ComplianceReportsApp component', () => { describe('adherence standards report', () => { beforeEach(() => { - wrapper = createComponent(defaultProps, mount, {}, { adherenceReportUiEnabled: true }); + wrapper = createComponent(defaultProps, mount, {}, {}); }); it('renders the standards adherence report tab', () => { @@ -201,7 +200,6 @@ describe('ComplianceReportsApp component', () => { }, }, { - adherenceReportUiEnabled: true, complianceFrameworkReportUiEnabled: true, }, ); diff --git a/ee/spec/services/approval_rules/update_service_spec.rb b/ee/spec/services/approval_rules/update_service_spec.rb index 6e77c48f4b82b..a4a69d629b381 100644 --- a/ee/spec/services/approval_rules/update_service_spec.rb +++ b/ee/spec/services/approval_rules/update_service_spec.rb @@ -39,31 +39,12 @@ result end - context 'when feature flag compliance_adherence_report is enabled' do - before do - stub_feature_flags(compliance_adherence_report: true) - end - - it 'invokes ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker' do - expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) - .to receive(:perform_async).with({ 'project_id' => approval_rule.project.id, 'user_id' => user.id }) - .and_call_original - - result - end - end + it 'invokes ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker' do + expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) + .to receive(:perform_async).with({ 'project_id' => approval_rule.project.id, 'user_id' => user.id }) + .and_call_original - context 'when feature flag compliance_adherence_report is disabled' do - before do - stub_feature_flags(compliance_adherence_report: false) - end - - it 'does not invoke ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker' do - expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) - .not_to receive(:perform_async) - - result - end + result end end diff --git a/ee/spec/services/merge_request_approval_settings/update_service_spec.rb b/ee/spec/services/merge_request_approval_settings/update_service_spec.rb index cff6e13228a4a..cdce257ad42c7 100644 --- a/ee/spec/services/merge_request_approval_settings/update_service_spec.rb +++ b/ee/spec/services/merge_request_approval_settings/update_service_spec.rb @@ -57,44 +57,25 @@ stub_licensed_features(group_level_compliance_dashboard: true) end - context 'when feature flag is enabled' do - before do - stub_feature_flags(compliance_adherence_report: true) - end + it 'invokes prevent approval by author and committer workers', :sidekiq_inline, :aggregate_failures do + expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) + .to receive(:perform_async).with({ 'project_id' => project.id, 'user_id' => user.id }).and_call_original - it 'invokes prevent approval by author and committer workers', :sidekiq_inline, :aggregate_failures do - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) - .to receive(:perform_async).with({ 'project_id' => project.id, 'user_id' => user.id }).and_call_original + expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) + .to receive(:perform_async).with({ 'project_id' => project.id, 'user_id' => user.id }).and_call_original - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) - .to receive(:perform_async).with({ 'project_id' => project.id, 'user_id' => user.id }).and_call_original - - response = subject.execute - - expect(response).to be_success + response = subject.execute - project_adherence = project.reload.compliance_standards_adherence - .for_check_name(:prevent_approval_by_merge_request_author).first + expect(response).to be_success - project_adherence_2 = project.reload.compliance_standards_adherence - .for_check_name(:prevent_approval_by_merge_request_committers).first + project_adherence = project.reload.compliance_standards_adherence + .for_check_name(:prevent_approval_by_merge_request_author).first - expect(project_adherence.status).to eq("success") - expect(project_adherence_2.status).to eq("success") - end - end + project_adherence_2 = project.reload.compliance_standards_adherence + .for_check_name(:prevent_approval_by_merge_request_committers).first - context 'when feature flag is disabled' do - before do - stub_feature_flags(compliance_adherence_report: false) - end - - it 'does not invoke PreventApprovalByAuthorWorker and PreventApprovalByCommitterWorker' do - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) - .not_to receive(:perform_async).with({ 'project_id' => project.id, 'user_id' => user.id }) - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) - .not_to receive(:perform_async).with({ 'project_id' => project.id, 'user_id' => user.id }) - end + expect(project_adherence.status).to eq("success") + expect(project_adherence_2.status).to eq("success") end end end @@ -151,35 +132,16 @@ stub_licensed_features(group_level_compliance_dashboard: true) end - context 'when feature flag is enabled' do - before do - stub_feature_flags(compliance_adherence_report: true) - end + it 'invokes GroupWorkers', :sidekiq_inline do + expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorGroupWorker) + .to receive(:perform_async).with({ 'group_id' => group.id, 'user_id' => user.id }).and_call_original - it 'invokes GroupWorkers', :sidekiq_inline do - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorGroupWorker) - .to receive(:perform_async).with({ 'group_id' => group.id, 'user_id' => user.id }).and_call_original + expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterGroupWorker) + .to receive(:perform_async).with({ 'group_id' => group.id, 'user_id' => user.id }).and_call_original - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterGroupWorker) - .to receive(:perform_async).with({ 'group_id' => group.id, 'user_id' => user.id }).and_call_original - - response = subject.execute - - expect(response).to be_success - end - end + response = subject.execute - context 'when feature flag is disabled' do - before do - stub_feature_flags(compliance_adherence_report: false) - end - - it 'does not invoke GroupWorkers' do - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorGroupWorker) - .not_to receive(:perform_async).with({ 'group_id' => group.id, 'user_id' => user.id }) - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterGroupWorker) - .not_to receive(:perform_async).with({ 'group_id' => group.id, 'user_id' => user.id }) - end + expect(response).to be_success end end diff --git a/ee/spec/services/projects/create_service_spec.rb b/ee/spec/services/projects/create_service_spec.rb index a43bbd5e1c9af..bdbd25504a59c 100644 --- a/ee/spec/services/projects/create_service_spec.rb +++ b/ee/spec/services/projects/create_service_spec.rb @@ -564,99 +564,45 @@ describe 'run_compliance_standards_checks' do let_it_be(:group, reload: true) { create(:group) } - context 'when feature flag is enabled' do + context 'when project belongs to a group', :sidekiq_inline do before do - stub_feature_flags(compliance_adherence_report: true) + group.add_maintainer(user) end - context 'when project belongs to a group', :sidekiq_inline do - before do - group.add_maintainer(user) - end - - it 'creates compliance standards adherence' do - stub_licensed_features(group_level_compliance_dashboard: true) - - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) - .to receive(:perform_async).and_call_original - - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) - .to receive(:perform_async).and_call_original + it 'creates compliance standards adherence' do + stub_licensed_features(group_level_compliance_dashboard: true) - expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) - .to receive(:perform_async).and_call_original - - project = create_project(user, { name: "GitLab", namespace_id: group.id }) - - expect(project.compliance_standards_adherence.count).to eq(3) - end - end + expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) + .to receive(:perform_async).and_call_original - context 'when project belongs to a user namespace' do - it 'does not invoke the workers' do - stub_licensed_features(group_level_compliance_dashboard: true) + expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) + .to receive(:perform_async).and_call_original - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) - .not_to receive(:perform_async) + expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) + .to receive(:perform_async).and_call_original - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) - .not_to receive(:perform_async) - - expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) - .not_to receive(:perform_async) - - project = create_project(user, opts) + project = create_project(user, { name: "GitLab", namespace_id: group.id }) - expect(project.compliance_standards_adherence).to be_empty - end + expect(project.compliance_standards_adherence.count).to eq(3) end end - context 'when feature flag is disabled' do - before do - stub_feature_flags(compliance_adherence_report: false) - end - - context 'when project belongs to a group', :sidekiq_inline do - before do - group.add_maintainer(user) - end - - it 'does not create compliance standards adherence' do - stub_licensed_features(group_level_compliance_dashboard: true) - - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) - .not_to receive(:perform_async) - - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) - .not_to receive(:perform_async) - - expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) - .not_to receive(:perform_async) - - project = create_project(user, { name: "GitLab", namespace_id: group.id }) - - expect(project.compliance_standards_adherence).to be_empty - end - end - - context 'when project belongs to a user namespace' do - it 'does not invoke the workers' do - stub_licensed_features(group_level_compliance_dashboard: true) + context 'when project belongs to a user namespace' do + it 'does not invoke the workers' do + stub_licensed_features(group_level_compliance_dashboard: true) - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) - .not_to receive(:perform_async) + expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByAuthorWorker) + .not_to receive(:perform_async) - expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) - .not_to receive(:perform_async) + expect(::ComplianceManagement::Standards::Gitlab::PreventApprovalByCommitterWorker) + .not_to receive(:perform_async) - expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) - .not_to receive(:perform_async) + expect(::ComplianceManagement::Standards::Gitlab::AtLeastTwoApprovalsWorker) + .not_to receive(:perform_async) - project = create_project(user, opts) + project = create_project(user, opts) - expect(project.compliance_standards_adherence).to be_empty - end + expect(project.compliance_standards_adherence).to be_empty end end end diff --git a/ee/spec/views/groups/security/compliance_dashboards/show.html.haml_spec.rb b/ee/spec/views/groups/security/compliance_dashboards/show.html.haml_spec.rb index 50f95b66614fe..f6d2e6bc63a65 100644 --- a/ee/spec/views/groups/security/compliance_dashboards/show.html.haml_spec.rb +++ b/ee/spec/views/groups/security/compliance_dashboards/show.html.haml_spec.rb @@ -28,44 +28,6 @@ expect(rendered).to have_selector("[data-pipeline-configuration-enabled='false']") end - context 'for `adherence-report-ui-enabled` selector' do - before do - Feature.disable(:adherence_report_ui) - end - - context 'when feature `adherence_report_ui` is not enabled' do - it 'renders with the correct selector value' do - render - - expect(rendered).to have_selector("[data-adherence-report-ui-enabled='false']") - end - end - - context 'when feature `adherence_report_ui` is enabled for a group' do - before do - Feature.enable(:adherence_report_ui, group) - end - - it 'renders with the correct selector value' do - render - - expect(rendered).to have_selector("[data-adherence-report-ui-enabled='true']") - end - end - - context 'when feature `adherence_report_ui` is globally enabled' do - before do - Feature.enable(:adherence_report_ui) - end - - it 'renders with the correct selector value' do - render - - expect(rendered).to have_selector("[data-adherence-report-ui-enabled='true']") - end - end - end - context 'for `compliance-framework-report-ui-enabled` selector' do context 'when feature `compliance_framework_report_ui` is not enabled' do before do -- GitLab