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
ffa72325
Commit
ffa72325
authored
Mar 31, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Multiple issue asignees] Fix spec/services/issues/update_service_spec.rb
parent
68791d0a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
22 deletions
+27
-22
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+6
-9
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+11
-3
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+2
-2
app/services/system_note_service.rb
app/services/system_note_service.rb
+7
-7
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+1
-1
No files found.
app/services/issuable_base_service.rb
View file @
ffa72325
...
...
@@ -48,13 +48,8 @@ class IssuableBaseService < BaseService
params
.
delete
(
:add_label_ids
)
params
.
delete
(
:remove_label_ids
)
params
.
delete
(
:label_ids
)
if
issuable
.
is_a?
(
Issue
)
params
.
delete
(
:assignee_ids
)
else
params
.
delete
(
:assignee_id
)
end
params
.
delete
(
:due_date
)
end
...
...
@@ -280,7 +275,7 @@ class IssuableBaseService < BaseService
end
end
def
has_changes?
(
issuable
,
old_labels:
[])
def
has_changes?
(
issuable
,
old_labels:
[]
,
old_assignees:
[]
)
valid_attrs
=
[
:title
,
:description
,
:assignee_id
,
:milestone_id
,
:target_branch
]
attrs_changed
=
valid_attrs
.
any?
do
|
attr
|
...
...
@@ -289,7 +284,9 @@ class IssuableBaseService < BaseService
labels_changed
=
issuable
.
labels
!=
old_labels
attrs_changed
||
labels_changed
assignees_changed
=
issuable
.
assignees
!=
old_assignees
attrs_changed
||
labels_changed
||
assignees_changed
end
def
handle_common_system_notes
(
issuable
,
old_labels:
[])
...
...
app/services/issues/base_service.rb
View file @
ffa72325
...
...
@@ -9,9 +9,9 @@ module Issues
private
def
create_assignee_note
(
issue
)
def
create_assignee_note
(
issue
,
old_assignees
)
SystemNoteService
.
change_issue_assignees
(
issue
,
issue
.
project
,
current_user
,
issue
.
assignees
)
issue
,
issue
.
project
,
current_user
,
old_
assignees
)
end
def
execute_hooks
(
issue
,
action
=
'open'
)
...
...
@@ -24,7 +24,15 @@ module Issues
def
filter_assignee
(
issuable
)
return
if
params
[
:assignee_ids
].
to_a
.
empty?
params
[
:assignee_ids
]
=
params
[
:assignee_ids
].
select
{
|
assignee_id
|
assignee_can_read?
(
issuable
,
assignee_id
)}
assignee_ids
=
params
[
:assignee_ids
].
select
{
|
assignee_id
|
assignee_can_read?
(
issuable
,
assignee_id
)}
if
params
[
:assignee_ids
].
map
(
&
:to_s
)
==
[
IssuableFinder
::
NONE
]
params
[
:assignee_ids
]
=
[]
elsif
assignee_ids
.
any?
params
[
:assignee_ids
]
=
assignee_ids
else
params
.
delete
(
:assignee_ids
)
end
end
end
end
app/services/issues/update_service.rb
View file @
ffa72325
...
...
@@ -17,7 +17,7 @@ module Issues
old_mentioned_users
=
options
[
:old_mentioned_users
]
||
[]
old_assignees
=
options
[
:old_assignees
]
||
[]
if
has_changes?
(
issue
,
old_labels:
old_labels
)
if
has_changes?
(
issue
,
old_labels:
old_labels
,
old_assignees:
old_assignees
)
todo_service
.
mark_pending_todos_as_done
(
issue
,
current_user
)
end
...
...
@@ -31,7 +31,7 @@ module Issues
end
if
issue
.
assignees
!=
old_assignees
create_assignee_note
(
issue
)
create_assignee_note
(
issue
,
old_assignees
)
notification_service
.
reassigned_issue
(
issue
,
current_user
,
old_assignees
)
todo_service
.
reassigned_issue
(
issue
,
current_user
)
end
...
...
app/services/system_note_service.rb
View file @
ffa72325
...
...
@@ -67,18 +67,18 @@ module SystemNoteService
# "assigned to @user1 and @user2"
#
# Returns the created Note object
def
change_issue_assignees
(
issue
,
project
,
author
,
assignees
)
def
change_issue_assignees
(
issue
,
project
,
author
,
old_
assignees
)
# TODO: basic implementation, should be improved before merging the MR
body
=
if
issue
.
assignees
.
any?
&&
assignees
.
any?
unassigned_users
=
issue
.
assignees
-
assignees
added_users
=
assignees
-
issue
.
assignees
if
issue
.
assignees
.
any?
&&
old_
assignees
.
any?
unassigned_users
=
old_assignees
-
issue
.
assignees
added_users
=
issue
.
assignees
.
to_a
-
old_
assignees
"assigned to
#{
added_users
.
map
(
&
:to_reference
).
to_sentence
}
and unassigned
#{
unassigned_users
.
map
(
&
:to_reference
).
to_sentence
}
"
elsif
issue
.
assignees
.
any?
elsif
old_
assignees
.
any?
"removed all assignees"
elsif
assignees
.
any?
"assigned to
#{
assignees
.
map
(
&
:to_reference
).
to_sentence
}
"
elsif
issue
.
assignees
.
any?
"assigned to
#{
issue
.
assignees
.
map
(
&
:to_reference
).
to_sentence
}
"
end
create_note
(
noteable:
issue
,
project:
project
,
author:
author
,
note:
body
)
...
...
spec/services/issues/update_service_spec.rb
View file @
ffa72325
...
...
@@ -165,7 +165,7 @@ describe Issues::UpdateService, services: true do
non_member
=
create
(
:user
)
original_assignees
=
issue
.
assignees
update_issue
(
assignee_ids:
non_member
.
id
.
to_s
)
update_issue
(
assignee_ids:
[
non_member
.
id
]
)
expect
(
issue
.
reload
.
assignees
).
to
eq
(
original_assignees
)
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