ability_spec.rb revision 8a03fefc49541c745e176a8a436c090e55358370
2N/Arequire 'spec_helper' 2N/A it 'not be allowed: new, create' do 32N/A it 'not be allowed some actions' do 38N/A it 'be allowed: new, create' do 38N/A it 'not be allowed some actions' do 2N/A it 'be allowed: new, create' do 34N/A it 'be allowed: edit, update, destroy, permissions, write' do 2N/A it 'not be allowed on other: edit, update, destroy, permissions' do 6N/A it 'not be allowed: edit, update, destroy, permissions' do 38N/A it 'not be allowed: anything' do it 'not be allowed: to manage' do it 'be allowed: to read' do it 'be allowed: to read and manage' do it 'be allowed: everything' do context 'Private read-only Repository' do it 'not be allowed: anything' do it 'not be allowed: to write' do it 'be allowed: to read' do it 'reader, editor should be allowed' do it 'owner should not be allowed' do it 'be allowed: edit, update, destroy' do %i(edit update destroy).each do |perm| should be_able_to(perm, create(:team_user, user: user).team) it 'be allowed: create, show, index' do %i(create show index).each do |perm| should be_able_to(perm, Team.new) it 'not be allowed: edit, update, destroy (without admin on team)' do %i(edit update destroy).each do |perm| should_not be_able_to(perm, @memberteam) it 'not be allowed: edit, update, destroy (without being on team)' do %i(edit update destroy).each do |perm| should_not be_able_to(perm, otherteam) let(:comment){ create :comment } subject(:ability){ Ability.new(comment.user, nil) } it 'destroy his own comment' do should be_able_to(:destroy, comment) it 'not be allowed to destroy others comment' do should_not be_able_to(:destroy, create(:comment)) subject(:ability){ Ability.new(create(:admin), nil) } it 'destroy others comment' do should be_able_to(:destroy, comment) context 'comments repository owner' do subject(:ability){ Ability.new(owner, nil) } create(:permission, subject: owner, role: 'owner', item: comment.commentable.repository) it 'destroy others comments for his repository' do should be_able_to(:destroy, comment) context 'comments repository editor' do subject(:ability){ Ability.new(owner, nil) } create(:permission, subject: owner, role: 'editor', item: comment.commentable.repository) it 'not destroy others comments for his repository' do should_not be_able_to(:destroy, comment)