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
d0b64118
Commit
d0b64118
authored
Apr 03, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Multiple issue asignees] fix a few specs
parent
cd364ec5
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
72 additions
and
32 deletions
+72
-32
app/models/issue_assignee.rb
app/models/issue_assignee.rb
+3
-3
app/services/issuable/bulk_update_service.rb
app/services/issuable/bulk_update_service.rb
+5
-1
app/services/merge_requests/assign_issues_service.rb
app/services/merge_requests/assign_issues_service.rb
+1
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+0
-1
app/services/todo_service.rb
app/services/todo_service.rb
+1
-1
spec/features/issues/award_emoji_spec.rb
spec/features/issues/award_emoji_spec.rb
+1
-1
spec/features/issues_spec.rb
spec/features/issues_spec.rb
+6
-6
spec/lib/banzai/filter/redactor_filter_spec.rb
spec/lib/banzai/filter/redactor_filter_spec.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+0
-1
spec/services/issuable/bulk_update_service_spec.rb
spec/services/issuable/bulk_update_service_spec.rb
+50
-12
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+2
-2
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+1
-1
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+1
-1
No files found.
app/models/issue_assignee.rb
View file @
d0b64118
class
IssueAssignee
<
ActiveRecord
::
Base
class
IssueAssignee
<
ActiveRecord
::
Base
belongs_to
:issue
belongs_to
:issue
belongs_to
:assignee
,
class_name:
"User"
,
foreign_key: :user_id
belongs_to
:assignee
,
class_name:
"User"
,
foreign_key: :user_id
end
end
\ No newline at end of file
app/services/issuable/bulk_update_service.rb
View file @
d0b64118
...
@@ -7,10 +7,14 @@ module Issuable
...
@@ -7,10 +7,14 @@ module Issuable
ids
=
params
.
delete
(
:issuable_ids
).
split
(
","
)
ids
=
params
.
delete
(
:issuable_ids
).
split
(
","
)
items
=
model_class
.
where
(
id:
ids
)
items
=
model_class
.
where
(
id:
ids
)
%i(state_event milestone_id assignee_id add_label_ids remove_label_ids subscription_event)
.
each
do
|
key
|
%i(state_event milestone_id assignee_id a
ssignee_ids a
dd_label_ids remove_label_ids subscription_event)
.
each
do
|
key
|
params
.
delete
(
key
)
unless
params
[
key
].
present?
params
.
delete
(
key
)
unless
params
[
key
].
present?
end
end
if
params
[
:assignee_ids
]
==
[
IssuableFinder
::
NONE
.
to_s
]
params
[
:assignee_ids
]
=
[]
end
items
.
each
do
|
issuable
|
items
.
each
do
|
issuable
|
next
unless
can?
(
current_user
,
:"update_
#{
type
}
"
,
issuable
)
next
unless
can?
(
current_user
,
:"update_
#{
type
}
"
,
issuable
)
...
...
app/services/merge_requests/assign_issues_service.rb
View file @
d0b64118
...
@@ -14,7 +14,7 @@ module MergeRequests
...
@@ -14,7 +14,7 @@ module MergeRequests
def
execute
def
execute
assignable_issues
.
each
do
|
issue
|
assignable_issues
.
each
do
|
issue
|
Issues
::
UpdateService
.
new
(
issue
.
project
,
current_user
,
assignee_ids:
current_user
.
id
.
to_s
).
execute
(
issue
)
Issues
::
UpdateService
.
new
(
issue
.
project
,
current_user
,
assignee_ids:
[
current_user
.
id
]
).
execute
(
issue
)
end
end
{
{
...
...
app/services/system_note_service.rb
View file @
d0b64118
...
@@ -84,7 +84,6 @@ module SystemNoteService
...
@@ -84,7 +84,6 @@ module SystemNoteService
create_note
(
noteable:
issue
,
project:
project
,
author:
author
,
note:
body
)
create_note
(
noteable:
issue
,
project:
project
,
author:
author
,
note:
body
)
end
end
# Called when one or more labels on a Noteable are added and/or removed
# Called when one or more labels on a Noteable are added and/or removed
#
#
# noteable - Noteable object
# noteable - Noteable object
...
...
app/services/todo_service.rb
View file @
d0b64118
...
@@ -270,7 +270,7 @@ class TodoService
...
@@ -270,7 +270,7 @@ class TodoService
end
end
end
end
def
create_mention_todos
(
project
,
target
,
author
,
note
=
nil
)
def
create_mention_todos
(
project
,
target
,
author
,
note
=
nil
)
# Create Todos for directly addressed users
# Create Todos for directly addressed users
directly_addressed_users
=
filter_directly_addressed_users
(
project
,
note
||
target
,
author
)
directly_addressed_users
=
filter_directly_addressed_users
(
project
,
note
||
target
,
author
)
attributes
=
attributes_for_todo
(
project
,
target
,
author
,
Todo
::
DIRECTLY_ADDRESSED
,
note
)
attributes
=
attributes_for_todo
(
project
,
target
,
author
,
Todo
::
DIRECTLY_ADDRESSED
,
note
)
...
...
spec/features/issues/award_emoji_spec.rb
View file @
d0b64118
...
@@ -7,7 +7,7 @@ describe 'Awards Emoji', feature: true do
...
@@ -7,7 +7,7 @@ describe 'Awards Emoji', feature: true do
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
do
let
(
:issue
)
do
create
(
:issue
,
create
(
:issue
,
assignees:
[
@
user
],
assignees:
[
user
],
project:
project
)
project:
project
)
end
end
...
...
spec/features/issues_spec.rb
View file @
d0b64118
...
@@ -62,7 +62,7 @@ describe 'Issues', feature: true do
...
@@ -62,7 +62,7 @@ describe 'Issues', feature: true do
expect
(
page
).
to
have_content
'No assignee - assign yourself'
expect
(
page
).
to
have_content
'No assignee - assign yourself'
end
end
expect
(
issue
.
reload
.
assignee
).
to
be_nil
expect
(
issue
.
reload
.
assignee
s
).
to
be_empty
end
end
end
end
...
@@ -363,9 +363,9 @@ describe 'Issues', feature: true do
...
@@ -363,9 +363,9 @@ describe 'Issues', feature: true do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
before
do
before
do
foo
.
assignee
=
user2
foo
.
assignee
s
<<
user2
foo
.
save
foo
.
save
bar
.
assignee
=
user2
bar
.
assignee
s
<<
user2
bar
.
save
bar
.
save
end
end
...
@@ -440,7 +440,7 @@ describe 'Issues', feature: true do
...
@@ -440,7 +440,7 @@ describe 'Issues', feature: true do
expect
(
page
).
to
have_content
'No assignee'
expect
(
page
).
to
have_content
'No assignee'
end
end
expect
(
issue
.
reload
.
assignee
).
to
be_nil
expect
(
issue
.
reload
.
assignee
s
).
to
be_empty
end
end
it
'allows user to select an assignee'
,
js:
true
do
it
'allows user to select an assignee'
,
js:
true
do
...
@@ -498,7 +498,7 @@ describe 'Issues', feature: true do
...
@@ -498,7 +498,7 @@ describe 'Issues', feature: true do
login_with
guest
login_with
guest
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
expect
(
page
).
to
have_content
issue
.
assignee
.
name
expect
(
page
).
to
have_content
issue
.
assignee
s
.
first
.
name
end
end
end
end
end
end
...
@@ -590,7 +590,7 @@ describe 'Issues', feature: true do
...
@@ -590,7 +590,7 @@ describe 'Issues', feature: true do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
before
do
before
do
issue
.
assignee
=
user2
issue
.
assignee
s
<<
user2
issue
.
save
issue
.
save
end
end
end
end
...
...
spec/lib/banzai/filter/redactor_filter_spec.rb
View file @
d0b64118
...
@@ -103,7 +103,7 @@ describe Banzai::Filter::RedactorFilter, lib: true do
...
@@ -103,7 +103,7 @@ describe Banzai::Filter::RedactorFilter, lib: true do
it
'allows references for assignee'
do
it
'allows references for assignee'
do
assignee
=
create
(
:user
)
assignee
=
create
(
:user
)
project
=
create
(
:empty_project
,
:public
)
project
=
create
(
:empty_project
,
:public
)
issue
=
create
(
:issue
,
:confidential
,
project:
project
,
assignee
:
assignee
)
issue
=
create
(
:issue
,
:confidential
,
project:
project
,
assignee
s:
[
assignee
]
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_type:
'issue'
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_type:
'issue'
)
doc
=
filter
(
link
,
current_user:
assignee
)
doc
=
filter
(
link
,
current_user:
assignee
)
...
...
spec/models/user_spec.rb
View file @
d0b64118
...
@@ -24,7 +24,6 @@ describe User, models: true do
...
@@ -24,7 +24,6 @@ describe User, models: true do
it
{
is_expected
.
to
have_many
(
:recent_events
).
class_name
(
'Event'
)
}
it
{
is_expected
.
to
have_many
(
:recent_events
).
class_name
(
'Event'
)
}
it
{
is_expected
.
to
have_many
(
:issues
).
dependent
(
:restrict_with_exception
)
}
it
{
is_expected
.
to
have_many
(
:issues
).
dependent
(
:restrict_with_exception
)
}
it
{
is_expected
.
to
have_many
(
:notes
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:notes
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:assigned_issues
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:merge_requests
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:merge_requests
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:assigned_merge_requests
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:assigned_merge_requests
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:identities
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:identities
).
dependent
(
:destroy
)
}
...
...
spec/services/issuable/bulk_update_service_spec.rb
View file @
d0b64118
...
@@ -4,11 +4,12 @@ describe Issuable::BulkUpdateService, services: true do
...
@@ -4,11 +4,12 @@ describe Issuable::BulkUpdateService, services: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
,
namespace:
user
.
namespace
)
}
let
(
:project
)
{
create
(
:empty_project
,
namespace:
user
.
namespace
)
}
def
bulk_update
(
issues
,
extra_params
=
{})
def
bulk_update
(
issu
abl
es
,
extra_params
=
{})
bulk_update_params
=
extra_params
bulk_update_params
=
extra_params
.
reverse_merge
(
issuable_ids:
Array
(
issues
).
map
(
&
:id
).
join
(
','
))
.
reverse_merge
(
issuable_ids:
Array
(
issu
abl
es
).
map
(
&
:id
).
join
(
','
))
Issuable
::
BulkUpdateService
.
new
(
project
,
user
,
bulk_update_params
).
execute
(
'issue'
)
type
=
Array
(
issuables
).
first
.
model_name
.
param_key
Issuable
::
BulkUpdateService
.
new
(
project
,
user
,
bulk_update_params
).
execute
(
type
)
end
end
describe
'close issues'
do
describe
'close issues'
do
...
@@ -47,15 +48,15 @@ describe Issuable::BulkUpdateService, services: true do
...
@@ -47,15 +48,15 @@ describe Issuable::BulkUpdateService, services: true do
end
end
end
end
describe
'updating assignee'
do
describe
'updating
merge request
assignee'
do
let
(
:
issue
)
{
create
(
:issue
,
project:
project
,
assignee:
user
)
}
let
(
:
merge_request
)
{
create
(
:merge_request
,
target_project:
project
,
source_
project:
project
,
assignee:
user
)
}
context
'when the new assignee ID is a valid user'
do
context
'when the new assignee ID is a valid user'
do
it
'succeeds'
do
it
'succeeds'
do
new_assignee
=
create
(
:user
)
new_assignee
=
create
(
:user
)
project
.
team
<<
[
new_assignee
,
:developer
]
project
.
team
<<
[
new_assignee
,
:developer
]
result
=
bulk_update
(
issue
,
assignee_id:
new_assignee
.
id
)
result
=
bulk_update
(
merge_request
,
assignee_id:
new_assignee
.
id
)
expect
(
result
[
:success
]).
to
be_truthy
expect
(
result
[
:success
]).
to
be_truthy
expect
(
result
[
:count
]).
to
eq
(
1
)
expect
(
result
[
:count
]).
to
eq
(
1
)
...
@@ -65,22 +66,59 @@ describe Issuable::BulkUpdateService, services: true do
...
@@ -65,22 +66,59 @@ describe Issuable::BulkUpdateService, services: true do
assignee
=
create
(
:user
)
assignee
=
create
(
:user
)
project
.
team
<<
[
assignee
,
:developer
]
project
.
team
<<
[
assignee
,
:developer
]
expect
{
bulk_update
(
issue
,
assignee_id:
assignee
.
id
)
}
expect
{
bulk_update
(
merge_request
,
assignee_id:
assignee
.
id
)
}
.
to
change
{
issue
.
reload
.
assignee
}.
from
(
user
).
to
(
assignee
)
.
to
change
{
merge_request
.
reload
.
assignee
}.
from
(
user
).
to
(
assignee
)
end
end
end
end
context
"when the new assignee ID is
#{
IssuableFinder
::
NONE
}
"
do
context
"when the new assignee ID is
#{
IssuableFinder
::
NONE
}
"
do
it
"unassigns the issues"
do
it
"unassigns the issues"
do
expect
{
bulk_update
(
issue
,
assignee_id:
IssuableFinder
::
NONE
)
}
expect
{
bulk_update
(
merge_request
,
assignee_id:
IssuableFinder
::
NONE
)
}
.
to
change
{
issue
.
reload
.
assignee
}.
to
(
nil
)
.
to
change
{
merge_request
.
reload
.
assignee
}.
to
(
nil
)
end
end
end
end
context
'when the new assignee ID is not present'
do
context
'when the new assignee ID is not present'
do
it
'does not unassign'
do
it
'does not unassign'
do
expect
{
bulk_update
(
issue
,
assignee_id:
nil
)
}
expect
{
bulk_update
(
merge_request
,
assignee_id:
nil
)
}
.
not_to
change
{
issue
.
reload
.
assignee
}
.
not_to
change
{
merge_request
.
reload
.
assignee
}
end
end
end
describe
'updating issue assignee'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
assignees:
[
user
])
}
context
'when the new assignee ID is a valid user'
do
it
'succeeds'
do
new_assignee
=
create
(
:user
)
project
.
team
<<
[
new_assignee
,
:developer
]
result
=
bulk_update
(
issue
,
assignee_ids:
[
new_assignee
.
id
])
expect
(
result
[
:success
]).
to
be_truthy
expect
(
result
[
:count
]).
to
eq
(
1
)
end
it
'updates the assignee to the use ID passed'
do
assignee
=
create
(
:user
)
project
.
team
<<
[
assignee
,
:developer
]
expect
{
bulk_update
(
issue
,
assignee_ids:
[
assignee
.
id
])
}
.
to
change
{
issue
.
reload
.
assignees
.
first
}.
from
(
user
).
to
(
assignee
)
end
end
context
"when the new assignee ID is
#{
IssuableFinder
::
NONE
}
"
do
it
"unassigns the issues"
do
expect
{
bulk_update
(
issue
,
assignee_ids:
[
IssuableFinder
::
NONE
.
to_s
])
}
.
to
change
{
issue
.
reload
.
assignees
.
count
}.
from
(
1
).
to
(
0
)
end
end
context
'when the new assignee ID is not present'
do
it
'does not unassign'
do
expect
{
bulk_update
(
issue
,
assignee_ids:
[])
}
.
not_to
change
{
issue
.
reload
.
assignees
}
end
end
end
end
end
end
...
...
spec/services/issues/create_service_spec.rb
View file @
d0b64118
...
@@ -20,7 +20,7 @@ describe Issues::CreateService, services: true do
...
@@ -20,7 +20,7 @@ describe Issues::CreateService, services: true do
let
(
:opts
)
do
let
(
:opts
)
do
{
title:
'Awesome issue'
,
{
title:
'Awesome issue'
,
description:
'please fix'
,
description:
'please fix'
,
assignee_ids:
assignee
.
id
.
to_s
,
assignee_ids:
[
assignee
.
id
]
,
label_ids:
labels
.
map
(
&
:id
),
label_ids:
labels
.
map
(
&
:id
),
milestone_id:
milestone
.
id
,
milestone_id:
milestone
.
id
,
due_date:
Date
.
tomorrow
}
due_date:
Date
.
tomorrow
}
...
@@ -37,7 +37,7 @@ describe Issues::CreateService, services: true do
...
@@ -37,7 +37,7 @@ describe Issues::CreateService, services: true do
context
'when current user cannot admin issues in the project'
do
context
'when current user cannot admin issues in the project'
do
let
(
:guest
)
{
create
(
:user
)
}
let
(
:guest
)
{
create
(
:user
)
}
before
do
before
do
project
.
team
<<
[
guest
,
:guest
]
project
.
team
<<
[
guest
,
:guest
]
end
end
...
...
spec/services/issues/update_service_spec.rb
View file @
d0b64118
...
@@ -162,7 +162,7 @@ describe Issues::UpdateService, services: true do
...
@@ -162,7 +162,7 @@ describe Issues::UpdateService, services: true do
it
'does not update assignee_id with unauthorized users'
do
it
'does not update assignee_id with unauthorized users'
do
project
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
project
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
update_issue
(
confidential:
true
)
update_issue
(
confidential:
true
)
non_member
=
create
(
:user
)
non_member
=
create
(
:user
)
original_assignees
=
issue
.
assignees
original_assignees
=
issue
.
assignees
update_issue
(
assignee_ids:
[
non_member
.
id
])
update_issue
(
assignee_ids:
[
non_member
.
id
])
...
...
spec/services/notification_service_spec.rb
View file @
d0b64118
...
@@ -569,7 +569,7 @@ describe NotificationService, services: true do
...
@@ -569,7 +569,7 @@ describe NotificationService, services: true do
end
end
it
'emails previous assignee even if he has the "on mention" notif level'
do
it
'emails previous assignee even if he has the "on mention" notif level'
do
issue
.
assignees
=
[
@u_mentioned
]
issue
.
assignees
=
[
@u_mentioned
]
notification
.
reassigned_issue
(
issue
,
@u_disabled
,
[
@u_watcher
])
notification
.
reassigned_issue
(
issue
,
@u_disabled
,
[
@u_watcher
])
should_email
(
@u_mentioned
)
should_email
(
@u_mentioned
)
...
...
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