mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
FIX: change title when primary group changes (#6602)
This commit is contained in:
parent
fc9aafaa6a
commit
38a9bc740d
@ -24,14 +24,7 @@ class GroupUser < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def set_primary_group
|
||||
if group.primary_group
|
||||
DB.exec("
|
||||
UPDATE users
|
||||
SET primary_group_id = :id
|
||||
WHERE id = :user_id",
|
||||
id: group.id, user_id: user_id
|
||||
)
|
||||
end
|
||||
user.update!(primary_group: group) if group.primary_group
|
||||
end
|
||||
|
||||
def remove_primary_group
|
||||
|
@ -710,11 +710,16 @@ describe Group do
|
||||
end
|
||||
|
||||
it "always sets user's primary group" do
|
||||
group.update(primary_group: true)
|
||||
group.update(primary_group: true, title: 'AAAA')
|
||||
expect { group.add(user) }.to change { user.reload.primary_group }.from(nil).to(group)
|
||||
|
||||
new_group = Fabricate(:group, primary_group: true)
|
||||
expect { new_group.add(user) }.to change { user.reload.primary_group }.from(group).to(new_group)
|
||||
new_group = Fabricate(:group, primary_group: true, title: 'BBBB')
|
||||
|
||||
expect {
|
||||
new_group.add(user)
|
||||
user.reload
|
||||
}.to change { user.primary_group }.from(group).to(new_group)
|
||||
.and change { user.title }.from('AAAA').to('BBBB')
|
||||
end
|
||||
|
||||
context 'when adding a user into a public group' do
|
||||
|
Loading…
Reference in New Issue
Block a user