From 0c6a970be0d7036ab08a1adb883f55c8c554273b Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 17 Jul 2013 09:12:43 +0600 Subject: [PATCH] add some specs for group-member --- spec/models/cancan_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/models/cancan_spec.rb b/spec/models/cancan_spec.rb index bf79241ad..9442eebfa 100644 --- a/spec/models/cancan_spec.rb +++ b/spec/models/cancan_spec.rb @@ -228,6 +228,27 @@ describe CanCan do 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 context 'platform relations' do