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
aad0af54
Commit
aad0af54
authored
Nov 24, 2020
by
Catalin Irimie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change test subject and use let_it_be_with_refind
parent
7b812c7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
spec/models/user_spec.rb
spec/models/user_spec.rb
+11
-11
No files found.
spec/models/user_spec.rb
View file @
aad0af54
...
...
@@ -2966,17 +2966,19 @@ RSpec.describe User do
end
describe
'#solo_owned_groups'
do
subject
{
create
(
:user
)
}
let_it_be_with_refind
(
:user
)
{
create
(
:user
)
}
subject
(
:solo_owned_groups
)
{
user
.
solo_owned_groups
}
context
'no owned groups'
do
it
{
expect
(
subject
.
solo_owned_groups
)
.
to
be_empty
}
it
{
is_expected
.
to
be_empty
}
end
context
'has owned groups'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
before
do
group
.
add_owner
(
subject
)
group
.
add_owner
(
user
)
end
context
'not solo owner'
do
...
...
@@ -2986,23 +2988,21 @@ RSpec.describe User do
group
.
add_owner
(
user2
)
end
it
{
expect
(
subject
.
solo_owned_groups
)
.
to
be_empty
}
it
{
is_expected
.
to
be_empty
}
end
context
'solo owner'
do
it
{
expect
(
subject
.
solo_owned_groups
)
.
to
include
(
group
)
}
it
{
is_expected
.
to
include
(
group
)
}
it
'avoids N+1 queries'
do
instance1
=
User
.
find
(
subject
.
id
)
instance2
=
User
.
find
(
subject
.
id
)
fresh_user
=
User
.
find
(
user
.
id
)
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
instance1
.
solo_owned_groups
fresh_user
.
solo_owned_groups
end
.
count
create
(
:group
).
add_owner
(
subject
)
create
(
:group
).
add_owner
(
user
)
expect
{
instance2
.
solo_owned_groups
}.
not_to
exceed_query_limit
(
control_count
)
expect
{
solo_owned_groups
}.
not_to
exceed_query_limit
(
control_count
)
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