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
0346ae00
Commit
0346ae00
authored
Aug 12, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up member model specs
parent
55aaf11a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
spec/models/member_spec.rb
spec/models/member_spec.rb
+12
-11
No files found.
spec/models/member_spec.rb
View file @
0346ae00
...
...
@@ -113,9 +113,10 @@ RSpec.describe Member do
end
describe
'Scopes & finders'
do
before
do
project
=
create
(
:project
,
:public
)
group
=
create
(
:group
)
let_it_be
(
:project
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
before_all
do
@owner_user
=
create
(
:user
).
tap
{
|
u
|
group
.
add_owner
(
u
)
}
@owner
=
group
.
members
.
find_by
(
user_id:
@owner_user
.
id
)
...
...
@@ -252,9 +253,9 @@ RSpec.describe Member do
describe
'.add_user'
do
%w[project group]
.
each
do
|
source_type
|
context
"when source is a
#{
source_type
}
"
do
let
!
(
:sourc
e
)
{
create
(
source_type
,
:public
)
}
let
!
(
:user
)
{
create
(
:user
)
}
let
!
(
:admin
)
{
create
(
:admin
)
}
let
_it_be
(
:source
,
reload:
tru
e
)
{
create
(
source_type
,
:public
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:admin
)
{
create
(
:admin
)
}
it
'returns a <Source>Member object'
do
member
=
described_class
.
add_user
(
source
,
user
,
:maintainer
)
...
...
@@ -322,7 +323,7 @@ RSpec.describe Member do
it
'adds the user as a member'
do
expect
(
source
.
users
).
not_to
include
(
user
)
described_class
.
add_user
(
source
,
42
,
:maintainer
)
described_class
.
add_user
(
source
,
non_existing_record_id
,
:maintainer
)
expect
(
source
.
users
.
reload
).
not_to
include
(
user
)
end
...
...
@@ -482,10 +483,10 @@ RSpec.describe Member do
describe
'.add_users'
do
%w[project group]
.
each
do
|
source_type
|
context
"when source is a
#{
source_type
}
"
do
let
!
(
:source
)
{
create
(
source_type
,
:public
)
}
let
!
(
:admin
)
{
create
(
:admin
)
}
let
(
:user1
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
_it_be
(
:source
)
{
create
(
source_type
,
:public
)
}
let
_it_be
(
:admin
)
{
create
(
:admin
)
}
let
_it_be
(
:user1
)
{
create
(
:user
)
}
let
_it_be
(
:user2
)
{
create
(
:user
)
}
it
'returns a <Source>Member objects'
do
members
=
described_class
.
add_users
(
source
,
[
user1
,
user2
],
:maintainer
)
...
...
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