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
Léo-Paul Géneau
gitlab-ce
Commits
0750638f
Commit
0750638f
authored
Mar 20, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CE] Reduce differences with EE in users_finder_spec.rb
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
9e171a53
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
49 deletions
+38
-49
spec/finders/merge_requests_finder_spec.rb
spec/finders/merge_requests_finder_spec.rb
+1
-1
spec/finders/users_finder_spec.rb
spec/finders/users_finder_spec.rb
+14
-17
spec/support/shared_contexts/finders/users_finder_shared_contexts.rb
...t/shared_contexts/finders/users_finder_shared_contexts.rb
+8
-0
spec/support/shared_examples/snippet_visibility_shared_examples.rb
...ort/shared_examples/snippet_visibility_shared_examples.rb
+15
-31
No files found.
spec/finders/merge_requests_finder_spec.rb
View file @
0750638f
...
...
@@ -34,7 +34,7 @@ describe MergeRequestsFinder do
it
'includes all merge requests when user has access exceluding merge requests from projects the user does not have access to'
do
private_project
=
allow_gitaly_n_plus_1
{
create
(
:project
,
:private
,
group:
group
)
}
private_project
.
add_guest
(
user
)
private_mr
=
create
(
:merge_request
,
:simple
,
author:
user
,
source_project:
private_project
,
target_project:
private_project
)
create
(
:merge_request
,
:simple
,
author:
user
,
source_project:
private_project
,
target_project:
private_project
)
params
=
{
group_id:
group
.
id
}
merge_requests
=
described_class
.
new
(
user
,
params
).
execute
...
...
spec/finders/users_finder_spec.rb
View file @
0750638f
...
...
@@ -2,10 +2,7 @@ require 'spec_helper'
describe
UsersFinder
do
describe
'#execute'
do
let!
(
:user1
)
{
create
(
:user
,
username:
'johndoe'
)
}
let!
(
:user2
)
{
create
(
:user
,
:blocked
,
username:
'notsorandom'
)
}
let!
(
:external_user
)
{
create
(
:user
,
:external
)
}
let!
(
:omniauth_user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
include_context
'UsersFinder#execute filter by project context'
context
'with a normal user'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -13,43 +10,43 @@ describe UsersFinder do
it
'returns all users'
do
users
=
described_class
.
new
(
user
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
user2
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
blocked_user
,
omniauth_user
)
end
it
'filters by username'
do
users
=
described_class
.
new
(
user
,
username:
'johndoe'
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
it
'filters by username (case insensitive)'
do
users
=
described_class
.
new
(
user
,
username:
'joHNdoE'
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
it
'filters by search'
do
users
=
described_class
.
new
(
user
,
search:
'orando'
).
execute
expect
(
users
).
to
contain_exactly
(
user2
)
expect
(
users
).
to
contain_exactly
(
blocked_user
)
end
it
'filters by blocked users'
do
users
=
described_class
.
new
(
user
,
blocked:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user2
)
expect
(
users
).
to
contain_exactly
(
blocked_user
)
end
it
'filters by active users'
do
users
=
described_class
.
new
(
user
,
active:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
omniauth_user
)
end
it
'returns no external users'
do
users
=
described_class
.
new
(
user
,
external:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
user2
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
blocked_user
,
omniauth_user
)
end
it
'filters by created_at'
do
...
...
@@ -69,7 +66,7 @@ describe UsersFinder do
custom_attributes:
{
foo:
'bar'
}
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
user2
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
blocked_user
,
omniauth_user
)
end
end
...
...
@@ -85,20 +82,20 @@ describe UsersFinder do
it
'returns all users'
do
users
=
described_class
.
new
(
admin
).
execute
expect
(
users
).
to
contain_exactly
(
admin
,
user1
,
user2
,
external_user
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
admin
,
normal_user
,
blocked_user
,
external_user
,
omniauth_user
)
end
it
'filters by custom attributes'
do
create
:user_custom_attribute
,
user:
user1
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
user1
,
key:
'bar'
,
value:
'bar'
create
:user_custom_attribute
,
user:
user2
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
normal_user
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
normal_user
,
key:
'bar'
,
value:
'bar'
create
:user_custom_attribute
,
user:
blocked_user
,
key:
'foo'
,
value:
'foo'
users
=
described_class
.
new
(
admin
,
custom_attributes:
{
foo:
'foo'
,
bar:
'bar'
}
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
end
end
...
...
spec/support/shared_contexts/finders/users_finder_shared_contexts.rb
0 → 100644
View file @
0750638f
require
'spec_helper'
RSpec
.
shared_context
'UsersFinder#execute filter by project context'
do
set
(
:normal_user
)
{
create
(
:user
,
username:
'johndoe'
)
}
set
(
:blocked_user
)
{
create
(
:user
,
:blocked
,
username:
'notsorandom'
)
}
set
(
:external_user
)
{
create
(
:user
,
:external
)
}
set
(
:omniauth_user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
end
spec/support/shared_examples/snippet_visibility_shared_examples.rb
View file @
0750638f
...
...
@@ -10,14 +10,6 @@ RSpec.shared_examples 'snippet visibility' do
set
(
:member
)
{
create
(
:user
)
}
set
(
:external
)
{
create
(
:user
,
:external
)
}
let!
(
:snippet_type_visibilities
)
do
{
public:
Snippet
::
PUBLIC
,
internal:
Snippet
::
INTERNAL
,
private:
Snippet
::
PRIVATE
}
end
context
"For project snippets"
do
let!
(
:users
)
do
{
...
...
@@ -29,14 +21,6 @@ RSpec.shared_examples 'snippet visibility' do
}
end
let
(
:project_feature_visibilities
)
do
{
enabled:
ProjectFeature
::
ENABLED
,
private:
ProjectFeature
::
PRIVATE
,
disabled:
ProjectFeature
::
DISABLED
}
end
where
(
:project_type
,
:feature_visibility
,
:user_type
,
:snippet_type
,
:outcome
)
do
[
# Public projects
...
...
@@ -277,26 +261,26 @@ RSpec.shared_examples 'snippet visibility' do
where
(
:snippet_visibility
,
:user_type
,
:outcome
)
do
[
[
:public
,
:unauthenticated
,
true
],
[
:public
,
:external
,
true
],
[
:public
,
:non_member
,
true
],
[
:public
,
:author
,
true
],
[
:internal
,
:unauthenticated
,
false
],
[
:internal
,
:external
,
false
],
[
:internal
,
:non_member
,
true
],
[
:internal
,
:author
,
true
],
[
:private
,
:unauthenticated
,
false
],
[
:private
,
:external
,
false
],
[
:private
,
:non_member
,
false
],
[
:private
,
:author
,
true
]
[
Snippet
::
PUBLIC
,
:unauthenticated
,
true
],
[
Snippet
::
PUBLIC
,
:external
,
true
],
[
Snippet
::
PUBLIC
,
:non_member
,
true
],
[
Snippet
::
PUBLIC
,
:author
,
true
],
[
Snippet
::
INTERNAL
,
:unauthenticated
,
false
],
[
Snippet
::
INTERNAL
,
:external
,
false
],
[
Snippet
::
INTERNAL
,
:non_member
,
true
],
[
Snippet
::
INTERNAL
,
:author
,
true
],
[
Snippet
::
PRIVATE
,
:unauthenticated
,
false
],
[
Snippet
::
PRIVATE
,
:external
,
false
],
[
Snippet
::
PRIVATE
,
:non_member
,
false
],
[
Snippet
::
PRIVATE
,
:author
,
true
]
]
end
with_them
do
let!
(
:user
)
{
users
[
user_type
]
}
let!
(
:snippet
)
{
create
(
:personal_snippet
,
visibility_level:
snippet_
type_visibilities
[
snippet_visibility
]
,
author:
author
)
}
let!
(
:snippet
)
{
create
(
:personal_snippet
,
visibility_level:
snippet_
visibility
,
author:
author
)
}
context
"For personal and
#{
params
[
:snippet_visibility
]
}
snippets with
#{
params
[
:user_type
]
}
user"
do
it
'should agree with read_personal_snippet policy'
do
...
...
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