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
Kazuhiko Shiozaki
gitlab-ce
Commits
94a788f6
Commit
94a788f6
authored
Oct 13, 2015
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only accept open issues and merge requests
parent
9f9f0c35
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
19 deletions
+62
-19
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-1
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+1
-1
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+4
-0
app/models/issue.rb
app/models/issue.rb
+5
-5
app/models/merge_request.rb
app/models/merge_request.rb
+0
-4
app/views/projects/issues/_closed_by_box.html.haml
app/views/projects/issues/_closed_by_box.html.haml
+3
-6
app/views/projects/issues/show.html.haml
app/views/projects/issues/show.html.haml
+1
-1
spec/helpers/issues_helper_spec.rb
spec/helpers/issues_helper_spec.rb
+10
-0
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+0
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+37
-0
No files found.
app/controllers/projects/issues_controller.rb
View file @
94a788f6
...
...
@@ -116,7 +116,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
def
closed_by_merge_requests
@closed_by_m
r
=
@issue
.
closed_by_merge_requests
(
current_user
)
@closed_by_m
erge_requests
||
=
@issue
.
closed_by_merge_requests
(
current_user
)
end
protected
...
...
app/helpers/issues_helper.rb
View file @
94a788f6
...
...
@@ -84,7 +84,7 @@ module IssuesHelper
end
def
merge_requests_sentence
(
merge_requests
)
merge_requests
.
map
(
&
:to_reference
).
to_sentence
merge_requests
.
map
(
&
:to_reference
).
to_sentence
(
last_word_connector:
', or '
)
end
# Required for Gitlab::Markdown::IssueReferenceFilter
...
...
app/models/concerns/issuable.rb
View file @
94a788f6
...
...
@@ -86,6 +86,10 @@ module Issuable
assignee_id_changed?
end
def
open?
opened?
||
reopened?
end
#
# Votes
#
...
...
app/models/issue.rb
View file @
94a788f6
...
...
@@ -98,11 +98,11 @@ class Issue < ActiveRecord::Base
# From all notes on this issue, we'll select the system notes about linked
# merge requests. Of those, the MRs closing `self` are returned.
def
closed_by_merge_requests
(
current_user
)
def
closed_by_merge_requests
(
current_user
=
nil
)
return
[]
unless
open
?
notes
.
system
.
flat_map
do
|
note
|
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
self
.
project
,
current_user
)
ext
.
analyze
(
note
.
note
)
ext
.
merge_requests
end
.
uniq
.
select
{
|
mr
|
mr
.
closes_issue?
(
self
)
}
note
.
all_references
(
current_user
).
merge_requests
end
.
uniq
.
select
{
|
mr
|
mr
.
open?
&&
mr
.
closes_issue?
(
self
)
}
end
end
app/models/merge_request.rb
View file @
94a788f6
...
...
@@ -222,10 +222,6 @@ class MergeRequest < ActiveRecord::Base
self
.
target_project
.
events
.
where
(
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
action:
Event
::
CLOSED
).
last
end
def
open?
opened?
||
reopened?
end
def
work_in_progress?
!!
(
title
=~
/\A\[?WIP\]?:? /i
)
end
...
...
app/views/projects/issues/_closed_by_box.html.haml
View file @
94a788f6
.issue-closed-by-widget
%i
.fa.fa-check
-
if
@closed_by_mr
.
count
==
1
This issue will be closed when
#{
gfm
(
@closed_by_mr
.
first
.
to_reference
)
}
is accepted.
-
else
This issue will be closed when any of merge requests
#{
gfm
(
merge_requests_sentence
(
@closed_by_mr
.
sort
))
}
is accepted.
=
icon
(
'check'
)
This issue will be closed automatically when merge request
#{
gfm
(
merge_requests_sentence
(
@closed_by_merge_requests
.
sort
))
}
is accepted.
app/views/projects/issues/show.html.haml
View file @
94a788f6
...
...
@@ -46,7 +46,7 @@
=
markdown
(
@issue
.
description
)
%textarea
.hidden.js-task-list-field
=
@issue
.
description
-
if
@closed_by_m
r
.
present?
-
if
@closed_by_m
erge_requests
.
present?
=
render
'projects/issues/closed_by_box'
.issue-discussion
=
render
'projects/issues/discussion'
spec/helpers/issues_helper_spec.rb
View file @
94a788f6
...
...
@@ -117,4 +117,14 @@ describe IssuesHelper do
end
end
describe
"#merge_requests_sentence"
do
subject
{
merge_requests_sentence
(
merge_requests
)}
let
(
:merge_requests
)
do
[
build
(
:merge_request
,
iid:
1
),
build
(
:merge_request
,
iid:
2
),
build
(
:merge_request
,
iid:
3
)]
end
it
{
is_expected
.
to
eq
(
"!1, !2, or !3"
)
}
end
end
spec/models/concerns/issuable_spec.rb
View file @
94a788f6
...
...
@@ -68,7 +68,6 @@ describe Issue, "Issuable" do
end
end
describe
"#to_hook_data"
do
let
(
:hook_data
)
{
issue
.
to_hook_data
(
user
)
}
...
...
spec/models/issue_spec.rb
View file @
94a788f6
...
...
@@ -68,6 +68,43 @@ describe Issue do
end
end
describe
'#closed_by_merge_requests'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
state:
"opened"
)}
let
(
:closed_issue
)
{
build
(
:issue
,
project:
project
,
state:
"closed"
)}
let
(
:mr
)
do
opts
=
{
title:
'Awesome merge_request'
,
description:
"Fixes
#{
issue
.
to_reference
}
"
,
source_branch:
'feature'
,
target_branch:
'master'
}
MergeRequests
::
CreateService
.
new
(
project
,
project
.
owner
,
opts
).
execute
end
let
(
:closed_mr
)
do
opts
=
{
title:
'Awesome merge_request 2'
,
description:
"Fixes
#{
issue
.
to_reference
}
"
,
source_branch:
'feature'
,
target_branch:
'master'
,
state:
'closed'
}
MergeRequests
::
CreateService
.
new
(
project
,
project
.
owner
,
opts
).
execute
end
it
'returns the merge request to close this issue'
do
allow
(
mr
).
to
receive
(
:closes_issue?
).
with
(
issue
).
and_return
(
true
)
expect
(
issue
.
closed_by_merge_requests
).
to
eq
([
mr
])
end
it
"returns an empty array when the current issue is closed already"
do
expect
(
closed_issue
.
closed_by_merge_requests
).
to
eq
([])
end
end
it_behaves_like
'an editable mentionable'
do
subject
{
create
(
:issue
)
}
...
...
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