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
363339c6
Commit
363339c6
authored
Jan 18, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cap approvals_required at 100
Fix migration to honor this cap
parent
24e9be42
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
1 deletion
+34
-1
ee/app/models/concerns/approval_rule_like.rb
ee/app/models/concerns/approval_rule_like.rb
+2
-0
ee/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb
...ackground_migration/migrate_approver_to_approval_rules.rb
+1
-1
ee/spec/lib/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb
...ound_migration/migrate_approver_to_approval_rules_spec.rb
+12
-0
ee/spec/models/concerns/approval_rule_like_spec.rb
ee/spec/models/concerns/approval_rule_like_spec.rb
+19
-0
No files found.
ee/app/models/concerns/approval_rule_like.rb
View file @
363339c6
...
...
@@ -4,6 +4,7 @@ module ApprovalRuleLike
extend
ActiveSupport
::
Concern
DEFAULT_NAME
=
'Default'
APPROVALS_REQUIRED_MAX
=
100
included
do
has_and_belongs_to_many
:users
...
...
@@ -11,6 +12,7 @@ module ApprovalRuleLike
has_many
:group_users
,
->
{
distinct
},
through: :groups
,
source: :users
validates
:name
,
presence:
true
validates
:approvals_required
,
numericality:
{
less_than_or_equal_to:
APPROVALS_REQUIRED_MAX
}
end
# Users who are eligible to approve, including specified group members.
...
...
ee/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb
View file @
363339c6
...
...
@@ -162,7 +162,7 @@ module Gitlab
unless
rule
.
persisted?
rule
.
name
||=
ApprovalRuleLike
::
DEFAULT_NAME
rule
.
approvals_required
=
target
.
approvals_required
rule
.
approvals_required
=
[
target
.
approvals_required
,
ApprovalRuleLike
::
APPROVALS_REQUIRED_MAX
].
min
rule
.
save!
end
...
...
ee/spec/lib/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb
View file @
363339c6
...
...
@@ -154,6 +154,18 @@ describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do
end
end
context
'when approvals_before_merge is too big'
do
it
"caps at allowed maximum"
do
target
.
target_project
.
update
(
approvals_before_merge:
::
ApprovalRuleLike
::
APPROVALS_REQUIRED_MAX
+
1
)
target
.
update
(
approvals_before_merge:
nil
)
create_member_in
(
create
(
:user
),
:old_schema
)
described_class
.
new
.
perform
(
target_type
,
target
.
id
)
expect
(
target
.
approval_rules
.
regular
.
first
.
approvals_required
).
to
eq
(
::
ApprovalRuleLike
::
APPROVALS_REQUIRED_MAX
)
end
end
context
'when approver is no longer overwritten'
do
before
do
create_member_in
(
create
(
:user
),
:new_schema
)
...
...
ee/spec/models/concerns/approval_rule_like_spec.rb
View file @
363339c6
...
...
@@ -74,6 +74,25 @@ describe ApprovalRuleLike do
end
end
end
describe
'validation'
do
context
'when value is too big'
do
it
'is invalid'
do
subject
.
approvals_required
=
described_class
::
APPROVALS_REQUIRED_MAX
+
1
expect
(
subject
).
to
be_invalid
expect
(
subject
.
errors
.
key?
(
:approvals_required
)).
to
eq
(
true
)
end
end
context
'when value is within limit'
do
it
'is valid'
do
subject
.
approvals_required
=
described_class
::
APPROVALS_REQUIRED_MAX
expect
(
subject
).
to
be_valid
end
end
end
end
context
'MergeRequest'
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