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
8eba0422
Commit
8eba0422
authored
Jan 24, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix updating approvals count when editing an MR
parent
1473908e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
24 deletions
+75
-24
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+3
-1
changelogs/unreleased-ee/1591_approvals_update_fix.yml
changelogs/unreleased-ee/1591_approvals_update_fix.yml
+4
-0
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+68
-23
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
8eba0422
...
...
@@ -706,8 +706,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
target_project
=
@project
.
forked_from_project
if
@project
.
id
.
to_s
!=
mr_params
[
:target_project_id
]
target_project
||=
@project
# If the number of approvals is not greater than the project default, set to nil,
# so that we fall back to the project default.
if
mr_params
[
:approvals_before_merge
].
to_i
<=
target_project
.
approvals_before_merge
mr_params
.
delete
(
:approvals_before_merge
)
mr_params
[
:approvals_before_merge
]
=
nil
end
mr_params
...
...
changelogs/unreleased-ee/1591_approvals_update_fix.yml
0 → 100644
View file @
8eba0422
---
title
:
Fix updating approvals count when editing an MR
merge_request
:
1106
author
:
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
8eba0422
...
...
@@ -400,6 +400,7 @@ describe Projects::MergeRequestsController do
context
'the approvals_before_merge param'
do
before
{
project
.
update_attributes
(
approvals_before_merge:
2
)
}
context
'approvals_before_merge not set for the existing MR'
do
context
'when it is less than the one in the target project'
do
before
{
update_merge_request
(
approvals_before_merge:
1
)
}
...
...
@@ -439,6 +440,50 @@ describe Projects::MergeRequestsController do
end
end
end
context
'approvals_before_merge set for the existing MR'
do
before
{
merge_request
.
update_attribute
(
:approvals_before_merge
,
4
)
}
context
'when it is less than the one in the target project'
do
before
{
update_merge_request
(
approvals_before_merge:
1
)
}
it
'sets the param to nil'
do
expect
(
merge_request
.
reload
.
approvals_before_merge
).
to
eq
(
nil
)
end
it
'updates the merge request'
do
expect
(
merge_request
.
reload
).
to
be_valid
expect
(
response
).
to
redirect_to
(
namespace_project_merge_request_path
(
id:
merge_request
.
iid
,
project_id:
project
.
to_param
))
end
end
context
'when it is equal to the one in the target project'
do
before
{
update_merge_request
(
approvals_before_merge:
2
)
}
it
'sets the param to nil'
do
expect
(
merge_request
.
reload
.
approvals_before_merge
).
to
eq
(
nil
)
end
it
'updates the merge request'
do
expect
(
merge_request
.
reload
).
to
be_valid
expect
(
response
).
to
redirect_to
(
namespace_project_merge_request_path
(
id:
merge_request
.
iid
,
project_id:
project
.
to_param
))
end
end
context
'when it is greater than the one in the target project'
do
before
{
update_merge_request
(
approvals_before_merge:
3
)
}
it
'saves the param in the merge request'
do
expect
(
merge_request
.
reload
.
approvals_before_merge
).
to
eq
(
3
)
end
it
'updates the merge request'
do
expect
(
merge_request
.
reload
).
to
be_valid
expect
(
response
).
to
redirect_to
(
namespace_project_merge_request_path
(
id:
merge_request
.
iid
,
project_id:
project
.
to_param
))
end
end
end
end
end
describe
'POST merge'
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