mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: allow admins to choose a group as a primary group
FEATURE: allow admins to set a default title for a group
This commit is contained in:
parent
e143eb595f
commit
75890aed26
11 changed files with 220 additions and 19 deletions
|
@ -47,7 +47,73 @@ describe Group do
|
|||
Group[:staff].user_ids - [-1]
|
||||
end
|
||||
|
||||
it "Correctly handles primary group" do
|
||||
it "Correctly handles primary groups" do
|
||||
group = Fabricate(:group, primary_group: true)
|
||||
user = Fabricate(:user)
|
||||
|
||||
group.add(user)
|
||||
|
||||
user.reload
|
||||
expect(user.primary_group_id).to eq group.id
|
||||
|
||||
group.remove(user)
|
||||
|
||||
user.reload
|
||||
expect(user.primary_group_id).to eq nil
|
||||
|
||||
group.add(user)
|
||||
group.primary_group = false
|
||||
group.save
|
||||
|
||||
user.reload
|
||||
expect(user.primary_group_id).to eq nil
|
||||
|
||||
end
|
||||
|
||||
it "Correctly handles title" do
|
||||
|
||||
group = Fabricate(:group, title: 'Super Awesome')
|
||||
user = Fabricate(:user)
|
||||
|
||||
expect(user.title).to eq nil
|
||||
|
||||
group.add(user)
|
||||
user.reload
|
||||
|
||||
expect(user.title).to eq 'Super Awesome'
|
||||
|
||||
group.title = 'BOOM'
|
||||
group.save
|
||||
|
||||
user.reload
|
||||
expect(user.title).to eq 'BOOM'
|
||||
|
||||
group.title = nil
|
||||
group.save
|
||||
|
||||
user.reload
|
||||
expect(user.title).to eq nil
|
||||
|
||||
group.title = "BOB"
|
||||
group.save
|
||||
|
||||
user.reload
|
||||
expect(user.title).to eq "BOB"
|
||||
|
||||
group.remove(user)
|
||||
|
||||
user.reload
|
||||
expect(user.title).to eq nil
|
||||
|
||||
group.add(user)
|
||||
group.destroy
|
||||
|
||||
user.reload
|
||||
expect(user.title).to eq nil
|
||||
|
||||
end
|
||||
|
||||
it "Correctly handles removal of primary group" do
|
||||
group = Fabricate(:group)
|
||||
user = Fabricate(:user)
|
||||
group.add(user)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue