Commit e443da4b authored by Vijay Hawoldar's avatar Vijay Hawoldar

Update a user highest role when removed from group

If a user is removed from a group, their highest role should
be recalculated and updated

Changelog: fixed
parent 99b8cb27
...@@ -439,7 +439,7 @@ class Member < ApplicationRecord ...@@ -439,7 +439,7 @@ class Member < ApplicationRecord
def update_highest_role? def update_highest_role?
return unless user_id.present? return unless user_id.present?
previous_changes[:access_level].present? previous_changes[:access_level].present? || destroyed?
end end
def update_highest_role_attribute def update_highest_role_attribute
......
...@@ -706,7 +706,8 @@ RSpec.describe Member do ...@@ -706,7 +706,8 @@ RSpec.describe Member do
end end
context 'when after_commit :update_highest_role' do context 'when after_commit :update_highest_role' do
let!(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:user_id) { user.id } let(:user_id) { user.id }
where(:member_type, :source_type) do where(:member_type, :source_type) do
...@@ -741,7 +742,7 @@ RSpec.describe Member do ...@@ -741,7 +742,7 @@ RSpec.describe Member do
end end
describe 'destroy member' do describe 'destroy member' do
subject { member.destroy! } subject { member.reload.destroy! }
include_examples 'update highest role with exclusive lease' include_examples 'update highest role with exclusive lease'
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