BigW Consortium Gitlab

Commit 394fe761 by Dmitriy Zaporozhets

Merge branch 'leave-group' into 'master'

User should be able to leave group. If not - show him proper message Signed-off-by: 's avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> See merge request !743
parents 907bbb2b 85de253e
...@@ -30,6 +30,7 @@ v 7.12.0 (unreleased) ...@@ -30,6 +30,7 @@ v 7.12.0 (unreleased)
- Clarify navigation labels for Project Settings and Group Settings. - Clarify navigation labels for Project Settings and Group Settings.
- Move user avatar and logout button to sidebar - Move user avatar and logout button to sidebar
- You can not remove user if he/she is an only owner of group - 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 v 7.11.4
- Fix missing bullets when creating lists - Fix missing bullets when creating lists
......
...@@ -66,9 +66,13 @@ class Groups::GroupMembersController < Groups::ApplicationController ...@@ -66,9 +66,13 @@ class Groups::GroupMembersController < Groups::ApplicationController
@group_member.destroy @group_member.destroy
redirect_to(dashboard_groups_path, notice: "You left #{group.name} group.") redirect_to(dashboard_groups_path, notice: "You left #{group.name} group.")
else else
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 return render_403
end end
end end
end
protected protected
......
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
%i.fa.fa-cogs %i.fa.fa-cogs
Settings 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: 'Leave this group' do
= 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 %i.fa.fa-sign-out
Leave Leave
......
...@@ -24,7 +24,8 @@ Feature: Dashboard Group ...@@ -24,7 +24,8 @@ Feature: Dashboard Group
When I visit dashboard groups page When I visit dashboard groups page
Then I should see group "Owned" in group list Then I should see group "Owned" in group list
Then I should see group "Guest" 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 @javascript
Scenario: Guest should be able to leave from group Scenario: Guest should be able to leave from group
......
...@@ -60,4 +60,8 @@ class Spinach::Features::DashboardGroup < Spinach::FeatureSteps ...@@ -60,4 +60,8 @@ class Spinach::Features::DashboardGroup < Spinach::FeatureSteps
page.should have_content "Samurai" page.should have_content "Samurai"
page.should have_content "Tokugawa Shogunate" page.should have_content "Tokugawa Shogunate"
end 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 end
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