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
5fd5dad4
Commit
5fd5dad4
authored
Jan 13, 2018
by
Akos Gyimesi
Committed by
Nick Thomas
Dec 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error message when attempting to reopen MR and there's a new open MR for the same branch
parent
2e3cefa6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+4
-0
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+12
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
5fd5dad4
...
...
@@ -122,6 +122,10 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
respond_to
do
|
format
|
format
.
html
do
if
merge_request_params
[
:state_event
]
&&
@merge_request
.
errors
.
any?
flash
[
:alert
]
=
@merge_request
.
errors
.
values
.
flatten
.
to_sentence
end
if
@merge_request
.
valid?
redirect_to
([
@merge_request
.
target_project
.
namespace
.
becomes
(
Namespace
),
@merge_request
.
target_project
,
@merge_request
])
else
...
...
app/models/merge_request.rb
View file @
5fd5dad4
...
...
@@ -547,7 +547,7 @@ class MergeRequest < ActiveRecord::Base
similar_mrs
=
similar_mrs
.
where
(
'id not in (?)'
,
self
.
id
)
if
self
.
id
if
similar_mrs
.
any?
errors
.
add
:validate_branches
,
"Cannot
Create: This merge request already exists:
#{
similar_mrs
.
pluck
(
:title
)
}
"
"Cannot
open this Merge Request because another open Merge Request already exists for this source branch:
#{
similar_mrs
.
first
.
title
}
"
end
end
end
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
5fd5dad4
...
...
@@ -290,6 +290,18 @@ describe Projects::MergeRequestsController do
it_behaves_like
'update invalid issuable'
,
MergeRequest
end
context
'there are two merge requests with the same source branch'
do
it
"does not allow to reopen a closed merge request if another one is open"
do
merge_request
.
close!
create
(
:merge_request
,
source_project:
merge_request
.
source_project
,
source_branch:
merge_request
.
source_branch
)
update_merge_request
(
state_event:
'reopen'
)
expect
(
controller
).
to
set_flash
[
:alert
].
to
(
/another open Merge Request already exists for this source branch/
)
expect
(
merge_request
.
reload
).
to
be_closed
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