Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6699141e
Commit
6699141e
authored
Mar 05, 2020
by
Tan Le
Committed by
Dmytro Zaporozhets
Mar 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Audit number of required approvals changes at project level
parent
2e08c928
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
1 deletion
+75
-1
doc/administration/audit_events.md
doc/administration/audit_events.md
+1
-0
ee/app/services/concerns/approval_rules/updater.rb
ee/app/services/concerns/approval_rules/updater.rb
+13
-0
ee/changelogs/unreleased/7531-audit-approval-list-changes.yml
...hangelogs/unreleased/7531-audit-approval-list-changes.yml
+5
-0
ee/spec/services/approval_rules/update_service_spec.rb
ee/spec/services/approval_rules/update_service_spec.rb
+56
-1
No files found.
doc/administration/audit_events.md
View file @
6699141e
...
...
@@ -81,6 +81,7 @@ From there, you can see the following actions:
-
Release milestone associations changed
-
Permission to approve merge requests by committers was updated (
[
introduced
](
https://gitlab.com/gitlab-org/gitlab/issues/7531
)
in GitLab 12.9)
-
Permission to approve merge requests by authors was updated (
[
introduced
](
https://gitlab.com/gitlab-org/gitlab/issues/7531
)
in GitLab 12.9)
-
Number of required approvals was updated (
[
introduced
](
https://gitlab.com/gitlab-org/gitlab/issues/7531
)
in GitLab 12.9)
### Instance events **(PREMIUM ONLY)**
...
...
ee/app/services/concerns/approval_rules/updater.rb
View file @
6699141e
...
...
@@ -2,13 +2,17 @@
module
ApprovalRules
module
Updater
include
EE
::
Audit
::
Changes
# rubocop: disable Cop/InjectEnterpriseEditionModule
def
action
filter_eligible_users!
filter_eligible_groups!
filter_eligible_protected_branches!
if
rule
.
update
(
params
)
log_audit_event
(
rule
)
rule
.
reset
success
else
error
(
rule
.
errors
.
messages
)
...
...
@@ -41,5 +45,14 @@ module ApprovalRules
.
id_in
(
protected_branch_ids
)
.
for_project
(
project
)
end
def
log_audit_event
(
rule
)
audit_changes
(
:approvals_required
,
as:
'number of required approvals'
,
entity:
rule
.
project
,
model:
rule
)
end
end
end
ee/changelogs/unreleased/7531-audit-approval-list-changes.yml
0 → 100644
View file @
6699141e
---
title
:
Audit number of required approvals changes
merge_request
:
7531
author
:
type
:
added
ee/spec/services/approval_rules/update_service_spec.rb
View file @
6699141e
...
...
@@ -5,7 +5,7 @@ require 'spec_helper'
describe
ApprovalRules
::
UpdateService
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
project
.
creator
}
let
(
:approval_rule
)
{
target
.
approval_rules
.
create
(
name:
'foo'
)
}
let
(
:approval_rule
)
{
target
.
approval_rules
.
create
(
name:
'foo'
,
approvals_required:
2
)
}
shared_examples
'editable'
do
let
(
:new_approvers
)
{
create_list
(
:user
,
2
)
}
...
...
@@ -190,6 +190,61 @@ describe ApprovalRules::UpdateService do
end
end
end
describe
'audit events'
do
subject
(
:operation
)
do
described_class
.
new
(
approval_rule
,
user
,
name:
'developers'
,
approvals_required:
1
).
execute
end
context
'when licensed'
do
before
do
stub_licensed_features
(
audit_events:
true
)
end
context
'when rule update operation succeeds'
do
it
'logs an audit event'
do
expect
{
operation
}.
to
change
{
AuditEvent
.
count
}.
by
(
1
)
end
it
'logs the audit event info'
do
operation
expect
(
AuditEvent
.
last
).
to
have_attributes
(
details:
hash_including
(
change:
'number of required approvals'
,
from:
2
,
to:
1
)
)
end
end
context
'when rule update operation fails'
do
before
do
allow
(
approval_rule
).
to
receive
(
:update
).
and_return
(
false
)
end
it
'does not log any audit event'
do
expect
{
operation
}.
not_to
change
{
AuditEvent
.
count
}
end
end
end
context
'when not licensed'
do
before
do
stub_licensed_features
(
admin_audit_log:
false
,
audit_events:
false
,
extended_audit_events:
false
)
end
it
'does not log any audit event'
do
expect
{
operation
}.
not_to
change
{
AuditEvent
.
count
}
end
end
end
end
context
'when target is merge request'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment