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
7401c7a5
Commit
7401c7a5
authored
Nov 19, 2019
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for BulkUpdateService
parent
51254a44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
44 deletions
+63
-44
ee/spec/services/ee/issuable/bulk_update_service_spec.rb
ee/spec/services/ee/issuable/bulk_update_service_spec.rb
+28
-13
spec/services/issuable/bulk_update_service_spec.rb
spec/services/issuable/bulk_update_service_spec.rb
+35
-31
No files found.
ee/spec/services/ee/issuable/bulk_update_service_spec.rb
View file @
7401c7a5
...
...
@@ -13,6 +13,11 @@ describe Issuable::BulkUpdateService do
let
(
:epic2
)
{
create
(
:epic
,
group:
group
,
labels:
[
label1
])
}
let
(
:label1
)
{
create
(
:group_label
,
group:
group
)
}
before
do
group
.
add_reporter
(
user
)
stub_licensed_features
(
epics:
true
)
end
describe
'updating labels'
do
let
(
:label2
)
{
create
(
:group_label
,
group:
group
,
title:
'Bug'
)
}
let
(
:label3
)
{
create
(
:group_label
,
group:
group
,
title:
'suggestion'
)
}
...
...
@@ -26,9 +31,21 @@ describe Issuable::BulkUpdateService do
}
end
context
'when epics are enabled'
do
it
'updates epic labels'
do
result
=
subject
expect
(
result
[
:success
]).
to
be_truthy
expect
(
result
[
:count
]).
to
eq
(
issuables
.
count
)
issuables
.
each
do
|
issuable
|
expect
(
issuable
.
reload
.
labels
).
to
eq
([
label2
,
label3
])
end
end
end
context
'when epics are disabled'
do
before
do
group
.
add_reporter
(
user
)
stub_licensed_features
(
epics:
false
)
end
...
...
@@ -39,21 +56,19 @@ describe Issuable::BulkUpdateService do
end
end
context
'when epics are enabled'
do
before
do
group
.
add_reporter
(
user
)
stub_licensed_features
(
epics:
true
)
end
it
'updates epic labels'
do
result
=
subject
context
'when issuable_ids contain external epics'
do
it
'updates epics that belong to the parent group or descendants'
do
epic3
=
create
(
:epic
,
labels:
[
label1
])
epic4
=
create
(
:epic
,
group:
create
(
:group
,
parent:
group
),
labels:
[
label1
])
params
=
{
issuable_ids:
[
epic1
.
id
,
epic3
.
id
,
epic4
.
id
],
add_label_ids:
[
label3
.
id
]
}
result
=
described_class
.
new
(
group
,
user
,
params
).
execute
(
'epic'
)
expect
(
result
[
:success
]).
to
be_truthy
expect
(
result
[
:count
]).
to
eq
(
issuables
.
count
)
expect
(
result
[
:count
]).
to
eq
(
2
)
issuables
.
each
do
|
issuable
|
expect
(
issuable
.
reload
.
labels
).
to
eq
([
label2
,
label3
])
e
nd
expect
(
epic1
.
reload
.
labels
).
to
eq
([
label1
,
label3
])
expect
(
epic3
.
reload
.
labels
).
to
eq
([
label1
])
e
xpect
(
epic4
.
reload
.
labels
).
to
eq
([
label1
,
label3
])
end
end
end
...
...
spec/services/issuable/bulk_update_service_spec.rb
View file @
7401c7a5
...
...
@@ -202,33 +202,6 @@ describe Issuable::BulkUpdateService do
expect
(
project
.
issues
.
opened
).
to
be_empty
expect
(
project
.
issues
.
closed
).
not_to
be_empty
end
context
'when issue for a different project is created'
do
let
(
:private_project
)
{
create
(
:project
,
:private
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
private_project
,
author:
user
)
}
context
'when user has access to the project'
do
it
'closes all issues passed'
do
private_project
.
add_maintainer
(
user
)
bulk_update
(
issues
+
[
issue
],
state_event:
'close'
)
expect
(
project
.
issues
.
opened
).
to
be_empty
expect
(
project
.
issues
.
closed
).
not_to
be_empty
expect
(
private_project
.
issues
.
closed
).
not_to
be_empty
end
end
context
'when user does not have access to project'
do
it
'only closes all issues that the user has access to'
do
bulk_update
(
issues
+
[
issue
],
state_event:
'close'
)
expect
(
project
.
issues
.
opened
).
to
be_empty
expect
(
project
.
issues
.
closed
).
not_to
be_empty
expect
(
private_project
.
issues
.
closed
).
to
be_empty
end
end
end
end
describe
'reopen issues'
do
...
...
@@ -364,12 +337,30 @@ describe Issuable::BulkUpdateService do
end
end
end
describe
'updating issuables from external project'
do
it
'updates issuables that belong to the parent project'
do
issue1
=
create
(
:issue
,
project:
project
)
issue2
=
create
(
:issue
,
project:
create
(
:project
))
result
=
bulk_update
([
issue1
,
issue2
],
assignee_ids:
[
user
.
id
])
expect
(
result
[
:success
]).
to
be_truthy
expect
(
result
[
:count
]).
to
eq
(
1
)
expect
(
issue1
.
reload
.
assignees
).
to
eq
([
user
])
expect
(
issue2
.
reload
.
assignees
).
to
be_empty
end
end
end
context
'with issuables at a group level'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:parent
)
{
group
}
before
do
group
.
add_reporter
(
user
)
end
describe
'updating milestones'
do
let
(
:milestone
)
{
create
(
:milestone
,
group:
group
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
group:
group
)
}
...
...
@@ -401,11 +392,24 @@ describe Issuable::BulkUpdateService do
let
(
:regression
)
{
create
(
:group_label
,
group:
group
)
}
let
(
:merge_requests
)
{
create
(
:group_label
,
group:
group
)
}
before
do
group
.
add_reporter
(
user
)
end
it_behaves_like
'updating labels'
end
describe
'updating issuables from external group'
do
it
'updates issuables that belong to the parent group or descendants'
do
issue1
=
create
(
:issue
,
project:
create
(
:project
,
group:
group
))
issue2
=
create
(
:issue
,
project:
create
(
:project
,
group:
create
(
:group
)))
issue3
=
create
(
:issue
,
project:
create
(
:project
,
group:
create
(
:group
,
parent:
group
)))
milestone
=
create
(
:milestone
,
group:
group
)
result
=
bulk_update
([
issue1
,
issue2
,
issue3
],
milestone_id:
milestone
.
id
)
expect
(
result
[
:success
]).
to
be_truthy
expect
(
result
[
:count
]).
to
eq
(
2
)
expect
(
issue1
.
reload
.
milestone
).
to
eq
(
milestone
)
expect
(
issue2
.
reload
.
milestone
).
to
be_nil
expect
(
issue3
.
reload
.
milestone
).
to
eq
(
milestone
)
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