Commit ece9a17c authored by Mark Chao's avatar Mark Chao

Merge branch 'vij-fix-update-highest-role' into 'master'

Update a user highest role when removed from group

See merge request gitlab-org/gitlab!65164
parents 6a84e4f9 e443da4b
...@@ -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