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
833f6eef
Commit
833f6eef
authored
Feb 20, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
d536d979
c7787f44
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
6 deletions
+47
-6
app/services/concerns/users/participable_service.rb
app/services/concerns/users/participable_service.rb
+9
-6
spec/controllers/projects/autocomplete_sources_controller_spec.rb
...trollers/projects/autocomplete_sources_controller_spec.rb
+38
-0
No files found.
app/services/concerns/users/participable_service.rb
View file @
833f6eef
...
@@ -11,7 +11,7 @@ module Users
...
@@ -11,7 +11,7 @@ module Users
def
noteable_owner
def
noteable_owner
return
[]
unless
noteable
&&
noteable
.
author
.
present?
return
[]
unless
noteable
&&
noteable
.
author
.
present?
[
as_hash
(
noteable
.
author
)]
[
user_
as_hash
(
noteable
.
author
)]
end
end
def
participants_in_noteable
def
participants_in_noteable
...
@@ -23,21 +23,24 @@ module Users
...
@@ -23,21 +23,24 @@ module Users
def
sorted
(
users
)
def
sorted
(
users
)
users
.
uniq
.
to_a
.
compact
.
sort_by
(
&
:username
).
map
do
|
user
|
users
.
uniq
.
to_a
.
compact
.
sort_by
(
&
:username
).
map
do
|
user
|
as_hash
(
user
)
user_
as_hash
(
user
)
end
end
end
end
def
groups
def
groups
current_user
.
authorized_groups
.
sort_by
(
&
:path
).
map
do
|
group
|
current_user
.
authorized_groups
.
sort_by
(
&
:path
).
map
do
|
group
|
count
=
group
.
users
.
count
group_as_hash
(
group
)
{
username:
group
.
full_path
,
name:
group
.
full_name
,
count:
count
,
avatar_url:
group
.
avatar_url
}
end
end
end
end
private
private
def
as_hash
(
user
)
def
user_as_hash
(
user
)
{
username:
user
.
username
,
name:
user
.
name
,
avatar_url:
user
.
avatar_url
}
{
type:
user
.
class
.
name
,
username:
user
.
username
,
name:
user
.
name
,
avatar_url:
user
.
avatar_url
}
end
def
group_as_hash
(
group
)
{
type:
group
.
class
.
name
,
username:
group
.
full_path
,
name:
group
.
full_name
,
avatar_url:
group
.
avatar_url
,
count:
group
.
users
.
count
}
end
end
end
end
end
end
spec/controllers/projects/autocomplete_sources_controller_spec.rb
0 → 100644
View file @
833f6eef
# frozen_string_literal: true
require
'spec_helper'
describe
Projects
::
AutocompleteSourcesController
do
set
(
:group
)
{
create
(
:group
)
}
set
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
set
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
set
(
:user
)
{
create
(
:user
)
}
describe
'GET members'
do
before
do
group
.
add_owner
(
user
)
sign_in
(
user
)
end
it
'returns an array of member object'
do
get
:members
,
format: :json
,
params:
{
namespace_id:
group
.
path
,
project_id:
project
.
path
,
type:
issue
.
class
.
name
,
type_id:
issue
.
id
}
all
=
json_response
.
find
{
|
member
|
member
[
"username"
]
==
'all'
}
the_group
=
json_response
.
find
{
|
member
|
member
[
"username"
]
==
group
.
full_path
}
the_user
=
json_response
.
find
{
|
member
|
member
[
"username"
]
==
user
.
username
}
expect
(
all
.
symbolize_keys
).
to
include
(
username:
'all'
,
name:
'All Project and Group Members'
,
count:
1
)
expect
(
the_group
.
symbolize_keys
).
to
include
(
type:
group
.
class
.
name
,
name:
group
.
full_name
,
avatar_url:
group
.
avatar_url
,
count:
1
)
expect
(
the_user
.
symbolize_keys
).
to
include
(
type:
user
.
class
.
name
,
name:
user
.
name
,
avatar_url:
user
.
avatar_url
)
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