BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
bceee987
Commit
bceee987
authored
Jun 18, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show 'Leave project' only if member can actually leave the project
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
654565c9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
6 deletions
+43
-6
_project.html.haml
app/views/layouts/nav/_project.html.haml
+6
-5
_project_settings.html.haml
app/views/layouts/nav/_project_settings.html.haml
+1
-1
member_leaves_project_spec.rb
spec/features/projects/members/member_leaves_project_spec.rb
+19
-0
owner_cannot_leave_project_spec.rb
...tures/projects/members/owner_cannot_leave_project_spec.rb
+16
-0
user_requests_access_spec.rb
spec/features/projects/members/user_requests_access_spec.rb
+1
-0
No files found.
app/views/layouts/nav/_project.html.haml
View file @
bceee987
...
...
@@ -5,19 +5,20 @@
=
icon
(
'cog'
)
=
icon
(
'caret-down'
)
%ul
.dropdown-menu.dropdown-menu-align-right
-
is_project_member
=
@project
.
users
.
exists?
(
current_user
.
id
)
-
access
=
@project
.
team
.
max_member_access
(
current_user
.
id
)
-
can_edit
=
can?
(
current_user
,
:admin_project
,
@project
)
-# We don't use @project.team.find_member because it searches for group members too...
-
member
=
@project
.
members
.
non_request
.
find_by
(
user_id:
current_user
.
id
)
-
can_leave
=
member
&&
can?
(
current_user
,
:destroy_project_member
,
member
)
=
render
'layouts/nav/project_settings'
,
access:
access
,
can_edit:
can_edit
=
render
'layouts/nav/project_settings'
,
can_edit:
can_edit
-
if
can_edit
||
is_project_member
-
if
can_edit
||
can_leave
%li
.divider
-
if
can_edit
%li
=
link_to
edit_project_path
(
@project
)
do
Edit Project
-
if
is_project_member
-
if
can_leave
%li
=
link_to
polymorphic_path
([
:leave
,
@project
,
:members
]),
data:
{
confirm:
leave_confirmation_message
(
@project
)
},
method: :delete
,
title:
'Leave project'
do
...
...
app/views/layouts/nav/_project_settings.html.haml
View file @
bceee987
...
...
@@ -3,7 +3,7 @@
=
link_to
namespace_project_project_members_path
(
@project
.
namespace
,
@project
),
title:
'Members'
,
class:
'team-tab tab'
do
%span
Members
-
if
access
&&
can_edit
-
if
can_edit
-
if
@project
.
allowed_to_share_with_group?
=
nav_link
(
controller: :group_links
)
do
=
link_to
namespace_project_group_links_path
(
@project
.
namespace
,
@project
),
title:
"Groups"
do
...
...
spec/features/projects/members/member_leaves_project_spec.rb
0 → 100644
View file @
bceee987
require
'spec_helper'
feature
'Projects > Members > Member leaves project'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
background
do
project
.
team
<<
[
user
,
:developer
]
login_as
(
user
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
end
scenario
'user leaves project'
do
click_link
'Leave Project'
expect
(
current_path
).
to
eq
(
dashboard_projects_path
)
expect
(
project
.
users
.
exists?
(
user
.
id
)).
to
be_falsey
end
end
spec/features/projects/members/owner_cannot_leave_project_spec.rb
0 → 100644
View file @
bceee987
require
'spec_helper'
feature
'Projects > Members > Owner cannot leave project'
,
feature:
true
do
let
(
:owner
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
background
do
project
.
team
<<
[
owner
,
:owner
]
login_as
(
owner
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
end
scenario
'user does not see a "Leave Project" link'
do
expect
(
page
).
not_to
have_content
'Leave Project'
end
end
spec/features/projects/members/user_requests_access_spec.rb
View file @
bceee987
...
...
@@ -21,6 +21,7 @@ feature 'Projects > Members > User requests access', feature: true do
expect
(
page
).
to
have_content
'Your request for access has been queued for review.'
expect
(
page
).
to
have_content
'Withdraw Access Request'
expect
(
page
).
not_to
have_content
'Leave Project'
end
scenario
'user is not listed in the project members page'
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