Commit 0840cf9e authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'nicolasdular/record-approval-rule' into 'master'

Record onboarding action for MR approval rule

See merge request gitlab-org/gitlab!51987
parents c5d95891 4e1dfeda
...@@ -23,6 +23,12 @@ module ApprovalRules ...@@ -23,6 +23,12 @@ module ApprovalRules
super(@rule.project, user, params) super(@rule.project, user, params)
end end
def success
track_onboarding_progress
super
end
private private
def copy_approval_project_rule_properties(params) def copy_approval_project_rule_properties(params)
...@@ -59,5 +65,9 @@ module ApprovalRules ...@@ -59,5 +65,9 @@ module ApprovalRules
def approvers_present? def approvers_present?
%i(user_ids group_ids users groups).any? { |key| @params[key].present? } %i(user_ids group_ids users groups).any? { |key| @params[key].present? }
end end
def track_onboarding_progress
OnboardingProgressService.new(rule.project.namespace).execute(action: :required_mr_approvals_enabled)
end
end end
end end
...@@ -62,6 +62,15 @@ RSpec.describe ApprovalRules::CreateService do ...@@ -62,6 +62,15 @@ RSpec.describe ApprovalRules::CreateService do
expect(result[:status]).to eq(:error) expect(result[:status]).to eq(:error)
end end
it_behaves_like 'does not record an onboarding progress action' do
subject do
described_class.new(target, user, {
name: nil,
approvals_required: 1
}).execute
end
end
end end
context 'when user does not have right to admin project' do context 'when user does not have right to admin project' do
...@@ -114,6 +123,19 @@ RSpec.describe ApprovalRules::CreateService do ...@@ -114,6 +123,19 @@ RSpec.describe ApprovalRules::CreateService do
expect { subject.execute }.not_to change(target.approval_rules.any_approver, :count) expect { subject.execute }.not_to change(target.approval_rules.any_approver, :count)
end end
end end
it_behaves_like 'records an onboarding progress action', :required_mr_approvals_enabled do
let(:namespace) { project.namespace }
subject do
described_class.new(target, user, {
name: 'security',
approvals_required: 1,
user_ids: new_approvers.map(&:id),
group_ids: new_groups.map(&:id)
}).execute
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