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
38916cff
Commit
38916cff
authored
Jan 28, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop syncing approvals_required once feature enabled
as it is no longer needed.
parent
3b9d4255
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
16 deletions
+57
-16
ee/app/services/ee/merge_requests/update_service.rb
ee/app/services/ee/merge_requests/update_service.rb
+1
-0
ee/app/services/ee/projects/update_service.rb
ee/app/services/ee/projects/update_service.rb
+1
-0
ee/spec/services/merge_requests/update_service_spec.rb
ee/spec/services/merge_requests/update_service_spec.rb
+38
-11
ee/spec/services/projects/update_service_spec.rb
ee/spec/services/projects/update_service_spec.rb
+17
-5
No files found.
ee/app/services/ee/merge_requests/update_service.rb
View file @
38916cff
...
...
@@ -47,6 +47,7 @@ module EE
# TODO remove after #1979 is closed
def
sync_approval_rules
(
merge_request
)
return
if
::
Feature
.
enabled?
(
:approval_rules
,
merge_request
.
target_project
)
return
if
merge_request
.
merged?
return
unless
merge_request
.
previous_changes
.
include?
(
:approvals_before_merge
)
...
...
ee/app/services/ee/projects/update_service.rb
View file @
38916cff
...
...
@@ -77,6 +77,7 @@ module EE
# TODO remove after #1979 is closed
def
sync_approval_rules
return
if
::
Feature
.
enabled?
(
:approval_rules
,
project
)
return
unless
project
.
previous_changes
.
include?
(
:approvals_before_merge
)
project
.
approval_rules
.
update_all
(
approvals_required:
project
.
approvals_before_merge
)
...
...
ee/spec/services/merge_requests/update_service_spec.rb
View file @
38916cff
...
...
@@ -60,22 +60,49 @@ describe MergeRequests::UpdateService, :mailer do
context
'when approvals_before_merge changes'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:project_value
,
:mr_before_value
,
:mr_after_value
,
:result
)
do
3
|
4
|
5
|
5
3
|
4
|
nil
|
3
3
|
nil
|
5
|
5
context
'when approval_rules is disabled'
do
before
do
stub_feature_flags
(
approval_rules:
false
)
end
where
(
:project_value
,
:mr_before_value
,
:mr_after_value
,
:result
)
do
3
|
4
|
5
|
5
3
|
4
|
nil
|
3
3
|
nil
|
5
|
5
end
with_them
do
let
(
:project
)
{
create
(
:project
,
:repository
,
approvals_before_merge:
project_value
)
}
it
"updates approval_rules' approvals_required"
do
merge_request
.
update
(
approvals_before_merge:
mr_before_value
)
rule
=
create
(
:approval_merge_request_rule
,
merge_request:
merge_request
)
update_merge_request
(
approvals_before_merge:
mr_after_value
)
expect
(
rule
.
reload
.
approvals_required
).
to
eq
(
result
)
end
end
end
with_them
do
let
(
:project
)
{
create
(
:project
,
:repository
,
approvals_before_merge:
project_value
)
}
context
'when approval_rules is enabled'
do
where
(
:project_value
,
:mr_before_value
,
:mr_after_value
,
:result
)
do
3
|
4
|
5
|
5
3
|
4
|
nil
|
3
3
|
nil
|
5
|
5
end
with_them
do
let
(
:project
)
{
create
(
:project
,
:repository
,
approvals_before_merge:
project_value
)
}
it
"updates approval_rules' approvals_required
"
do
merge_request
.
update
(
approvals_before_merge:
mr_before_value
)
rule
=
create
(
:approval_merge_request_rule
,
merge_request:
merge_request
)
it
"does not update
"
do
merge_request
.
update
(
approvals_before_merge:
mr_before_value
)
rule
=
create
(
:approval_merge_request_rule
,
merge_request:
merge_request
)
update_merge_request
(
approvals_before_merge:
mr_after_value
)
update_merge_request
(
approvals_before_merge:
mr_after_value
)
expect
(
rule
.
reload
.
approvals_required
).
to
eq
(
result
)
expect
(
rule
.
reload
.
approvals_required
).
to
eq
(
0
)
end
end
end
end
...
...
ee/spec/services/projects/update_service_spec.rb
View file @
38916cff
...
...
@@ -230,14 +230,26 @@ describe Projects::UpdateService, '#execute' do
end
context
'with approval_rules'
do
it
"updates approval_rules' approvals_required"
do
stub_feature_flags
(
approval_rules:
false
)
context
'when approval_rules is disabled'
do
it
"updates approval_rules' approvals_required"
do
stub_feature_flags
(
approval_rules:
false
)
rule
=
create
(
:approval_project_rule
,
project:
project
)
rule
=
create
(
:approval_project_rule
,
project:
project
)
update_project
(
project
,
user
,
approvals_before_merge:
42
)
update_project
(
project
,
user
,
approvals_before_merge:
42
)
expect
(
rule
.
reload
.
approvals_required
).
to
eq
(
42
)
expect
(
rule
.
reload
.
approvals_required
).
to
eq
(
42
)
end
end
context
'when approval_rules is enabled'
do
it
'does not update'
do
rule
=
create
(
:approval_project_rule
,
project:
project
)
update_project
(
project
,
user
,
approvals_before_merge:
42
)
expect
(
rule
.
reload
.
approvals_required
).
to
eq
(
0
)
end
end
end
...
...
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