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
dbb4caf5
Commit
dbb4caf5
authored
Nov 16, 2020
by
Catalin Irimie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update user search tests to let_it_be, no delegate
parent
11e728c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
40 deletions
+36
-40
spec/models/user_spec.rb
spec/models/user_spec.rb
+36
-40
No files found.
spec/models/user_spec.rb
View file @
dbb4caf5
...
...
@@ -2024,10 +2024,10 @@ RSpec.describe User do
end
describe
'.search'
do
let
!
(
:user
)
{
create
(
:user
,
name:
'user'
,
username:
'usern'
,
email:
'email@gmail.com'
)
}
let
!
(
:user2
)
{
create
(
:user
,
name:
'user name'
,
username:
'username'
,
email:
'someemail@gmail.com'
)
}
let
!
(
:user3
)
{
create
(
:user
,
name:
'us'
,
username:
'se'
,
email:
'foo@gmail.com'
)
}
let
!
(
:email
)
do
let
_it_be
(
:user
)
{
create
(
:user
,
name:
'user'
,
username:
'usern'
,
email:
'email@gmail.com'
)
}
let
_it_be
(
:user2
)
{
create
(
:user
,
name:
'user name'
,
username:
'username'
,
email:
'someemail@gmail.com'
)
}
let
_it_be
(
:user3
)
{
create
(
:user
,
name:
'us'
,
username:
'se'
,
email:
'foo@gmail.com'
)
}
let
_it_be
(
:email
)
do
create
(
:email
,
user:
user
,
email:
'alias@example.com'
)
end
...
...
@@ -2137,126 +2137,122 @@ RSpec.describe User do
end
describe
'.search_without_secondary_emails'
do
delegate
:search_without_secondary_emails
,
to: :described_class
let!
(
:user
)
{
create
(
:user
,
name:
'John Doe'
,
username:
'john.doe'
,
email:
'someone.1@example.com'
)
}
let!
(
:another_user
)
{
create
(
:user
,
name:
'Albert Smith'
,
username:
'albert.smith'
,
email:
'another.2@example.com'
)
}
let!
(
:email
)
do
let_it_be
(
:user
)
{
create
(
:user
,
name:
'John Doe'
,
username:
'john.doe'
,
email:
'someone.1@example.com'
)
}
let_it_be
(
:another_user
)
{
create
(
:user
,
name:
'Albert Smith'
,
username:
'albert.smith'
,
email:
'another.2@example.com'
)
}
let_it_be
(
:email
)
do
create
(
:email
,
user:
another_user
,
email:
'alias@example.com'
)
end
it
'returns users with a matching name'
do
expect
(
search_without_secondary_emails
(
user
.
name
)).
to
eq
([
user
])
expect
(
described_class
.
search_without_secondary_emails
(
user
.
name
)).
to
eq
([
user
])
end
it
'returns users with a partially matching name'
do
expect
(
search_without_secondary_emails
(
user
.
name
[
0
..
2
])).
to
eq
([
user
])
expect
(
described_class
.
search_without_secondary_emails
(
user
.
name
[
0
..
2
])).
to
eq
([
user
])
end
it
'returns users with a matching name regardless of the casing'
do
expect
(
search_without_secondary_emails
(
user
.
name
.
upcase
)).
to
eq
([
user
])
expect
(
described_class
.
search_without_secondary_emails
(
user
.
name
.
upcase
)).
to
eq
([
user
])
end
it
'returns users with a matching email'
do
expect
(
search_without_secondary_emails
(
user
.
email
)).
to
eq
([
user
])
expect
(
described_class
.
search_without_secondary_emails
(
user
.
email
)).
to
eq
([
user
])
end
it
'does not return users with a partially matching email'
do
expect
(
search_without_secondary_emails
(
user
.
email
[
0
..
2
])).
not_to
include
(
user
)
expect
(
described_class
.
search_without_secondary_emails
(
user
.
email
[
0
..
2
])).
not_to
include
(
user
)
end
it
'returns users with a matching email regardless of the casing'
do
expect
(
search_without_secondary_emails
(
user
.
email
.
upcase
)).
to
eq
([
user
])
expect
(
described_class
.
search_without_secondary_emails
(
user
.
email
.
upcase
)).
to
eq
([
user
])
end
it
'returns users with a matching username'
do
expect
(
search_without_secondary_emails
(
user
.
username
)).
to
eq
([
user
])
expect
(
described_class
.
search_without_secondary_emails
(
user
.
username
)).
to
eq
([
user
])
end
it
'returns users with a partially matching username'
do
expect
(
search_without_secondary_emails
(
user
.
username
[
0
..
2
])).
to
eq
([
user
])
expect
(
described_class
.
search_without_secondary_emails
(
user
.
username
[
0
..
2
])).
to
eq
([
user
])
end
it
'returns users with a matching username regardless of the casing'
do
expect
(
search_without_secondary_emails
(
user
.
username
.
upcase
)).
to
eq
([
user
])
expect
(
described_class
.
search_without_secondary_emails
(
user
.
username
.
upcase
)).
to
eq
([
user
])
end
it
'does not return users with a matching whole secondary email'
do
expect
(
search_without_secondary_emails
(
email
.
email
)).
not_to
include
(
email
.
user
)
expect
(
described_class
.
search_without_secondary_emails
(
email
.
email
)).
not_to
include
(
email
.
user
)
end
it
'does not return users with a matching part of secondary email'
do
expect
(
search_without_secondary_emails
(
email
.
email
[
1
..
4
])).
not_to
include
(
email
.
user
)
expect
(
described_class
.
search_without_secondary_emails
(
email
.
email
[
1
..
4
])).
not_to
include
(
email
.
user
)
end
it
'returns no matches for an empty string'
do
expect
(
search_without_secondary_emails
(
''
)).
to
be_empty
expect
(
described_class
.
search_without_secondary_emails
(
''
)).
to
be_empty
end
it
'returns no matches for nil'
do
expect
(
search_without_secondary_emails
(
nil
)).
to
be_empty
expect
(
described_class
.
search_without_secondary_emails
(
nil
)).
to
be_empty
end
end
describe
'.search_with_secondary_emails'
do
delegate
:search_with_secondary_emails
,
to: :described_class
let!
(
:user
)
{
create
(
:user
,
name:
'John Doe'
,
username:
'john.doe'
,
email:
'someone.1@example.com'
)
}
let!
(
:another_user
)
{
create
(
:user
,
name:
'Albert Smith'
,
username:
'albert.smith'
,
email:
'another.2@example.com'
)
}
let!
(
:email
)
do
let_it_be
(
:user
)
{
create
(
:user
,
name:
'John Doe'
,
username:
'john.doe'
,
email:
'someone.1@example.com'
)
}
let_it_be
(
:another_user
)
{
create
(
:user
,
name:
'Albert Smith'
,
username:
'albert.smith'
,
email:
'another.2@example.com'
)
}
let_it_be
(
:email
)
do
create
(
:email
,
user:
another_user
,
email:
'alias@example.com'
)
end
it
'returns users with a matching name'
do
expect
(
search_with_secondary_emails
(
user
.
name
)).
to
eq
([
user
])
expect
(
described_class
.
search_with_secondary_emails
(
user
.
name
)).
to
eq
([
user
])
end
it
'returns users with a partially matching name'
do
expect
(
search_with_secondary_emails
(
user
.
name
[
0
..
2
])).
to
eq
([
user
])
expect
(
described_class
.
search_with_secondary_emails
(
user
.
name
[
0
..
2
])).
to
eq
([
user
])
end
it
'returns users with a matching name regardless of the casing'
do
expect
(
search_with_secondary_emails
(
user
.
name
.
upcase
)).
to
eq
([
user
])
expect
(
described_class
.
search_with_secondary_emails
(
user
.
name
.
upcase
)).
to
eq
([
user
])
end
it
'returns users with a matching email'
do
expect
(
search_with_secondary_emails
(
user
.
email
)).
to
eq
([
user
])
expect
(
described_class
.
search_with_secondary_emails
(
user
.
email
)).
to
eq
([
user
])
end
it
'does not return users with a partially matching email'
do
expect
(
search_with_secondary_emails
(
user
.
email
[
0
..
2
])).
not_to
include
(
user
)
expect
(
described_class
.
search_with_secondary_emails
(
user
.
email
[
0
..
2
])).
not_to
include
(
user
)
end
it
'returns users with a matching email regardless of the casing'
do
expect
(
search_with_secondary_emails
(
user
.
email
.
upcase
)).
to
eq
([
user
])
expect
(
described_class
.
search_with_secondary_emails
(
user
.
email
.
upcase
)).
to
eq
([
user
])
end
it
'returns users with a matching username'
do
expect
(
search_with_secondary_emails
(
user
.
username
)).
to
eq
([
user
])
expect
(
described_class
.
search_with_secondary_emails
(
user
.
username
)).
to
eq
([
user
])
end
it
'returns users with a partially matching username'
do
expect
(
search_with_secondary_emails
(
user
.
username
[
0
..
2
])).
to
eq
([
user
])
expect
(
described_class
.
search_with_secondary_emails
(
user
.
username
[
0
..
2
])).
to
eq
([
user
])
end
it
'returns users with a matching username regardless of the casing'
do
expect
(
search_with_secondary_emails
(
user
.
username
.
upcase
)).
to
eq
([
user
])
expect
(
described_class
.
search_with_secondary_emails
(
user
.
username
.
upcase
)).
to
eq
([
user
])
end
it
'returns users with a matching whole secondary email'
do
expect
(
search_with_secondary_emails
(
email
.
email
)).
to
eq
([
email
.
user
])
expect
(
described_class
.
search_with_secondary_emails
(
email
.
email
)).
to
eq
([
email
.
user
])
end
it
'does not return users with a matching part of secondary email'
do
expect
(
search_with_secondary_emails
(
email
.
email
[
1
..
4
])).
not_to
include
(
email
.
user
)
expect
(
described_class
.
search_with_secondary_emails
(
email
.
email
[
1
..
4
])).
not_to
include
(
email
.
user
)
end
it
'returns no matches for an empty string'
do
expect
(
search_with_secondary_emails
(
''
)).
to
be_empty
expect
(
described_class
.
search_with_secondary_emails
(
''
)).
to
be_empty
end
it
'returns no matches for nil'
do
expect
(
search_with_secondary_emails
(
nil
)).
to
be_empty
expect
(
described_class
.
search_with_secondary_emails
(
nil
)).
to
be_empty
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