mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FEATURE: match user title when primary group changes
When primary group changes and the user's title is the previous primary group's title, change the title to the new primary group's title
This commit is contained in:
@ -1814,4 +1814,16 @@ describe User do
|
||||
|
||||
end
|
||||
|
||||
describe '#match_title_to_primary_group_changes' do
|
||||
let(:primary_group_a) { Fabricate(:group, title: 'A', users: [user]) }
|
||||
let(:primary_group_b) { Fabricate(:group, title: 'B', users: [user]) }
|
||||
|
||||
it "updates user's title only when it is blank or matches the previous primary group" do
|
||||
expect { user.update(primary_group: primary_group_a) }.to change { user.reload.title }.from(nil).to('A')
|
||||
expect { user.update(primary_group: primary_group_b) }.to change { user.reload.title }.from('A').to('B')
|
||||
|
||||
user.update(title: 'Different')
|
||||
expect { user.update(primary_group: primary_group_a) }.to_not change { user.reload.title }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user