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
76cf824f
Commit
76cf824f
authored
Mar 20, 2019
by
Rémy Coutable
Committed by
Robert Speicher
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EE] Extract EE-specific code from users_finder_spec.rb
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
355da208
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
65 deletions
+63
-65
ee/spec/finders/users_finder_spec.rb
ee/spec/finders/users_finder_spec.rb
+25
-0
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
-33
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.
ee/spec/finders/users_finder_spec.rb
0 → 100644
View file @
76cf824f
require
'spec_helper'
describe
UsersFinder
do
describe
'#execute'
do
include_context
'UsersFinder#execute filter by project context'
context
'with a normal user'
do
context
'with LDAP users'
do
let!
(
:ldap_user
)
{
create
(
:omniauth_user
,
provider:
'ldap'
)
}
it
'returns ldap users by default'
do
users
=
described_class
.
new
(
normal_user
).
execute
expect
(
users
).
to
contain_exactly
(
normal_user
,
blocked_user
,
omniauth_user
,
ldap_user
)
end
it
'returns only non-ldap users with skip_ldap: true'
do
users
=
described_class
.
new
(
normal_user
,
skip_ldap:
true
).
execute
expect
(
users
).
to
contain_exactly
(
normal_user
,
blocked_user
,
omniauth_user
)
end
end
end
end
end
spec/finders/merge_requests_finder_spec.rb
View file @
76cf824f
...
...
@@ -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 @
76cf824f
...
...
@@ -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,59 +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
)
end
context
'with LDAP users'
do
let!
(
:ldap_user
)
{
create
(
:omniauth_user
,
provider:
'ldap'
)
}
it
'returns ldap users by default'
do
users
=
described_class
.
new
(
user
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
user2
,
omniauth_user
,
ldap_user
)
end
it
'returns only non-ldap users with skip_ldap: true'
do
users
=
described_class
.
new
(
user
,
skip_ldap:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
user2
,
omniauth_user
)
end
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
blocked_user
,
omniauth_user
)
end
it
'filters by created_at'
do
...
...
@@ -85,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
...
...
@@ -101,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 @
76cf824f
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 @
76cf824f
...
...
@@ -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