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
bce0bf6c
Commit
bce0bf6c
authored
Apr 05, 2021
by
Doug Stull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance of milestonish concern spec
- performance gains over 900+ factory creation reduction.
parent
d7b72c34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
34 deletions
+31
-34
spec/models/concerns/milestoneish_spec.rb
spec/models/concerns/milestoneish_spec.rb
+31
-34
No files found.
spec/models/concerns/milestoneish_spec.rb
View file @
bce0bf6c
...
...
@@ -2,30 +2,28 @@
require
'spec_helper'
RSpec
.
describe
Milestone
,
'Milestoneish'
do
let
(
:author
)
{
create
(
:user
)
}
let
(
:assignee
)
{
create
(
:user
)
}
let
(
:non_member
)
{
create
(
:user
)
}
let
(
:member
)
{
create
(
:user
)
}
let
(
:guest
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:label1
)
{
create
(
:label
,
project:
project
)
}
let
(
:label2
)
{
create
(
:label
,
project:
project
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
milestone:
milestone
,
assignees:
[
member
],
labels:
[
label1
])
}
let!
(
:security_issue_1
)
{
create
(
:issue
,
:confidential
,
project:
project
,
author:
author
,
milestone:
milestone
,
labels:
[
label2
])
}
let!
(
:security_issue_2
)
{
create
(
:issue
,
:confidential
,
project:
project
,
assignees:
[
assignee
],
milestone:
milestone
)
}
let!
(
:closed_issue_1
)
{
create
(
:issue
,
:closed
,
project:
project
,
milestone:
milestone
)
}
let!
(
:closed_issue_2
)
{
create
(
:issue
,
:closed
,
project:
project
,
milestone:
milestone
)
}
let!
(
:closed_security_issue_1
)
{
create
(
:issue
,
:confidential
,
:closed
,
project:
project
,
author:
author
,
milestone:
milestone
)
}
let!
(
:closed_security_issue_2
)
{
create
(
:issue
,
:confidential
,
:closed
,
project:
project
,
assignees:
[
assignee
],
milestone:
milestone
)
}
let!
(
:closed_security_issue_3
)
{
create
(
:issue
,
:confidential
,
:closed
,
project:
project
,
author:
author
,
milestone:
milestone
)
}
let!
(
:closed_security_issue_4
)
{
create
(
:issue
,
:confidential
,
:closed
,
project:
project
,
assignees:
[
assignee
],
milestone:
milestone
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
milestone:
milestone
)
}
let
(
:label_1
)
{
create
(
:label
,
title:
'label_1'
,
project:
project
,
priority:
1
)
}
let
(
:label_2
)
{
create
(
:label
,
title:
'label_2'
,
project:
project
,
priority:
2
)
}
let
(
:label_3
)
{
create
(
:label
,
title:
'label_3'
,
project:
project
)
}
RSpec
.
describe
Milestone
,
'Milestoneish'
,
factory_default: :keep
do
let_it_be
(
:author
)
{
create
(
:user
)
}
let_it_be
(
:assignee
)
{
create
(
:user
)
}
let_it_be
(
:non_member
)
{
create
(
:user
)
}
let_it_be
(
:member
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:admin
)
{
create
(
:admin
)
}
let_it_be
(
:project
,
reload:
true
)
{
create_default
(
:project
,
:public
,
:empty_repo
).
freeze
}
let_it_be
(
:milestone
,
refind:
true
)
{
create_default
(
:milestone
,
project:
project
)
}
let_it_be
(
:label1
)
{
create
(
:label
)
}
let_it_be
(
:label2
)
{
create
(
:label
)
}
let_it_be
(
:issue
,
reload:
true
)
{
create
(
:issue
,
milestone:
milestone
,
assignees:
[
member
],
labels:
[
label1
])
}
let_it_be
(
:security_issue_1
,
reload:
true
)
{
create
(
:issue
,
:confidential
,
author:
author
,
milestone:
milestone
,
labels:
[
label2
])
}
let_it_be
(
:security_issue_2
,
reload:
true
)
{
create
(
:issue
,
:confidential
,
assignees:
[
assignee
],
milestone:
milestone
)
}
let_it_be
(
:closed_issue_1
,
reload:
true
)
{
create
(
:issue
,
:closed
,
milestone:
milestone
)
}
let_it_be
(
:closed_issue_2
,
reload:
true
)
{
create
(
:issue
,
:closed
,
milestone:
milestone
)
}
let_it_be
(
:closed_security_issue_1
,
reload:
true
)
{
create
(
:issue
,
:confidential
,
:closed
,
author:
author
,
milestone:
milestone
)
}
let_it_be
(
:closed_security_issue_2
,
reload:
true
)
{
create
(
:issue
,
:confidential
,
:closed
,
assignees:
[
assignee
],
milestone:
milestone
)
}
let_it_be
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
milestone:
milestone
)
}
let_it_be
(
:label_1
)
{
create
(
:label
,
title:
'label_1'
,
priority:
1
)
}
let_it_be
(
:label_2
)
{
create
(
:label
,
title:
'label_2'
,
priority:
2
)
}
let_it_be
(
:label_3
)
{
create
(
:label
,
title:
'label_3'
)
}
before
do
project
.
add_developer
(
member
)
...
...
@@ -63,7 +61,7 @@ RSpec.describe Milestone, 'Milestoneish' do
end
end
context
'attributes visibility'
do
context
'
with
attributes visibility'
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:users
)
do
...
...
@@ -167,8 +165,6 @@ RSpec.describe Milestone, 'Milestoneish' do
end
describe
'#merge_requests_visible_to_user'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
milestone:
milestone
)
}
context
'when project is private'
do
before
do
project
.
update!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
...
...
@@ -211,10 +207,11 @@ RSpec.describe Milestone, 'Milestoneish' do
end
context
'when milestone is at parent level group'
do
let
(
:parent_group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
,
parent:
parent_group
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let
(
:milestone
)
{
create
(
:milestone
,
group:
parent_group
)
}
let_it_be
(
:parent_group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
,
parent:
parent_group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:empty_repo
,
namespace:
group
)
}
let_it_be
(
:milestone
)
{
create
(
:milestone
,
group:
parent_group
)
}
let_it_be
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
milestone:
milestone
)
}
it
'does not return any merge request for a non member'
do
merge_requests
=
milestone
.
merge_requests_visible_to_user
(
non_member
)
...
...
@@ -243,7 +240,7 @@ RSpec.describe Milestone, 'Milestoneish' do
end
describe
'#percent_complete'
,
:use_clean_rails_memory_store_caching
do
context
'division by zero'
do
context
'
with
division by zero'
do
let
(
:new_milestone
)
{
build_stubbed
(
:milestone
)
}
it
{
expect
(
new_milestone
.
percent_complete
).
to
eq
(
0
)
}
...
...
@@ -252,13 +249,13 @@ RSpec.describe Milestone, 'Milestoneish' do
describe
'#closed_issues_count'
do
it
'counts all closed issues including confidential'
do
expect
(
milestone
.
closed_issues_count
).
to
eq
6
expect
(
milestone
.
closed_issues_count
).
to
eq
4
end
end
describe
'#total_issues_count'
do
it
'counts all issues including confidential'
do
expect
(
milestone
.
total_issues_count
).
to
eq
9
expect
(
milestone
.
total_issues_count
).
to
eq
7
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