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
f8211588
Commit
f8211588
authored
Mar 08, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build link to discussions to resolve in a helper
parent
9709309e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
3 deletions
+48
-3
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+14
-0
app/views/shared/issuable/_form.html.haml
app/views/shared/issuable/_form.html.haml
+2
-3
spec/helpers/issues_helper_spec.rb
spec/helpers/issues_helper_spec.rb
+32
-0
No files found.
app/helpers/issues_helper.rb
View file @
f8211588
...
@@ -134,6 +134,20 @@ module IssuesHelper
...
@@ -134,6 +134,20 @@ module IssuesHelper
options_from_collection_for_select
(
options
,
'name'
,
'title'
,
params
[
:due_date
])
options_from_collection_for_select
(
options
,
'name'
,
'title'
,
params
[
:due_date
])
end
end
def
link_to_discussions_to_resolve
(
merge_request
,
single_discussion
)
link_text
=
merge_request
.
to_reference
link_text
+=
" (discussion
#{
single_discussion
.
first_note
.
id
}
)"
if
single_discussion
path
=
if
single_discussion
Gitlab
::
UrlBuilder
.
build
(
single_discussion
.
first_note
)
else
project
=
merge_request
.
project
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
link_to
link_text
,
path
end
# Required for Banzai::Filter::IssueReferenceFilter
# Required for Banzai::Filter::IssueReferenceFilter
module_function
:url_for_issue
module_function
:url_for_issue
end
end
app/views/shared/issuable/_form.html.haml
View file @
f8211588
...
@@ -54,13 +54,12 @@
...
@@ -54,13 +54,12 @@
-
if
@discussion_to_resolve
-
if
@discussion_to_resolve
=
hidden_field_tag
'discussion_to_resolve'
,
@discussion_to_resolve
.
id
=
hidden_field_tag
'discussion_to_resolve'
,
@discussion_to_resolve
.
id
Creating this issue will resolve the discussion in
Creating this issue will resolve the discussion in
=
link_to
"
#{
@merge_request_for_resolving_discussions
.
to_reference
}
(discussion
#{
@discussion_to_resolve
.
first_note
.
id
}
)"
,
Gitlab
::
UrlBuilder
.
build
(
@discussion_to_resolve
.
first_note
)
-
else
-
else
Creating this issue will resolve all discussions in
Creating this issue will resolve all discussions in
=
link_to
@merge_request_for_resolving_discussions
.
to_reference
,
merge_request_path
(
@merge_request_for_resolving_discussions
)
=
link_to_discussions_to_resolve
(
@merge_request_for_resolving_discussions
,
@discussion_to_resolve
)
-
else
-
else
The discussion at
The discussion at
=
link_to
@merge_request_for_resolving_discussions
.
to_reference
,
merge_request_path
(
@merge_request_for_resolving_discussions
)
=
link_to
_discussions_to_resolve
(
@merge_request_for_resolving_discussions
,
@discussion_to_resolve
)
will stay unresolved. Ask someone with permission to resolve it.
will stay unresolved. Ask someone with permission to resolve it.
-
is_footer
=
!
(
issuable
.
is_a?
(
MergeRequest
)
&&
issuable
.
new_record?
)
-
is_footer
=
!
(
issuable
.
is_a?
(
MergeRequest
)
&&
issuable
.
new_record?
)
...
...
spec/helpers/issues_helper_spec.rb
View file @
f8211588
...
@@ -131,4 +131,36 @@ describe IssuesHelper do
...
@@ -131,4 +131,36 @@ describe IssuesHelper do
expect
(
options
).
to
have_selector
(
'option'
,
text:
milestone2
.
title
)
expect
(
options
).
to
have_selector
(
'option'
,
text:
milestone2
.
title
)
end
end
end
end
describe
"#link_to_discussions_to_resolve"
do
describe
"passing only a merge request"
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
it
"links just the merge request"
do
expected_path
=
namespace_project_merge_request_path
(
merge_request
.
project
.
namespace
,
merge_request
.
project
,
merge_request
)
expect
(
link_to_discussions_to_resolve
(
merge_request
,
nil
)).
to
include
(
expected_path
)
end
it
"containst the reference to the merge request"
do
expect
(
link_to_discussions_to_resolve
(
merge_request
,
nil
)).
to
include
(
merge_request
.
to_reference
)
end
end
describe
"when passing a discussion"
do
let
(
:diff_note
)
{
create
(
:diff_note_on_merge_request
)
}
let
(
:merge_request
)
{
diff_note
.
noteable
}
let
(
:discussion
)
{
Discussion
.
new
([
diff_note
])
}
it
"links to the merge request with first note if a single discussion was passed"
do
expected_path
=
Gitlab
::
UrlBuilder
.
build
(
diff_note
)
expect
(
link_to_discussions_to_resolve
(
merge_request
,
discussion
)).
to
include
(
expected_path
)
end
it
"contains both the reference to the merge request and a mention of the discussion"
do
expect
(
link_to_discussions_to_resolve
(
merge_request
,
discussion
)).
to
include
(
"
#{
merge_request
.
to_reference
}
(discussion
#{
diff_note
.
id
}
)"
)
end
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