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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
81da7f13
Commit
81da7f13
authored
Sep 05, 2016
by
Katarzyna Kobierska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test checking method closed_without_source_project
parent
31c37c6c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
6 deletions
+38
-6
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+0
-6
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+38
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
81da7f13
...
...
@@ -428,17 +428,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def
validates_merge_request
# If source project was removed (Ex. mr from fork to origin)
# return invalid_mr unless @merge_request.source_project
# Show git not found page
# if there is no saved commits between source & target branch
if
@merge_request
.
commits
.
blank?
# and if target branch doesn't exist
return
invalid_mr
unless
@merge_request
.
target_branch_exists?
# or if source branch doesn't exist
# return invalid_mr unless @merge_request.source_branch_exists?
end
end
...
...
spec/models/merge_request_spec.rb
View file @
81da7f13
...
...
@@ -1038,4 +1038,42 @@ describe MergeRequest, models: true do
end
end
end
describe
"#closed_without_source_project?"
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:fork_project
)
{
create
(
:project
,
forked_from_project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:destroy_project
)
{
Projects
::
DestroyService
.
new
(
fork_project
,
user
,
{})
}
context
"when the merge request is closed"
do
let
(
:closed_merge_request
)
do
create
(
:closed_merge_request
,
source_project:
fork_project
,
target_project:
project
)
end
it
"returns false if the source project exist"
do
expect
(
closed_merge_request
.
closed_without_source_project?
).
to
be_falsey
end
it
"returns true if the source project does not exist"
do
destroy_project
.
async_execute
closed_merge_request
.
reload
expect
(
closed_merge_request
.
closed_without_source_project?
).
to
be_truthy
end
end
context
"when the merge request is open"
do
let
(
:open_merge_request
)
do
create
(
:merge_request
,
source_project:
fork_project
,
target_project:
project
)
end
it
"returns false"
do
expect
(
open_merge_request
.
closed_without_source_project?
).
to
be_falsey
end
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