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
0cc9982a
Commit
0cc9982a
authored
Jul 09, 2020
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce no of queries in epic_issues service specs
- Replace the use of modifier let with let_it_be
parent
39b7836b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
48 deletions
+48
-48
ee/spec/services/epic_issues/create_service_spec.rb
ee/spec/services/epic_issues/create_service_spec.rb
+18
-18
ee/spec/services/epic_issues/destroy_service_spec.rb
ee/spec/services/epic_issues/destroy_service_spec.rb
+6
-6
ee/spec/services/epic_issues/list_service_spec.rb
ee/spec/services/epic_issues/list_service_spec.rb
+11
-11
ee/spec/services/epic_issues/update_service_spec.rb
ee/spec/services/epic_issues/update_service_spec.rb
+13
-13
No files found.
ee/spec/services/epic_issues/create_service_spec.rb
View file @
0cc9982a
...
@@ -4,14 +4,14 @@ require 'spec_helper'
...
@@ -4,14 +4,14 @@ require 'spec_helper'
RSpec
.
describe
EpicIssues
::
CreateService
do
RSpec
.
describe
EpicIssues
::
CreateService
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:group
)
{
create
(
:group
)
}
let
_it_be
(
:group
)
{
create
(
:group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue2
)
{
create
(
:issue
,
project:
project
)
}
let
_it_be
(
:issue2
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue3
)
{
create
(
:issue
,
project:
project
)
}
let
_it_be
(
:issue3
)
{
create
(
:issue
,
project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:valid_reference
)
{
issue
.
to_reference
(
full:
true
)
}
let
(
:valid_reference
)
{
issue
.
to_reference
(
full:
true
)
}
let
_it_be
(
:epic
,
reload:
true
)
{
create
(
:epic
,
group:
group
)
}
def
assign_issue
(
references
)
def
assign_issue
(
references
)
params
=
{
issuable_references:
references
}
params
=
{
issuable_references:
references
}
...
@@ -159,9 +159,9 @@ RSpec.describe EpicIssues::CreateService do
...
@@ -159,9 +159,9 @@ RSpec.describe EpicIssues::CreateService do
end
end
context
'when a link of an issue in a subgroup is given'
do
context
'when a link of an issue in a subgroup is given'
do
let
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
_it_be
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
(
:project2
)
{
create
(
:project
,
group:
subgroup
)
}
let
_it_be
(
:project2
)
{
create
(
:project
,
group:
subgroup
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project2
)
}
let
_it_be
(
:issue
)
{
create
(
:issue
,
project:
project2
)
}
subject
{
assign_issue
([
Gitlab
::
Routing
.
url_helpers
.
namespace_project_issue_url
(
namespace_id:
issue
.
project
.
namespace
,
project_id:
issue
.
project
,
id:
issue
.
iid
)])}
subject
{
assign_issue
([
Gitlab
::
Routing
.
url_helpers
.
namespace_project_issue_url
(
namespace_id:
issue
.
project
.
namespace
,
project_id:
issue
.
project
,
id:
issue
.
iid
)])}
...
@@ -201,10 +201,10 @@ RSpec.describe EpicIssues::CreateService do
...
@@ -201,10 +201,10 @@ RSpec.describe EpicIssues::CreateService do
end
end
context
'when there are invalid references'
do
context
'when there are invalid references'
do
let
(
:epic
)
{
create
(
:epic
,
confidential:
true
,
group:
group
)
}
let
_it_be
(
:epic
)
{
create
(
:epic
,
confidential:
true
,
group:
group
)
}
let
(
:valid_issue
)
{
create
(
:issue
,
:confidential
,
project:
project
)
}
let
_it_be
(
:valid_issue
)
{
create
(
:issue
,
:confidential
,
project:
project
)
}
let
(
:invalid_issue1
)
{
create
(
:issue
,
project:
project
)
}
let
_it_be
(
:invalid_issue1
)
{
create
(
:issue
,
project:
project
)
}
let
(
:invalid_issue2
)
{
create
(
:issue
,
project:
project
)
}
let
_it_be
(
:invalid_issue2
)
{
create
(
:issue
,
project:
project
)
}
subject
do
subject
do
assign_issue
([
invalid_issue1
.
to_reference
(
full:
true
),
assign_issue
([
invalid_issue1
.
to_reference
(
full:
true
),
...
@@ -255,7 +255,7 @@ RSpec.describe EpicIssues::CreateService do
...
@@ -255,7 +255,7 @@ RSpec.describe EpicIssues::CreateService do
end
end
context
'when at least one of the issues is still not assigned to the epic'
do
context
'when at least one of the issues is still not assigned to the epic'
do
let
(
:valid_reference
)
{
issue2
.
to_reference
(
full:
true
)
}
let
_it_be
(
:valid_reference
)
{
issue2
.
to_reference
(
full:
true
)
}
subject
{
assign_issue
([
valid_reference
,
issue
.
to_reference
(
full:
true
)])
}
subject
{
assign_issue
([
valid_reference
,
issue
.
to_reference
(
full:
true
)])
}
...
@@ -270,7 +270,7 @@ RSpec.describe EpicIssues::CreateService do
...
@@ -270,7 +270,7 @@ RSpec.describe EpicIssues::CreateService do
issue
.
reload
issue
.
reload
end
end
let
(
:another_epic
)
{
create
(
:epic
,
group:
group
)
}
let
_it_be
(
:another_epic
)
{
create
(
:epic
,
group:
group
)
}
subject
do
subject
do
params
=
{
issuable_references:
[
valid_reference
]
}
params
=
{
issuable_references:
[
valid_reference
]
}
...
@@ -335,7 +335,7 @@ RSpec.describe EpicIssues::CreateService do
...
@@ -335,7 +335,7 @@ RSpec.describe EpicIssues::CreateService do
context
'when issue from non group project is given'
do
context
'when issue from non group project is given'
do
subject
{
assign_issue
([
another_issue
.
to_reference
(
full:
true
)])
}
subject
{
assign_issue
([
another_issue
.
to_reference
(
full:
true
)])
}
let
(
:another_issue
)
{
create
:issue
}
let
_it_be
(
:another_issue
)
{
create
:issue
}
before
do
before
do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
...
...
ee/spec/services/epic_issues/destroy_service_spec.rb
View file @
0cc9982a
...
@@ -4,12 +4,12 @@ require 'spec_helper'
...
@@ -4,12 +4,12 @@ require 'spec_helper'
RSpec
.
describe
EpicIssues
::
DestroyService
do
RSpec
.
describe
EpicIssues
::
DestroyService
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
_it_be
(
:group
,
refind:
true
)
{
create
(
:group
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
_it_be
(
:project
,
refind:
true
)
{
create
(
:project
,
group:
group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
_it_be
(
:epic
,
reload:
true
)
{
create
(
:epic
,
group:
group
)
}
let
(
:iss
ue
)
{
create
(
:issue
,
project:
project
)
}
let
_it_be
(
:issue
,
reload:
tr
ue
)
{
create
(
:issue
,
project:
project
)
}
let
!
(
:epic_iss
ue
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issue
)
}
let
_it_be
(
:epic_issue
,
reload:
tr
ue
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issue
)
}
subject
{
described_class
.
new
(
epic_issue
,
user
).
execute
}
subject
{
described_class
.
new
(
epic_issue
,
user
).
execute
}
...
...
ee/spec/services/epic_issues/list_service_spec.rb
View file @
0cc9982a
...
@@ -3,22 +3,22 @@
...
@@ -3,22 +3,22 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
EpicIssues
::
ListService
do
RSpec
.
describe
EpicIssues
::
ListService
do
let
(
:user
)
{
create
:user
}
let
_it_be
(
:user
)
{
create
:user
}
let
(
:group
)
{
create
(
:group
,
:private
)
}
let
_it_be
(
:group
,
refind:
true
)
{
create
(
:group
,
:private
)
}
let
(
:project
)
{
create
(
:project_empty_repo
,
group:
group
)
}
let
_it_be
(
:project
,
refind:
true
)
{
create
(
:project_empty_repo
,
group:
group
)
}
let
(
:other_project
)
{
create
(
:project_empty_repo
,
group:
group
)
}
let
_it_be
(
:other_project
)
{
create
(
:project_empty_repo
,
group:
group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
_it_be
(
:epic
,
refind:
true
)
{
create
(
:epic
,
group:
group
)
}
# Reloading issues here is needed because when storing datetime on postgres
# Reloading issues here is needed because when storing datetime on postgres
# nanoseconds precision is ignored when fetching records but not when inserting,
# nanoseconds precision is ignored when fetching records but not when inserting,
# which makes the expectations fails for created_at field.
# which makes the expectations fails for created_at field.
let
!
(
:issue1
)
{
create
(
:issue
,
project:
project
,
weight:
1
).
reload
}
let
_it_be
(
:issue1
)
{
create
(
:issue
,
project:
project
,
weight:
1
).
reload
}
let
!
(
:issue2
)
{
create
(
:issue
,
project:
project
).
reload
}
let
_it_be
(
:issue2
)
{
create
(
:issue
,
project:
project
).
reload
}
let
!
(
:issue3
)
{
create
(
:issue
,
project:
other_project
).
reload
}
let
_it_be
(
:issue3
)
{
create
(
:issue
,
project:
other_project
).
reload
}
let
!
(
:epic_issue1
)
{
create
(
:epic_issue
,
issue:
issue1
,
epic:
epic
,
relative_position:
2
)
}
let
_it_be
(
:epic_issue1
)
{
create
(
:epic_issue
,
issue:
issue1
,
epic:
epic
,
relative_position:
2
)
}
let
!
(
:epic_issue2
)
{
create
(
:epic_issue
,
issue:
issue2
,
epic:
epic
,
relative_position:
1
)
}
let
_it_be
(
:epic_issue2
)
{
create
(
:epic_issue
,
issue:
issue2
,
epic:
epic
,
relative_position:
1
)
}
let
!
(
:epic_issue3
)
{
create
(
:epic_issue
,
issue:
issue3
,
epic:
epic
,
relative_position:
3
)
}
let
_it_be
(
:epic_issue3
)
{
create
(
:epic_issue
,
issue:
issue3
,
epic:
epic
,
relative_position:
3
)
}
describe
'#execute'
do
describe
'#execute'
do
subject
{
described_class
.
new
(
epic
,
user
).
execute
}
subject
{
described_class
.
new
(
epic
,
user
).
execute
}
...
...
ee/spec/services/epic_issues/update_service_spec.rb
View file @
0cc9982a
...
@@ -4,15 +4,15 @@ require 'spec_helper'
...
@@ -4,15 +4,15 @@ require 'spec_helper'
RSpec
.
describe
EpicIssues
::
UpdateService
do
RSpec
.
describe
EpicIssues
::
UpdateService
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
_it_be
(
:group
)
{
create
(
:group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
_it_be
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:issues
)
{
create_list
(
:issue
,
4
)
}
let
_it_be
(
:issues
)
{
create_list
(
:issue
,
4
)
}
let
!
(
:epic_issue1
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
0
],
relative_position:
3
)
}
let
_it_be
(
:epic_issue1
,
reload:
true
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
0
],
relative_position:
3
)
}
let
!
(
:epic_issue2
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
1
],
relative_position:
600
)
}
let
_it_be
(
:epic_issue2
,
reload:
true
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
1
],
relative_position:
600
)
}
let
!
(
:epic_issue3
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
2
],
relative_position:
1200
)
}
let
_it_be
(
:epic_issue3
,
reload:
true
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
2
],
relative_position:
1200
)
}
let
!
(
:epic_issue4
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
3
],
relative_position:
2000
)
}
let
_it_be
(
:epic_issue4
,
reload:
true
)
{
create
(
:epic_issue
,
epic:
epic
,
issue:
issues
[
3
],
relative_position:
2000
)
}
let
(
:default_position_value
)
{
Gitlab
::
Database
::
MAX_INT_VALUE
/
2
}
let
_it_be
(
:default_position_value
)
{
Gitlab
::
Database
::
MAX_INT_VALUE
/
2
}
before
do
before
do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
...
@@ -28,10 +28,10 @@ RSpec.describe EpicIssues::UpdateService do
...
@@ -28,10 +28,10 @@ RSpec.describe EpicIssues::UpdateService do
context
'when moving issues between different epics'
do
context
'when moving issues between different epics'
do
before
do
before
do
epic_issue3
.
update_attribute
(
:epic
,
create
(
:epic
,
group:
group
))
epic_issue3
.
update_attribute
(
:epic
,
build
(
:epic
,
group:
group
))
end
end
let
(
:params
)
{
{
move_before_id:
epic_issue3
.
id
,
move_after_id:
epic_issue4
.
id
}
}
let
_it_be
(
:params
)
{
{
move_before_id:
epic_issue3
.
id
,
move_after_id:
epic_issue4
.
id
}
}
subject
{
order_issue
(
epic_issue1
,
params
)
}
subject
{
order_issue
(
epic_issue1
,
params
)
}
...
@@ -50,7 +50,7 @@ RSpec.describe EpicIssues::UpdateService do
...
@@ -50,7 +50,7 @@ RSpec.describe EpicIssues::UpdateService do
end
end
context
'moving issue to the first position'
do
context
'moving issue to the first position'
do
let
(
:params
)
{
{
move_after_id:
epic_issue1
.
id
}
}
let
_it_be
(
:params
)
{
{
move_after_id:
epic_issue1
.
id
}
}
context
'when some positions are close to each other'
do
context
'when some positions are close to each other'
do
before
do
before
do
...
@@ -76,7 +76,7 @@ RSpec.describe EpicIssues::UpdateService do
...
@@ -76,7 +76,7 @@ RSpec.describe EpicIssues::UpdateService do
end
end
context
'moving issue to the third position'
do
context
'moving issue to the third position'
do
let
(
:params
)
{
{
move_before_id:
epic_issue3
.
id
,
move_after_id:
epic_issue4
.
id
}
}
let
_it_be
(
:params
)
{
{
move_before_id:
epic_issue3
.
id
,
move_after_id:
epic_issue4
.
id
}
}
context
'when some positions are close to each other'
do
context
'when some positions are close to each other'
do
before
do
before
do
...
...
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