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
...
@@ -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
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
=
allow_gitaly_n_plus_1
{
create
(
:project
,
:private
,
group:
group
)
}
private_project
.
add_guest
(
user
)
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
}
params
=
{
group_id:
group
.
id
}
merge_requests
=
described_class
.
new
(
user
,
params
).
execute
merge_requests
=
described_class
.
new
(
user
,
params
).
execute
...
...
spec/finders/users_finder_spec.rb
View file @
76cf824f
...
@@ -2,10 +2,7 @@ require 'spec_helper'
...
@@ -2,10 +2,7 @@ require 'spec_helper'
describe
UsersFinder
do
describe
UsersFinder
do
describe
'#execute'
do
describe
'#execute'
do
let!
(
:user1
)
{
create
(
:user
,
username:
'johndoe'
)
}
include_context
'UsersFinder#execute filter by project context'
let!
(
:user2
)
{
create
(
:user
,
:blocked
,
username:
'notsorandom'
)
}
let!
(
:external_user
)
{
create
(
:user
,
:external
)
}
let!
(
:omniauth_user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
context
'with a normal user'
do
context
'with a normal user'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
@@ -13,59 +10,43 @@ describe UsersFinder do
...
@@ -13,59 +10,43 @@ describe UsersFinder do
it
'returns all users'
do
it
'returns all users'
do
users
=
described_class
.
new
(
user
).
execute
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
end
it
'filters by username'
do
it
'filters by username'
do
users
=
described_class
.
new
(
user
,
username:
'johndoe'
).
execute
users
=
described_class
.
new
(
user
,
username:
'johndoe'
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
end
it
'filters by username (case insensitive)'
do
it
'filters by username (case insensitive)'
do
users
=
described_class
.
new
(
user
,
username:
'joHNdoE'
).
execute
users
=
described_class
.
new
(
user
,
username:
'joHNdoE'
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
end
it
'filters by search'
do
it
'filters by search'
do
users
=
described_class
.
new
(
user
,
search:
'orando'
).
execute
users
=
described_class
.
new
(
user
,
search:
'orando'
).
execute
expect
(
users
).
to
contain_exactly
(
user2
)
expect
(
users
).
to
contain_exactly
(
blocked_user
)
end
end
it
'filters by blocked users'
do
it
'filters by blocked users'
do
users
=
described_class
.
new
(
user
,
blocked:
true
).
execute
users
=
described_class
.
new
(
user
,
blocked:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user2
)
expect
(
users
).
to
contain_exactly
(
blocked_user
)
end
end
it
'filters by active users'
do
it
'filters by active users'
do
users
=
described_class
.
new
(
user
,
active:
true
).
execute
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
end
it
'returns no external users'
do
it
'returns no external users'
do
users
=
described_class
.
new
(
user
,
external:
true
).
execute
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
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
end
end
it
'filters by created_at'
do
it
'filters by created_at'
do
...
@@ -85,7 +66,7 @@ describe UsersFinder do
...
@@ -85,7 +66,7 @@ describe UsersFinder do
custom_attributes:
{
foo:
'bar'
}
custom_attributes:
{
foo:
'bar'
}
).
execute
).
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
end
end
...
@@ -101,20 +82,20 @@ describe UsersFinder do
...
@@ -101,20 +82,20 @@ describe UsersFinder do
it
'returns all users'
do
it
'returns all users'
do
users
=
described_class
.
new
(
admin
).
execute
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
end
it
'filters by custom attributes'
do
it
'filters by custom attributes'
do
create
:user_custom_attribute
,
user:
user1
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
normal_user
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
user1
,
key:
'bar'
,
value:
'bar'
create
:user_custom_attribute
,
user:
normal_user
,
key:
'bar'
,
value:
'bar'
create
:user_custom_attribute
,
user:
user2
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
blocked_user
,
key:
'foo'
,
value:
'foo'
users
=
described_class
.
new
(
users
=
described_class
.
new
(
admin
,
admin
,
custom_attributes:
{
foo:
'foo'
,
bar:
'bar'
}
custom_attributes:
{
foo:
'foo'
,
bar:
'bar'
}
).
execute
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
end
end
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
...
@@ -10,14 +10,6 @@ RSpec.shared_examples 'snippet visibility' do
set
(
:member
)
{
create
(
:user
)
}
set
(
:member
)
{
create
(
:user
)
}
set
(
:external
)
{
create
(
:user
,
:external
)
}
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
context
"For project snippets"
do
let!
(
:users
)
do
let!
(
:users
)
do
{
{
...
@@ -29,14 +21,6 @@ RSpec.shared_examples 'snippet visibility' do
...
@@ -29,14 +21,6 @@ RSpec.shared_examples 'snippet visibility' do
}
}
end
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
where
(
:project_type
,
:feature_visibility
,
:user_type
,
:snippet_type
,
:outcome
)
do
[
[
# Public projects
# Public projects
...
@@ -277,26 +261,26 @@ RSpec.shared_examples 'snippet visibility' do
...
@@ -277,26 +261,26 @@ RSpec.shared_examples 'snippet visibility' do
where
(
:snippet_visibility
,
:user_type
,
:outcome
)
do
where
(
:snippet_visibility
,
:user_type
,
:outcome
)
do
[
[
[
:public
,
:unauthenticated
,
true
],
[
Snippet
::
PUBLIC
,
:unauthenticated
,
true
],
[
:public
,
:external
,
true
],
[
Snippet
::
PUBLIC
,
:external
,
true
],
[
:public
,
:non_member
,
true
],
[
Snippet
::
PUBLIC
,
:non_member
,
true
],
[
:public
,
:author
,
true
],
[
Snippet
::
PUBLIC
,
:author
,
true
],
[
:internal
,
:unauthenticated
,
false
],
[
Snippet
::
INTERNAL
,
:unauthenticated
,
false
],
[
:internal
,
:external
,
false
],
[
Snippet
::
INTERNAL
,
:external
,
false
],
[
:internal
,
:non_member
,
true
],
[
Snippet
::
INTERNAL
,
:non_member
,
true
],
[
:internal
,
:author
,
true
],
[
Snippet
::
INTERNAL
,
:author
,
true
],
[
:private
,
:unauthenticated
,
false
],
[
Snippet
::
PRIVATE
,
:unauthenticated
,
false
],
[
:private
,
:external
,
false
],
[
Snippet
::
PRIVATE
,
:external
,
false
],
[
:private
,
:non_member
,
false
],
[
Snippet
::
PRIVATE
,
:non_member
,
false
],
[
:private
,
:author
,
true
]
[
Snippet
::
PRIVATE
,
:author
,
true
]
]
]
end
end
with_them
do
with_them
do
let!
(
:user
)
{
users
[
user_type
]
}
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
context
"For personal and
#{
params
[
:snippet_visibility
]
}
snippets with
#{
params
[
:user_type
]
}
user"
do
it
'should agree with read_personal_snippet policy'
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