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
Boxiang Sun
gitlab-ce
Commits
2e08f115
Commit
2e08f115
authored
Aug 09, 2016
by
Katarzyna Kobierska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code
parent
c9c2503c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
40 deletions
+64
-40
app/views/shared/issuable/_form.html.haml
app/views/shared/issuable/_form.html.haml
+20
-21
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+16
-4
spec/views/projects/merge_requests/edit.html.haml_spec.rb
spec/views/projects/merge_requests/edit.html.haml_spec.rb
+21
-9
spec/views/projects/merge_requests/show.html.haml_spec.rb
spec/views/projects/merge_requests/show.html.haml_spec.rb
+7
-6
No files found.
app/views/shared/issuable/_form.html.haml
View file @
2e08f115
...
@@ -134,8 +134,7 @@
...
@@ -134,8 +134,7 @@
title:
'Moving an issue will copy the discussion to a different project and close it here. All participants will be notified of the new location.'
}
title:
'Moving an issue will copy the discussion to a different project and close it here. All participants will be notified of the new location.'
}
=
icon
(
'question-circle'
)
=
icon
(
'question-circle'
)
-
if
issuable
.
is_a?
(
MergeRequest
)
-
if
issuable
.
is_a?
(
MergeRequest
)
&&
!
@merge_request
.
closed_without_fork?
-
unless
@merge_request
.
closed_without_fork?
%hr
%hr
-
if
@merge_request
.
new_record?
-
if
@merge_request
.
new_record?
.form-group
.form-group
...
...
spec/models/merge_request_spec.rb
View file @
2e08f115
...
@@ -992,7 +992,7 @@ describe MergeRequest, models: true do
...
@@ -992,7 +992,7 @@ describe MergeRequest, models: true do
target_project:
project
)
target_project:
project
)
end
end
it
do
it
"returns true"
do
unlink_project
.
execute
unlink_project
.
execute
merge_request
.
reload
merge_request
.
reload
...
@@ -1007,23 +1007,35 @@ describe MergeRequest, models: true do
...
@@ -1007,23 +1007,35 @@ describe MergeRequest, models: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:unlink_project
)
{
Projects
::
UnlinkForkService
.
new
(
fork_project
,
user
)
}
let
(
:unlink_project
)
{
Projects
::
UnlinkForkService
.
new
(
fork_project
,
user
)
}
context
"
closed MR
"
do
context
"
when merge request is closed
"
do
let
(
:closed_merge_request
)
do
let
(
:closed_merge_request
)
do
create
(
:closed_merge_request
,
create
(
:closed_merge_request
,
source_project:
fork_project
,
source_project:
fork_project
,
target_project:
project
)
target_project:
project
)
end
end
it
"
has a fork
"
do
it
"
returns false if fork exist
"
do
expect
(
closed_merge_request
.
closed_without_fork?
).
to
be_falsey
expect
(
closed_merge_request
.
closed_without_fork?
).
to
be_falsey
end
end
it
"
does not have a fork
"
do
it
"
returns true if fork doesn't exist
"
do
unlink_project
.
execute
unlink_project
.
execute
closed_merge_request
.
reload
closed_merge_request
.
reload
expect
(
closed_merge_request
.
closed_without_fork?
).
to
be_truthy
expect
(
closed_merge_request
.
closed_without_fork?
).
to
be_truthy
end
end
end
end
context
"when 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_fork?
).
to
be_falsey
end
end
end
end
end
end
spec/views/projects/merge_requests/edit.html.haml_spec.rb
View file @
2e08f115
...
@@ -6,36 +6,48 @@ describe 'projects/merge_requests/edit.html.haml' do
...
@@ -6,36 +6,48 @@ describe 'projects/merge_requests/edit.html.haml' do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:fork_project
)
{
create
(
:project
,
forked_from_project:
project
)
}
let
(
:fork_project
)
{
create
(
:project
,
forked_from_project:
project
)
}
let
(
:unlink_project
)
{
Projects
::
UnlinkForkService
.
new
(
fork_project
,
user
)
}
let
(
:closed_merge_request
)
do
let
(
:closed_merge_request
)
do
create
(
:closed_merge_request
,
create
(
:closed_merge_request
,
source_project:
fork_project
,
source_project:
fork_project
,
target_project:
project
,
target_project:
project
,
author:
user
)
author:
user
)
end
end
let
(
:unlink_project
)
{
Projects
::
UnlinkForkService
.
new
(
fork_project
,
user
)
}
before
do
before
do
assign
(
:project
,
project
)
assign
(
:project
,
project
)
assign
(
:merge_request
,
closed_merge_request
)
assign
(
:merge_request
,
closed_merge_request
)
allow
(
view
).
to
receive
(
:can?
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:can?
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
User
.
find
(
closed_merge_request
.
author_id
))
allow
(
view
).
to
receive
(
:current_user
)
.
and_return
(
User
.
find
(
closed_merge_request
.
author_id
))
end
end
context
'when closed
MR
without fork'
do
context
'when closed
merge request
without fork'
do
it
"shows editable fields"
do
it
"shows editable fields"
do
unlink_project
.
execute
unlink_project
.
execute
closed_merge_request
.
reload
closed_merge_request
.
reload
render
expect
(
rendered
).
to
have_field
(
'merge_request[title]'
)
expect
(
rendered
).
to
have_field
(
'merge_request[description]'
)
expect
(
rendered
).
to
have_selector
(
'#merge_request_assignee_id'
,
visible:
false
)
expect
(
rendered
).
to
have_selector
(
'#merge_request_milestone_id'
,
visible:
false
)
expect
(
rendered
).
not_to
have_selector
(
'#merge_request_target_branch'
,
visible:
false
)
end
end
context
'when closed merge request with fork'
do
it
"shows editable fields"
do
render
render
expect
(
rendered
).
to
have_field
(
'merge_request[title]'
)
expect
(
rendered
).
to
have_field
(
'merge_request[title]'
)
expect
(
rendered
).
to
have_css
(
'label'
,
text:
"Title"
)
expect
(
rendered
).
to
have_field
(
'merge_request[description]'
)
expect
(
rendered
).
to
have_field
(
'merge_request[description]'
)
expect
(
rendered
).
to
have_css
(
'label'
,
text:
"Description"
)
expect
(
rendered
).
to
have_selector
(
'#merge_request_assignee_id'
,
visible:
false
)
expect
(
rendered
).
to
have_css
(
'label'
,
text:
"Assignee"
)
expect
(
rendered
).
to
have_selector
(
'#merge_request_milestone_id'
,
visible:
false
)
expect
(
rendered
).
to
have_css
(
'label'
,
text:
"Milestone"
)
expect
(
rendered
).
to
have_selector
(
'#merge_request_target_branch'
,
visible:
false
)
expect
(
rendered
).
to
have_css
(
'label'
,
text:
"Labels"
)
expect
(
rendered
).
not_to
have_css
(
'label'
,
text:
"Target branch"
)
end
end
end
end
end
end
spec/views/projects/merge_requests/show.html.haml_spec.rb
View file @
2e08f115
...
@@ -5,23 +5,24 @@ describe 'projects/merge_requests/show.html.haml' do
...
@@ -5,23 +5,24 @@ describe 'projects/merge_requests/show.html.haml' do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:fork_project
)
{
create
(
:project
,
forked_from_project:
project
)
}
let
(
:fork_project
)
{
create
(
:project
,
forked_from_project:
project
)
}
let
(
:merge_request
)
do
create
(
:merge_request
,
let
(
:closed_merge_request
)
do
create
(
:closed_merge_request
,
source_project:
fork_project
,
source_project:
fork_project
,
source_branch:
'add-submodule-version-bump'
,
source_branch:
'add-submodule-version-bump'
,
target_branch:
'master'
,
target_project:
project
)
target_branch:
'master'
,
target_project:
project
)
end
end
before
do
before
do
assign
(
:project
,
project
)
assign
(
:project
,
project
)
assign
(
:merge_request
,
merge_request
)
assign
(
:merge_request
,
closed_
merge_request
)
assign
(
:commits_count
,
0
)
assign
(
:commits_count
,
0
)
merge_request
.
close!
allow
(
view
).
to
receive
(
:can?
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:can?
).
and_return
(
true
)
end
end
context
'
closed MR
'
do
context
'
when merge request is closed
'
do
it
'shows Reopen button'
do
it
'shows Reopen button'
do
render
render
...
...
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