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
476cf23f
Commit
476cf23f
authored
Apr 11, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to close invalid merge request
parent
4d04e918
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
5 deletions
+41
-5
app/models/commit.rb
app/models/commit.rb
+5
-3
app/models/merge_request.rb
app/models/merge_request.rb
+7
-2
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+29
-0
No files found.
app/models/commit.rb
View file @
476cf23f
...
...
@@ -150,13 +150,11 @@ class Commit
end
def
hook_attrs
(
with_changed_files:
false
)
path_with_namespace
=
project
.
path_with_namespace
data
=
{
id:
id
,
message:
safe_message
,
timestamp:
committed_date
.
xmlschema
,
url:
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
path_with_namespace
}
/commit/
#{
id
}
"
,
url:
commit_url
,
author:
{
name:
author_name
,
email:
author_email
...
...
@@ -170,6 +168,10 @@ class Commit
data
end
def
commit_url
project
.
present?
?
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
path_with_namespace
}
/commit/
#{
id
}
"
:
""
end
# Discover issues should be closed when this commit is pushed to a project's
# default branch.
def
closes_issues
(
current_user
=
self
.
committer
)
...
...
app/models/merge_request.rb
View file @
476cf23f
...
...
@@ -213,6 +213,8 @@ class MergeRequest < ActiveRecord::Base
end
def
validate_branches
return
if
allow_broken
if
target_project
==
source_project
&&
target_branch
==
source_branch
errors
.
add
:branch_conflict
,
"You can not use same project/branch for source and target"
end
...
...
@@ -344,9 +346,12 @@ class MergeRequest < ActiveRecord::Base
end
def
hook_attrs
source_hook_attrs
=
source_project
.
hook_attrs
if
source_project
.
present?
target_hook_attrs
=
target_project
.
hook_attrs
if
target_project
.
present?
attrs
=
{
source:
source_
project
.
hook_attrs
,
target:
target_
project
.
hook_attrs
,
source:
source_hook_attrs
,
target:
target_hook_attrs
,
last_commit:
nil
,
work_in_progress:
work_in_progress?
}
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
476cf23f
...
...
@@ -157,6 +157,35 @@ describe Projects::MergeRequestsController do
end
end
describe
'PUT #update'
do
context
'there is no source project'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:fork_project
)
{
create
(
:forked_project_with_submodules
)
}
let
(
:merge_request
)
{
create
(
:merge_request_with_diffs
,
source_project:
fork_project
,
source_branch:
'add-submodule-version-bump'
,
target_branch:
'master'
,
target_project:
project
)
}
before
do
fork_project
.
build_forked_project_link
(
forked_to_project_id:
fork_project
.
id
,
forked_from_project_id:
project
.
id
)
fork_project
.
save
merge_request
.
reload
end
it
'closes MR without errors'
do
fork_project
.
destroy
post
:update
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
merge_request
.
iid
,
merge_request:
{
state_event:
'close'
}
expect
(
response
).
to
redirect_to
([
merge_request
.
target_project
.
namespace
.
becomes
(
Namespace
),
merge_request
.
target_project
,
merge_request
])
expect
(
merge_request
.
reload
.
closed?
).
to
be_truthy
end
end
end
describe
"DELETE #destroy"
do
it
"denies access to users unless they're admin or project owner"
do
delete
:destroy
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
merge_request
.
iid
...
...
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