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
701f57aa
Commit
701f57aa
authored
Feb 16, 2021
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for N+1 queries for issue labels
parent
ea372fa8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
app/services/issues/export_csv_service.rb
app/services/issues/export_csv_service.rb
+1
-1
spec/services/issues/export_csv_service_spec.rb
spec/services/issues/export_csv_service_spec.rb
+19
-10
No files found.
app/services/issues/export_csv_service.rb
View file @
701f57aa
...
...
@@ -18,7 +18,7 @@ module Issues
private
def
associations_to_preload
%i(author assignees timelogs milestone)
%i(author assignees timelogs milestone
project
)
end
def
header_to_value_hash
...
...
spec/services/issues/export_csv_service_spec.rb
View file @
701f57aa
...
...
@@ -4,11 +4,11 @@ require 'spec_helper'
RSpec
.
describe
Issues
::
ExportCsvService
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
group:
group
)
}
let
!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let
!
(
:bad_issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let
(
:subject
)
{
described_class
.
new
(
Issue
.
all
,
project
)
}
let
_it_be
(
:group
)
{
create
(
:group
)
}
let
_it_be
(
:project
)
{
create
(
:project
,
:public
,
group:
group
)
}
let
_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let
_it_be
(
:bad_issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
subject
{
described_class
.
new
(
Issue
.
all
,
project
)
}
it
'renders csv to string'
do
expect
(
subject
.
csv_data
).
to
be_a
String
...
...
@@ -33,11 +33,11 @@ RSpec.describe Issues::ExportCsvService do
end
context
'includes'
do
let
(
:milestone
)
{
create
(
:milestone
,
title:
'v1.0'
,
project:
project
)
}
let
(
:idea_label
)
{
create
(
:label
,
project:
project
,
title:
'Idea'
)
}
let
(
:feature_label
)
{
create
(
:label
,
project:
project
,
title:
'Feature'
)
}
let
_it_be
(
:milestone
)
{
create
(
:milestone
,
title:
'v1.0'
,
project:
project
)
}
let
_it_be
(
:idea_label
)
{
create
(
:label
,
project:
project
,
title:
'Idea'
)
}
let
_it_be
(
:feature_label
)
{
create
(
:label
,
project:
project
,
title:
'Feature'
)
}
before
do
before
_all
do
# Creating a timelog touches the updated_at timestamp of issue,
# so create these first.
issue
.
timelogs
.
create!
(
time_spent:
360
,
user:
user
)
...
...
@@ -150,7 +150,7 @@ RSpec.describe Issues::ExportCsvService do
end
context
'with issues filtered by labels and project'
do
let
(
:subject
)
do
subject
do
described_class
.
new
(
IssuesFinder
.
new
(
user
,
project_id:
project
.
id
,
...
...
@@ -162,6 +162,15 @@ RSpec.describe Issues::ExportCsvService do
expect
(
csv
[
0
][
'Issue ID'
]).
to
eq
issue
.
iid
.
to_s
end
end
context
'performance'
do
it
'does not run a query for each label link'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
csv
}.
count
create_list
(
:labeled_issue
,
2
,
project:
project
,
author:
user
,
labels:
[
feature_label
,
idea_label
])
expect
{
csv
}.
not_to
exceed_query_limit
(
control_count
)
end
end
end
context
'with minimal details'
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