Skip to content

Fix the compliance violations report not showing the merged by avatar

Jiaan Louw requested to merge jlouw-fix-compliance-violations-merged-by into master

What does this MR do and why?

This MR resolves an issue where the compliance violations report wouldn't render the merge by user correctly to resolve #356691 (closed).

Note: This feature is deployed a default off feature flag.

Screenshots or screen recordings

Before After
image image

How to set up and validate locally

  1. You need a GitLab Ultimate license.
  2. Enable the feature flag in your terminal: echo "Feature.enable(:compliance_violations_report);" | rails c
  3. View the compliance report and use the pagination feature: [GDK_HOST]/groups/gitlab-org/-/security/compliance_dashboard
  4. Create several violations on the same MR by running this in rails console:
FactoryBot.definition_file_paths = [Rails.root.join('ee', 'spec', 'factories')]
FactoryBot.find_definitions

# Group 22 is gitlab-org by default
group = Group.find_by_id(22)

type = [:approved_by_insufficient_users, :approved_by_committer, :approved_by_merge_request_author]

project = group.projects.sample
merge_request = FactoryBot.create(:merge_request, source_project: project, target_project: project, state: :merged)
merge_request.metrics.update!(merged_at: 1.day.ago)

violations = 4.times.map {
  FactoryBot.create(:compliance_violation, type.sample, severity_level: :high, merge_request: merge_request, violating_user: project.members.sample.user)
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Relates to #356691 (closed)

Edited by Jiaan Louw

Merge request reports