diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-05-29 13:35:05 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-05-29 13:35:05 +0000 |
commit | 394fe7614c3d8507b79ca41419f11bcde906ccae (patch) | |
tree | c6ea3084085d581edf8a2f9079850897e55741cc | |
parent | 907bbb2b05860be401c77b305721b35a2850ea71 (diff) | |
parent | 85de253ee10aa7821a212270a1940c6205533d38 (diff) | |
download | gitlab-ce-394fe7614c3d8507b79ca41419f11bcde906ccae.tar.gz |
Merge branch 'leave-group' into 'master'
User should be able to leave group. If not - show him proper message
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
See merge request !743
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/groups/group_members_controller.rb | 6 | ||||
-rw-r--r-- | app/views/dashboard/groups/index.html.haml | 7 | ||||
-rw-r--r-- | features/dashboard/group.feature | 3 | ||||
-rw-r--r-- | features/steps/dashboard/group.rb | 4 |
5 files changed, 15 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG index 43788f5c4d3..7d05c210dfc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -30,6 +30,7 @@ v 7.12.0 (unreleased) - Clarify navigation labels for Project Settings and Group Settings. - Move user avatar and logout button to sidebar - You can not remove user if he/she is an only owner of group + - User should be able to leave group. If not - show him proper message v 7.11.4 - Fix missing bullets when creating lists diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index a11c554a2af..040255f08e6 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -66,7 +66,11 @@ class Groups::GroupMembersController < Groups::ApplicationController @group_member.destroy redirect_to(dashboard_groups_path, notice: "You left #{group.name} group.") else - return render_403 + if @group.last_owner?(current_user) + redirect_to(dashboard_groups_path, alert: "You can not leave #{group.name} group because you're the last owner. Transfer or delete the group.") + else + return render_403 + end end end diff --git a/app/views/dashboard/groups/index.html.haml b/app/views/dashboard/groups/index.html.haml index 5ecd53cff84..cfb386e131f 100644 --- a/app/views/dashboard/groups/index.html.haml +++ b/app/views/dashboard/groups/index.html.haml @@ -23,10 +23,9 @@ %i.fa.fa-cogs Settings - - if can?(current_user, :destroy_group_member, group_member) - = link_to leave_group_group_members_path(group), data: { confirm: leave_group_message(group.name) }, method: :delete, class: "btn-sm btn btn-grouped", title: 'Remove user from group' do - %i.fa.fa-sign-out - Leave + = link_to leave_group_group_members_path(group), data: { confirm: leave_group_message(group.name) }, method: :delete, class: "btn-sm btn btn-grouped", title: 'Leave this group' do + %i.fa.fa-sign-out + Leave = image_tag group_icon(group), class: "avatar s40 avatar-tile" = link_to group, class: 'group-name' do diff --git a/features/dashboard/group.feature b/features/dashboard/group.feature index cf4b8d7283b..e3c01db2ebb 100644 --- a/features/dashboard/group.feature +++ b/features/dashboard/group.feature @@ -24,7 +24,8 @@ Feature: Dashboard Group When I visit dashboard groups page Then I should see group "Owned" in group list Then I should see group "Guest" in group list - Then I should not see the "Leave" button for group "Owned" + When I click on the "Leave" button for group "Owned" + Then I should see the "Can not leave message" @javascript Scenario: Guest should be able to leave from group diff --git a/features/steps/dashboard/group.rb b/features/steps/dashboard/group.rb index 8384df2fb59..aeea49320ff 100644 --- a/features/steps/dashboard/group.rb +++ b/features/steps/dashboard/group.rb @@ -60,4 +60,8 @@ class Spinach::Features::DashboardGroup < Spinach::FeatureSteps page.should have_content "Samurai" page.should have_content "Tokugawa Shogunate" end + + step 'I should see the "Can not leave message"' do + page.should have_content "You can not leave Owned group because you're the last owner" + end end |