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
35cae03c
Commit
35cae03c
authored
Feb 06, 2015
by
Valery Sizov
Committed by
Valery Sizov
Feb 11, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for ldap group integration
parent
f440c2e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
1 deletion
+28
-1
app/models/user.rb
app/models/user.rb
+2
-0
lib/api/users.rb
lib/api/users.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+14
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+11
-0
No files found.
app/models/user.rb
View file @
35cae03c
...
...
@@ -183,6 +183,8 @@ class User < ActiveRecord::Base
scope
:without_projects
,
->
{
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM members)'
)
}
scope
:subscribed_for_admin_email
,
->
{
where
(
admin_email_unsubscribed_at:
nil
)
}
scope
:ldap
,
->
{
joins
(
:identities
).
where
(
'identities.provider LIKE ?'
,
'ldap%'
)
}
scope
:non_ldap
,
->
{
joins
(
'LEFT JOIN identities ON identities.user_id = users.id'
).
where
(
'identities.provider IS NULL OR identities.provider NOT LIKE ?'
,
'ldap%'
)
}
scope
:potential_team_members
,
->
(
team
)
{
team
.
members
.
any?
?
active
.
not_in_team
(
team
)
:
active
}
#
...
...
lib/api/users.rb
View file @
35cae03c
...
...
@@ -13,7 +13,7 @@ module API
@users
=
User
.
all
@users
=
@users
.
active
if
params
[
:active
].
present?
@users
=
@users
.
where
(
'provider != ? OR provider IS NULL'
,
'ldap'
)
if
skip_ldap
@users
=
@users
.
non_ldap
if
skip_ldap
@users
=
@users
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@users
=
paginate
@users
...
...
spec/models/user_spec.rb
View file @
35cae03c
...
...
@@ -109,6 +109,20 @@ describe User do
end
end
describe
"scopes"
do
describe
"non_ldap"
do
it
"retuns non-ldap user"
do
create
:user
ldap_user
=
create
:omniauth_user
,
provider:
"ldapmain"
create
:omniauth_user
,
provider:
"gitlub"
users
=
User
.
non_ldap
users
.
count
.
should
==
2
users
.
detect
{
|
user
|
user
.
username
==
ldap_user
.
username
}.
should
be_nil
end
end
end
describe
"Respond to"
do
it
{
should
respond_to
(
:is_admin?
)
}
it
{
should
respond_to
(
:name
)
}
...
...
spec/requests/api/users_spec.rb
View file @
35cae03c
...
...
@@ -37,6 +37,17 @@ describe API::API, api: true do
json_response
.
first
.
keys
.
should
include
'can_create_project'
end
end
context
"when authenticated and ldap is enabled"
do
it
"should return non-ldap user"
do
create
:omniauth_user
,
provider:
"ldapserver1"
get
api
(
"/users"
,
user
),
skip_ldap:
"true"
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
username
=
user
.
username
json_response
.
first
[
"username"
].
should
==
username
end
end
end
describe
"GET /users/:id"
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