Commit bf05ca88 authored by Rémy Coutable's avatar Rémy Coutable

Add 'Leave Group' link

The link was removed in !3798, probably by mistake.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent bceee987
- if current_user - if current_user
- if access = @group.users.find_by(id: current_user.id) - can_edit = can?(current_user, :admin_group, @group)
.controls - member = @group.members.non_request.find_by(user_id: current_user.id)
.dropdown.group-settings-dropdown - can_leave = member && can?(current_user, :destroy_group_member, member)
%a.dropdown-new.btn.btn-default#group-settings-button{href: '#', 'data-toggle' => 'dropdown'}
= icon('cog') .controls
= icon('caret-down') .dropdown.group-settings-dropdown
%ul.dropdown-menu.dropdown-menu-align-right %a.dropdown-new.btn.btn-default#group-settings-button{href: '#', 'data-toggle' => 'dropdown'}
- if can?(current_user, :admin_group, @group) = icon('cog')
= nav_link(path: 'groups#projects') do = icon('caret-down')
= link_to projects_group_path(@group), title: 'Projects' do %ul.dropdown-menu.dropdown-menu-align-right
Projects = nav_link(path: 'groups#projects') do
%li.divider = link_to 'Projects', projects_group_path(@group), title: 'Projects'
%li %li.divider
= link_to edit_group_path(@group) do - if can_edit
Edit Group %li
= link_to 'Edit Group', edit_group_path(@group)
- if can_leave
%li
= link_to polymorphic_path([:leave, @group, :members]),
data: { confirm: leave_confirmation_message(@group) }, method: :delete, title: 'Leave group' do
Leave Group
require 'spec_helper'
feature 'Groups > Members > Last owner cannot leave group', feature: true do
let(:owner) { create(:user) }
let(:group) { create(:group) }
background do
group.add_owner(owner)
login_as(owner)
visit group_path(group)
end
scenario 'user does not see a "Leave Group" link' do
expect(page).not_to have_content 'Leave Group'
end
end
require 'spec_helper'
feature 'Groups > Members > Member leaves group', feature: true do
let(:user) { create(:user) }
let(:owner) { create(:user) }
let(:group) { create(:group, :public) }
background do
group.add_owner(owner)
group.add_developer(user)
login_as(user)
visit group_path(group)
end
scenario 'user leaves group' do
# find('#group-settings-button').click
click_link 'Leave Group'
expect(current_path).to eq(dashboard_groups_path)
expect(group.users.exists?(user.id)).to be_falsey
end
end
...@@ -21,6 +21,7 @@ feature 'Groups > Members > User requests access', feature: true do ...@@ -21,6 +21,7 @@ feature 'Groups > 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 'Your request for access has been queued for review.'
expect(page).to have_content 'Withdraw Access Request' expect(page).to have_content 'Withdraw Access Request'
expect(page).not_to have_content 'Leave Group'
end end
scenario 'user is not listed in the group members page' do scenario 'user is not listed in the group members page' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment