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
2f5ba074
Commit
2f5ba074
authored
Mar 31, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build issues for merge request when there is an issue template
parent
37a1fd6d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+0
-5
app/services/issues/build_service.rb
app/services/issues/build_service.rb
+10
-1
spec/services/issues/build_service_spec.rb
spec/services/issues/build_service_spec.rb
+23
-0
No files found.
app/controllers/projects/issues_controller.rb
View file @
2f5ba074
...
...
@@ -77,11 +77,6 @@ class Projects::IssuesController < Projects::ApplicationController
@merge_request_to_resolve_discussions_of
=
service
.
merge_request_to_resolve_discussions_of
@discussion_to_resolve
=
service
.
discussions_to_resolve
.
first
if
params
[
:discussion_to_resolve
]
# Set Issue description based on project template
if
@project
.
issues_template
.
present?
@issue
.
description
=
@project
.
issues_template
end
respond_with
(
@issue
)
end
...
...
app/services/issues/build_service.rb
View file @
2f5ba074
...
...
@@ -7,6 +7,10 @@ module Issues
@issue
=
project
.
issues
.
new
(
issue_params
)
end
def
issue_params_from_template
{
description:
project
.
issues_template
}
end
def
issue_params_with_info_from_discussions
return
{}
unless
merge_request_to_resolve_discussions_of
...
...
@@ -49,8 +53,13 @@ module Issues
[
discussion_info
,
quote
].
join
(
"
\n\n
"
)
end
# Issue params can be built from 3 types of passed params,
# They take precedence over eachother like this
# passed params > discussion params > template params
def
issue_params
@issue_params
||=
issue_params_with_info_from_discussions
.
merge
(
whitelisted_issue_params
)
@issue_params
||=
issue_params_from_template
.
merge
(
issue_params_with_info_from_discussions
).
merge
(
whitelisted_issue_params
)
end
def
whitelisted_issue_params
...
...
spec/services/issues/build_service_spec.rb
View file @
2f5ba074
...
...
@@ -8,6 +8,19 @@ describe Issues::BuildService, services: true do
project
.
team
<<
[
user
,
:developer
]
end
context
'with an issue template'
do
describe
'#execute'
do
it
'fills in the template in the description'
do
project
=
build
(
:project
,
issues_template:
'Work hard, play hard!'
)
service
=
described_class
.
new
(
project
,
user
)
issue
=
service
.
execute
expect
(
issue
.
description
).
to
eq
(
'Work hard, play hard!'
)
end
end
end
context
'for a single discussion'
do
describe
'#execute'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
title:
"Hello world"
,
source_project:
project
)
}
...
...
@@ -25,6 +38,16 @@ describe Issues::BuildService, services: true do
expect
(
issue
.
description
).
to
include
(
'Almost done'
)
end
context
'with an issue template'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
issues_template:
'Work hard, play hard!'
)
}
it
'picks the discussion description over the issue template'
do
issue
=
service
.
execute
expect
(
issue
.
description
).
to
include
(
'Almost done'
)
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