FIX: Group members should be able to see their groups even if private

This commit is contained in:
Robin Ward
2016-04-26 14:17:53 -04:00
parent b34f55d880
commit de82bd946d
2 changed files with 14 additions and 3 deletions

View File

@ -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