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
Léo-Paul Géneau
gitlab-ce
Commits
ffe135cc
Commit
ffe135cc
authored
Feb 27, 2017
by
Bob Van Landuyt
Committed by
Bob Van Landuyt
Mar 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move functionality for resolving discussions into a concern
parent
6ffa988a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
42 deletions
+54
-42
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+2
-3
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+0
-27
app/services/issues/build_service.rb
app/services/issues/build_service.rb
+3
-0
app/services/issues/create_service.rb
app/services/issues/create_service.rb
+2
-9
app/services/issues/resolve_discussions.rb
app/services/issues/resolve_discussions.rb
+35
-0
spec/services/issues/resolve_discussions_spec.rb
spec/services/issues/resolve_discussions_spec.rb
+12
-3
No files found.
app/controllers/projects/issues_controller.rb
View file @
ffe135cc
...
...
@@ -64,16 +64,15 @@ class Projects::IssuesController < Projects::ApplicationController
params
[
:issue
]
||=
ActionController
::
Parameters
.
new
(
assignee_id:
""
)
build_params
=
issue_params
.
merge
(
merge_request_for_resolving_discussions:
params
[
:merge_request_for_resolving_discussions
],
discussion_to_resolve:
params
[
:discussion_to_resolve
]
)
service
=
Issues
::
BuildService
.
new
(
project
,
current_user
,
build_params
)
@merge_request_for_resolving_discussions
=
service
.
merge_request_for_resolving_discussions
@discussion_to_resolve
=
service
.
discussions_to_resolve
.
first
if
params
[
:discussion_to_resolve
]
@issue
=
@noteable
=
service
.
execute
@merge_request_for_resolving_discussions
=
service
.
merge_request_for_resolving_discussions
@discussion_to_resolve
=
service
.
discussions_to_resolve
.
first
if
params
[
:discussion_to_resolve
]
respond_with
(
@issue
)
end
...
...
app/services/issues/base_service.rb
View file @
ffe135cc
module
Issues
class
BaseService
<
::
IssuableBaseService
attr_reader
:merge_request_for_resolving_discussions_iid
,
:discussion_to_resolve_id
def
initialize
(
*
args
)
super
@merge_request_for_resolving_discussions_iid
||=
params
.
delete
(
:merge_request_for_resolving_discussions
)
@discussion_to_resolve_id
||=
params
.
delete
(
:discussion_to_resolve
)
end
def
hook_data
(
issue
,
action
)
issue_data
=
issue
.
to_hook_data
(
current_user
)
issue_url
=
Gitlab
::
UrlBuilder
.
build
(
issue
)
...
...
@@ -15,25 +7,6 @@ module Issues
issue_data
end
def
merge_request_for_resolving_discussions
@merge_request_for_resolving_discussions
||=
MergeRequestsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
execute
.
find_by
(
iid:
merge_request_for_resolving_discussions_iid
)
end
def
discussions_to_resolve
return
[]
unless
merge_request_for_resolving_discussions
@discussions_to_resolve
||=
NotesFinder
.
new
(
project
,
current_user
,
{
discussion_id:
discussion_to_resolve_id
,
target_type:
MergeRequest
.
name
.
underscore
,
target_id:
merge_request_for_resolving_discussions
.
id
}).
execute
.
discussions
.
select
(
&
:to_be_resolved?
)
end
private
def
execute_hooks
(
issue
,
action
=
'open'
)
...
...
app/services/issues/build_service.rb
View file @
ffe135cc
module
Issues
class
BuildService
<
Issues
::
BaseService
include
ResolveDiscussions
def
execute
filter_resolve_discussion_params
@issue
=
project
.
issues
.
new
(
issue_params
)
end
...
...
app/services/issues/create_service.rb
View file @
ffe135cc
module
Issues
class
CreateService
<
Issues
::
BaseService
include
SpamCheckService
include
ResolveDiscussions
def
execute
filter_spam_check_params
filter_resolve_discussion_params
issue_attributes
=
params
.
merge
(
merge_request_for_resolving_discussions:
merge_request_for_resolving_discussions_iid
,
...
...
@@ -28,15 +30,6 @@ module Issues
resolve_discussions_with_issue
(
issuable
)
end
def
resolve_discussions_with_issue
(
issue
)
return
if
discussions_to_resolve
.
empty?
Discussions
::
ResolveService
.
new
(
project
,
current_user
,
merge_request:
merge_request_for_resolving_discussions
,
follow_up_issue:
issue
).
execute
(
discussions_to_resolve
)
end
private
def
user_agent_detail_service
...
...
app/services/issues/resolve_discussions.rb
0 → 100644
View file @
ffe135cc
module
Issues
module
ResolveDiscussions
attr_reader
:merge_request_for_resolving_discussions_iid
,
:discussion_to_resolve_id
def
filter_resolve_discussion_params
@merge_request_for_resolving_discussions_iid
||=
params
.
delete
(
:merge_request_for_resolving_discussions
)
@discussion_to_resolve_id
||=
params
.
delete
(
:discussion_to_resolve
)
end
def
resolve_discussions_with_issue
(
issue
)
return
if
discussions_to_resolve
.
empty?
Discussions
::
ResolveService
.
new
(
project
,
current_user
,
merge_request:
merge_request_for_resolving_discussions
,
follow_up_issue:
issue
).
execute
(
discussions_to_resolve
)
end
def
merge_request_for_resolving_discussions
@merge_request_for_resolving_discussions
||=
MergeRequestsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
execute
.
find_by
(
iid:
merge_request_for_resolving_discussions_iid
)
end
def
discussions_to_resolve
return
[]
unless
merge_request_for_resolving_discussions
@discussions_to_resolve
||=
NotesFinder
.
new
(
project
,
current_user
,
{
discussion_id:
discussion_to_resolve_id
,
target_type:
MergeRequest
.
name
.
underscore
,
target_id:
merge_request_for_resolving_discussions
.
id
}).
execute
.
discussions
.
select
(
&
:to_be_resolved?
)
end
end
end
spec/services/issues/
base_service
_spec.rb
→
spec/services/issues/
resolve_discussions
_spec.rb
View file @
ffe135cc
require
'spec_helper.rb'
describe
Issues
::
BaseService
,
services:
true
do
class
DummyService
<
Issues
::
BaseService
include
::
Issues
::
ResolveDiscussions
def
initialize
(
*
args
)
super
filter_resolve_discussion_params
end
end
describe
DummyService
,
services:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -46,7 +55,7 @@ describe Issues::BaseService, services: true do
end
it
"contains only unresolved discussions"
do
second_discussion
=
Discussion
.
new
([
create
(
:diff_note_on_merge_request
,
:resolved
,
_
second_discussion
=
Discussion
.
new
([
create
(
:diff_note_on_merge_request
,
:resolved
,
noteable:
merge_request
,
project:
merge_request
.
target_project
,
line_number:
15
,
...
...
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