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
66e92895
Commit
66e92895
authored
Sep 13, 2016
by
Katarzyna Kobierska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change method name to #reopenable?
parent
34586c18
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
app/models/merge_request.rb
app/models/merge_request.rb
+3
-2
app/views/projects/merge_requests/_discussion.html.haml
app/views/projects/merge_requests/_discussion.html.haml
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+9
-9
No files found.
app/models/merge_request.rb
View file @
66e92895
...
...
@@ -327,9 +327,10 @@ class MergeRequest < ActiveRecord::Base
!
source_project
.
forked_from?
(
target_project
)
end
def
can_reopen
?
def
reopenable
?
return
false
if
closed_without_fork?
||
closed_without_source_project?
||
merged?
return
true
if
closed?
closed?
end
def
ensure_merge_request_diff
...
...
app/views/projects/merge_requests/_discussion.html.haml
View file @
66e92895
...
...
@@ -2,7 +2,7 @@
-
if
can?
(
current_user
,
:update_merge_request
,
@merge_request
)
-
if
@merge_request
.
open?
=
link_to
'Close merge request'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :close
}),
method: :put
,
class:
"btn btn-nr btn-comment btn-close close-mr-link js-note-target-close"
,
title:
"Close merge request"
,
data:
{
original_text:
"Close merge request"
,
alternative_text:
"Comment & close merge request"
}
-
if
@merge_request
.
can_reopen
?
-
if
@merge_request
.
reopenable
?
=
link_to
'Reopen merge request'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
}),
method: :put
,
class:
"btn btn-nr btn-comment btn-reopen reopen-mr-link js-note-target-reopen"
,
title:
"Reopen merge request"
,
data:
{
original_text:
"Reopen merge request"
,
alternative_text:
"Comment & reopen merge request"
}
%comment-and-resolve-btn
{
"inline-template"
=>
true
,
":discussion-id"
=>
""
}
%button
.btn.btn-nr.btn-default.append-right-10.js-comment-resolve-button
{
"v-if"
=>
"showButton"
,
type:
"submit"
,
data:
{
namespace_path:
"#{@merge_request.project.namespace.path}"
,
project_path:
"#{@merge_request.project.path}"
}
}
...
...
spec/models/merge_request_spec.rb
View file @
66e92895
...
...
@@ -1043,7 +1043,7 @@ describe MergeRequest, models: true do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:fork_project
)
{
create
(
:project
,
forked_from_project:
project
,
namespace:
user
.
namespace
)
}
let
(
:destroy_
project
)
{
Projects
::
DestroyService
.
new
(
fork_project
,
user
,
{}
)
}
let
(
:destroy_
service
)
{
Projects
::
DestroyService
.
new
(
fork_project
,
user
)
}
context
'when the merge request is closed'
do
let
(
:closed_merge_request
)
do
...
...
@@ -1057,7 +1057,7 @@ describe MergeRequest, models: true do
end
it
'returns true if the source project does not exist'
do
destroy_
project
.
execute
destroy_
service
.
execute
closed_merge_request
.
reload
expect
(
closed_merge_request
.
closed_without_source_project?
).
to
be_truthy
...
...
@@ -1071,12 +1071,12 @@ describe MergeRequest, models: true do
end
end
describe
'#
can_reopen
?'
do
describe
'#
reopenable
?'
do
context
'when the merge request is closed'
do
it
'returns true'
do
subject
.
close
expect
(
subject
.
can_reopen
?
).
to
be_truthy
expect
(
subject
.
reopenable
?
).
to
be_truthy
end
context
'forked project'
do
...
...
@@ -1092,26 +1092,26 @@ describe MergeRequest, models: true do
it
'returns false if unforked'
do
Projects
::
UnlinkForkService
.
new
(
fork_project
,
user
).
execute
expect
(
merge_request
.
reload
.
can_reopen
?
).
to
be_falsey
expect
(
merge_request
.
reload
.
reopenable
?
).
to
be_falsey
end
it
'returns false if the source project is deleted'
do
Projects
::
DestroyService
.
new
(
fork_project
,
user
,
{}
).
execute
Projects
::
DestroyService
.
new
(
fork_project
,
user
).
execute
expect
(
merge_request
.
reload
.
can_reopen
?
).
to
be_falsey
expect
(
merge_request
.
reload
.
reopenable
?
).
to
be_falsey
end
it
'returns false if the merge request is merged'
do
merge_request
.
update_attributes
(
state:
'merged'
)
expect
(
merge_request
.
reload
.
can_reopen
?
).
to
be_falsey
expect
(
merge_request
.
reload
.
reopenable
?
).
to
be_falsey
end
end
end
context
'when the merge request is opened'
do
it
'returns false'
do
expect
(
subject
.
can_reopen
?
).
to
be_falsey
expect
(
subject
.
reopenable
?
).
to
be_falsey
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