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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
59981576
Commit
59981576
authored
Sep 12, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include `can_leave` for a group
parent
6388b8fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
app/serializers/group_child_entity.rb
app/serializers/group_child_entity.rb
+9
-1
spec/serializers/group_child_entity_spec.rb
spec/serializers/group_child_entity_spec.rb
+6
-0
No files found.
app/serializers/group_child_entity.rb
View file @
59981576
...
...
@@ -43,7 +43,7 @@ class GroupChildEntity < Grape::Entity
# Group only attributes
expose
:children_count
,
:leave_path
,
:parent_id
,
:number_projects_with_delimiter
,
:number_users_with_delimiter
,
:project_count
,
:subgroup_count
,
:number_users_with_delimiter
,
:project_count
,
:subgroup_count
,
:can_leave
,
unless:
lambda
{
|
_instance
,
_options
|
project?
}
def
children_finder
...
...
@@ -66,6 +66,14 @@ class GroupChildEntity < Grape::Entity
leave_group_group_members_path
(
object
)
end
def
can_leave
if
membership
=
object
.
members_and_requesters
.
find_by
(
user:
request
.
current_user
)
can?
(
request
.
current_user
,
:destroy_group_member
,
membership
)
else
false
end
end
def
number_projects_with_delimiter
number_with_delimiter
(
project_count
)
end
...
...
spec/serializers/group_child_entity_spec.rb
View file @
59981576
...
...
@@ -83,6 +83,12 @@ describe GroupChildEntity do
end
end
it
'allows an owner to leave when there is another one'
do
object
.
add_owner
(
create
(
:user
))
expect
(
json
[
:can_leave
]).
to
be_truthy
end
it_behaves_like
'group child json'
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