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
4911f5af
Commit
4911f5af
authored
Aug 08, 2016
by
Timothy Andrew
Committed by
Alfredo Sumaran
Aug 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only show users that have the `push_code` ability.
- While selecting user access for a protected branch.
parent
683a0920
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
10 deletions
+31
-10
app/assets/javascripts/protected_branches_access_select_ee.js.es6
...ts/javascripts/protected_branches_access_select_ee.js.es6
+2
-1
app/controllers/autocomplete_controller.rb
app/controllers/autocomplete_controller.rb
+14
-9
spec/controllers/autocomplete_controller_spec.rb
spec/controllers/autocomplete_controller_spec.rb
+15
-0
No files found.
app/assets/javascripts/protected_branches_access_select_ee.js.es6
View file @
4911f5af
...
...
@@ -103,7 +103,8 @@ class ProtectedBranchesAccessSelect {
search: query,
per_page: 20,
active: true,
project_id: gon.current_project_id
project_id: gon.current_project_id,
push_code: true
},
dataType: "json"
}).done(function(users) {
...
...
app/controllers/autocomplete_controller.rb
View file @
4911f5af
...
...
@@ -9,15 +9,7 @@ class AutocompleteController < ApplicationController
@users
=
@users
.
where
.
not
(
id:
params
[
:skip_users
])
if
params
[
:skip_users
].
present?
@users
=
@users
.
active
@users
=
@users
.
reorder
(
:name
)
if
params
[
:push_code_to_protected_branches
].
present?
&&
params
[
:project_id
].
present?
project
=
Project
.
find_by
(
id:
params
[
:project_id
])
@users
=
@users
.
to_a
.
select
{
|
user
|
user
.
can?
(
:push_code_to_protected_branches
,
project
)
}.
take
(
Kaminari
.
config
.
default_per_page
)
else
@users
=
@users
.
page
(
params
[
:page
])
end
@users
=
load_users_by_ability
||
@users
.
page
(
params
[
:page
])
if
params
[
:search
].
blank?
# Include current user if available to filter by "Me"
...
...
@@ -56,6 +48,19 @@ class AutocompleteController < ApplicationController
private
def
load_users_by_ability
ability
=
:push_code_to_protected_branches
if
params
[
:push_code_to_protected_branches
].
present?
ability
=
:push_code
if
params
[
:push_code
].
present?
return
if
params
[
:project_id
].
blank?
return
if
ability
.
blank?
project
=
Project
.
find_by
(
id:
params
[
:project_id
])
@users
.
to_a
.
select
{
|
user
|
user
.
can?
(
ability
,
project
)
}.
take
(
Kaminari
.
config
.
default_per_page
)
end
def
find_users
@users
=
if
@project
...
...
spec/controllers/autocomplete_controller_spec.rb
View file @
4911f5af
...
...
@@ -46,6 +46,21 @@ describe AutocompleteController do
it
{
expect
(
body
.
size
).
to
eq
1
}
it
{
expect
(
body
.
first
[
"username"
]).
to
eq
user
.
username
}
end
describe
"GET #users that can push code"
do
let
(
:reporter_user
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
reporter_user
,
:reporter
]
get
(
:users
,
project_id:
project
.
id
,
push_code:
'true'
)
end
let
(
:body
)
{
JSON
.
parse
(
response
.
body
)
}
it
{
expect
(
body
).
to
be_kind_of
(
Array
)
}
it
{
expect
(
body
.
size
).
to
eq
2
}
it
{
expect
(
body
.
map
{
|
user
|
user
[
"username"
]
}).
to
match_array
([
user
.
username
,
user2
.
username
])
}
end
end
context
'group members'
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