add some specs for group-member

This commit is contained in:
Alexander Machehin 2013-07-17 09:12:43 +06:00
parent 37e4fd92ac
commit 0c6a970be0
1 changed files with 21 additions and 0 deletions

View File

@ -228,6 +228,27 @@ describe CanCan do
end end
end end
context 'through group-member' do
before(:each) do
@group_member = FactoryGirl.create(:group)
@project.relations.create!(:actor_id => @group_member.id, :actor_type => 'Group', :role => 'reader')
@group_member_ability = Ability.new(@group_member.owner)
end
it 'should be able to read open project' do
@group_member_ability.should be_able_to(:read, @project)
end
it 'should be able to read closed project' do
@project.update_attribute :visibility, 'hidden'
@group_member_ability.should be_able_to(:read, @project)
end
it 'should include hidden project in list' do
@project.update_attribute :visibility, 'hidden'
Project.accessible_by(@group_member_ability, :show).where(:projects => {:id => @project.id}).count.should == 1
end
end
end end
context 'platform relations' do context 'platform relations' do