mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:01:20 +08:00
FIX: Group members should be able to see their groups even if private
This commit is contained in:
@ -362,17 +362,24 @@ describe Guardian do
|
||||
|
||||
describe 'a Group' do
|
||||
let(:group) { Group.new }
|
||||
let(:invisible_group) { Group.new(visible: false) }
|
||||
let(:invisible_group) { Group.new(visible: false, name: 'invisible') }
|
||||
|
||||
it "returns true when the group is visible" do
|
||||
expect(Guardian.new.can_see?(group)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns true when the group is visible but the user is an admin" do
|
||||
it "returns true when the group is invisible but the user is an admin" do
|
||||
admin = Fabricate.build(:admin)
|
||||
expect(Guardian.new(admin).can_see?(invisible_group)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns true when the group is invisible but the user is a member" do
|
||||
invisible_group.save!
|
||||
member = Fabricate.build(:user)
|
||||
GroupUser.create(group: invisible_group, user: member)
|
||||
expect(Guardian.new(member).can_see?(invisible_group)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false when the group is invisible" do
|
||||
expect(Guardian.new.can_see?(invisible_group)).to be_falsey
|
||||
end
|
||||
|
Reference in New Issue
Block a user