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
74853a42
Commit
74853a42
authored
Sep 10, 2020
by
drew cimino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update specs and query method for readability
parent
d708e74f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
21 deletions
+24
-21
ee/app/finders/ci/daily_build_group_report_results_by_group_finder.rb
...rs/ci/daily_build_group_report_results_by_group_finder.rb
+4
-1
ee/spec/finders/ci/daily_build_group_report_results_by_group_finder_spec.rb
.../daily_build_group_report_results_by_group_finder_spec.rb
+20
-20
No files found.
ee/app/finders/ci/daily_build_group_report_results_by_group_finder.rb
View file @
74853a42
...
...
@@ -20,7 +20,10 @@ module Ci
private
def
query
super
.
with_included_projects
Ci
::
DailyBuildGroupReportResult
.
with_included_projects
.
recent_results
(
query_params
,
limit:
limit
)
end
def
query_allowed?
...
...
ee/spec/finders/ci/daily_build_group_report_results_by_group_finder_spec.rb
View file @
74853a42
...
...
@@ -10,11 +10,14 @@ RSpec.describe Ci::DailyBuildGroupReportResultsByGroupFinder do
let!
(
:project_coverage
)
{
create_daily_coverage
(
'rspec'
,
95.0
,
'2020-03-10'
,
project
)
}
let!
(
:group
)
{
create
(
:group
,
:private
)
}
let!
(
:
group
_project
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:
group_project_coverage_rspec
)
{
create_daily_coverage
(
'rspec'
,
79.0
,
'2020-03-09'
,
group
_project
)
}
let!
(
:
rspec
_project
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:
rspec_project_coverage
)
{
create_daily_coverage
(
'rspec'
,
79.0
,
'2020-03-09'
,
rspec
_project
)
}
let!
(
:group_project_two
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:group_project_coverage_karma
)
{
create_daily_coverage
(
'karma'
,
89.0
,
'2020-03-09'
,
group_project_two
)
}
let!
(
:karma_project
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:karma_project_coverage
)
{
create_daily_coverage
(
'karma'
,
89.0
,
'2020-03-09'
,
karma_project
)
}
let
(
:generic_project
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:generic_coverage
)
{
create_daily_coverage
(
'unreported'
,
95.0
,
'2020-03-10'
,
generic_project
)
}
let
(
:subgroup
)
{
create
(
:group
,
:private
,
parent:
group
)
}
let
(
:subgroup_project
)
{
create
(
:project
,
namespace:
subgroup
)
}
...
...
@@ -41,15 +44,12 @@ RSpec.describe Ci::DailyBuildGroupReportResultsByGroupFinder do
end
context
'when current user is allowed to :read_group_build_report_results'
do
let
(
:excluded_group_project
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:excluded_coverage
)
{
create_daily_coverage
(
'unreported'
,
95.0
,
'2020-03-10'
,
excluded_group_project
)
}
before
do
group
.
add_reporter
(
user
)
end
it
'returns only coverages belonging to the passed group'
do
expect
(
subject
).
to
include
(
group_project_coverage_rspec
,
group_project_coverage_karma
)
expect
(
subject
).
to
include
(
rspec_project_coverage
,
karma_project_coverage
)
expect
(
subject
).
not_to
include
(
project_coverage
)
expect
(
subject
).
not_to
include
(
subgroup_project_coverage
)
end
...
...
@@ -78,18 +78,18 @@ RSpec.describe Ci::DailyBuildGroupReportResultsByGroupFinder do
context
'with nil project_ids'
do
it
'returns only coverages belonging to the passed group'
do
expect
(
subject
).
to
include
(
group_project_coverage
)
expect
(
subject
).
to
match_array
([
rspec_project_coverage
,
karma_project_coverage
,
generic_coverage
]
)
expect
(
subject
).
not_to
include
(
project_coverage
)
expect
(
subject
).
not_to
include
(
subgroup_project_coverage
)
end
end
context
'with passed project_ids'
do
let
(
:project_ids
)
{
[
group
_project
.
id
]
}
let
(
:project_ids
)
{
[
rspec
_project
.
id
]
}
it
'filters out non-specified projects'
do
expect
(
subject
).
to
include
(
group_project_coverage
)
expect
(
subject
).
not_to
include
(
excluded
_coverage
)
expect
(
subject
).
to
match_array
([
rspec_project_coverage
]
)
expect
(
subject
).
not_to
include
(
karma_project_coverage
,
generic
_coverage
)
end
end
...
...
@@ -97,18 +97,18 @@ RSpec.describe Ci::DailyBuildGroupReportResultsByGroupFinder do
let
(
:project_ids
)
{
[]
}
it
'returns all projects'
do
expect
(
subject
).
to
include
(
group_project_coverage
)
expect
(
subject
).
to
include
(
excluded_coverage
)
expect
(
subject
).
to
match_array
([
rspec_project_coverage
,
karma_project_coverage
,
generic_coverage
])
end
end
context
'when accessing projects from the result'
do
it
'only does a single query'
do
# Two permission queries from "members" and "licenses"
# One query from "ci_daily_build_group_report_results"
# One optional from "projects" if not joined due to direct querying
expect
{
subject
.
map
(
&
:project
)
}.
not_to
exceed_query_limit
(
4
)
expect
(
subject
).
to
match_array
([
group_project_coverage_rspec
,
group_project_coverage_karma
])
it
'executes the same number of queries regardless of the number of records returned'
do
control
=
ActiveRecord
::
QueryRecorder
.
new
do
described_class
.
new
(
attributes
.
merge
(
limit:
1
)).
execute
.
map
(
&
:project
)
end
expect
{
subject
.
map
(
&
:project
)
}.
not_to
exceed_query_limit
(
control
)
expect
(
subject
).
to
match_array
([
rspec_project_coverage
,
karma_project_coverage
,
generic_coverage
])
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