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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
28912265
Commit
28912265
authored
Aug 24, 2017
by
Maxim Rydkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish spec/finders/yet_another_users_finder_spec.rb
parent
fbbb985a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
54 deletions
+42
-54
spec/finders/yet_another_users_finder_spec.rb
spec/finders/yet_another_users_finder_spec.rb
+42
-54
No files found.
spec/finders/yet_another_users_finder_spec.rb
View file @
28912265
...
@@ -9,78 +9,66 @@ describe YetAnotherUsersFinder do
...
@@ -9,78 +9,66 @@ describe YetAnotherUsersFinder do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:params
)
{
{}
}
let
(
:params
)
{
{}
}
it
'returns no users'
do
let
(
:users
)
{
User
.
all
}
users
=
described_class
.
new
(
params:
params
,
current_user:
current_user
).
execute
subject
{
described_class
.
new
(
params:
params
,
current_user:
current_user
,
users:
users
).
execute
.
to_a
}
expect
(
users
.
size
).
to
eq
(
0
)
context
'when users param not passed or nil'
do
end
let
(
:users
)
{
nil
}
# context 'with a normal user' do
# let(:user) { create(:user) }
# it 'returns all users' do
it
{
is_expected
.
to
match_array
([])
}
# users = described_class.new(user).execute
end
# expect(users).to contain_exactly(user, user1, user2, omniauth_user)
# end
# it 'filters by username' do
# users = described_class.new(user, username: 'johndoe').execute
# expect(users).to contain_exactly(user1)
it
{
is_expected
.
to
match_array
([
user1
,
external_user
,
omniauth_user
,
current_user
])
}
# end
# it 'filters
by search' do
context
'when filtered
by search'
do
# users = described_class.new(user, search: 'orando').execute
let
(
:params
)
{
{
search:
'johndoe'
}
}
# expect(users).to contain_exactly(user2)
it
{
is_expected
.
to
match_array
([
user1
])
}
#
end
end
# it 'filters by blocked
users' do
context
'when filtered by skip_
users'
do
# users = described_class.new(user, blocked: true).execute
let
(
:params
)
{
{
skip_users:
[
omniauth_user
.
id
,
current_user
.
id
]
}
}
# expect(users).to contain_exactly(user2)
it
{
is_expected
.
to
match_array
([
user1
,
external_user
])
}
#
end
end
# it 'filters by active users' do
context
'when todos exist'
do
# users = described_class.new(user, active: true).execute
let!
(
:pending_todo1
)
{
create
(
:todo
,
user:
current_user
,
author:
user1
,
state: :pending
)
}
let!
(
:pending_todo2
)
{
create
(
:todo
,
user:
external_user
,
author:
omniauth_user
,
state: :pending
)
}
let!
(
:done_todo1
)
{
create
(
:todo
,
user:
current_user
,
author:
external_user
,
state: :done
)
}
let!
(
:done_todo2
)
{
create
(
:todo
,
user:
user1
,
author:
external_user
,
state: :done
)
}
# expect(users).to contain_exactly(user, user1, omniauth_user)
context
'when filtered by todo_filter without todo_state_filter'
do
# end
let
(
:params
)
{
{
todo_filter:
true
}
}
# it 'returns no external users' do
it
{
is_expected
.
to
match_array
([])
}
# users = described_class.new(user, external: true).execute
end
# expect(users).to contain_exactly(user, user1, user2, omniauth_user)
context
'when filtered by todo_filter with pending todo_state_filter'
do
# end
let
(
:params
)
{
{
todo_filter:
true
,
todo_state_filter:
'pending'
}
}
# it 'filters by created_at' do
it
{
is_expected
.
to
match_array
([
user1
])
}
# filtered_user_before = create(:user, created_at: 3.days.ago)
end
# filtered_user_after = create(:user, created_at: Time.now + 3.days)
# users = described_class.new(user,
# created_after: 2.days.ago,
# created_before: Time.now + 2.days).execute
# expect(users.map(&:username)).not_to include([filtered_user_before.username, filtered_user_after.username])
context
'when filtered by todo_filter with done todo_state_filter'
do
# end
let
(
:params
)
{
{
todo_filter:
true
,
todo_state_filter:
'done'
}
}
# end
# context 'with an admin user' do
it
{
is_expected
.
to
match_array
([
external_user
])
}
# let(:admin) { create(:admin) }
end
end
# it 'filters by external users' do
context
'when filtered by current_user'
do
# users = described_class.new(admin, external: true).execute
let
(
:current_user
)
{
user2
}
let
(
:params
)
{
{
current_user:
true
}
}
# expect(users).to contain_exactly(external_user)
it
{
is_expected
.
to
match_array
([
user2
,
user1
,
external_user
,
omniauth_user
])
}
#
end
end
# it 'returns all users
' do
context
'when filtered by author_id
'
do
# users = described_class.new(admin).execute
let
(
:params
)
{
{
author_id:
user2
.
id
}
}
# expect(users).to contain_exactly(admin, user1, user2, external_user, omniauth_user)
it
{
is_expected
.
to
match_array
([
user2
,
user1
,
external_user
,
omniauth_user
,
current_user
])
}
# end
end
# end
end
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