#321: added specs

This commit is contained in:
Vokhmin Alexey V 2013-11-15 23:36:37 +04:00
parent 77b23780be
commit 1c961deced
2 changed files with 27 additions and 1 deletions

View File

@ -60,7 +60,7 @@ class Ability
can :remove_user, Group can :remove_user, Group
can :create, Project can :create, Project
can([:mass_import, :run_mass_import], Project) if user.platforms.select(&:main?).find{ |p| local_admin?(p) }.present? can([:mass_import, :run_mass_import], Project) if user.platforms.main.find{ |p| local_admin?(p) }.present?
can :read, Project, :visibility => 'open' can :read, Project, :visibility => 'open'
can [:read, :archive, :membered, :get_id], Project, :owner_type => 'User', :owner_id => user.id can [:read, :archive, :membered, :get_id], Project, :owner_type => 'User', :owner_id => user.id
can [:read, :archive, :membered, :get_id], Project, :owner_type => 'Group', :owner_id => user.group_ids can [:read, :archive, :membered, :get_id], Project, :owner_type => 'Group', :owner_id => user.group_ids

View File

@ -65,6 +65,12 @@ describe CanCan do
end end
end end
[:mass_import, :run_mass_import].each do |action|
it "should not be able to #{ action } project" do
@ability.should_not be_able_to(action, Project)
end
end
it 'should not be able to update register request' do it 'should not be able to update register request' do
@ability.should_not be_able_to(:update, register_request) @ability.should_not be_able_to(:update, register_request)
end end
@ -93,6 +99,12 @@ describe CanCan do
end end
end end
[:mass_import, :run_mass_import].each do |action|
it "should not be able to #{ action } project" do
@ability.should_not be_able_to(action, Project)
end
end
it "shoud be able to show user profile" do it "shoud be able to show user profile" do
@ability.should be_able_to(:show, User) @ability.should be_able_to(:show, User)
end end
@ -260,6 +272,13 @@ describe CanCan do
before(:each) do before(:each) do
@platform.owner = @user @platform.owner = @user
@platform.save @platform.save
@ability = Ability.new(@user)
end
[:mass_import, :run_mass_import].each do |action|
it "should be able to #{ action } project" do
@ability.should be_able_to(action, Project)
end
end end
[:read, :update, :destroy, :change_visibility].each do |action| [:read, :update, :destroy, :change_visibility].each do |action|
@ -272,6 +291,13 @@ describe CanCan do
context 'with read rights' do context 'with read rights' do
before(:each) do before(:each) do
@platform.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'reader') @platform.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'reader')
@ability = Ability.new(@user)
end
[:mass_import, :run_mass_import].each do |action|
it "should not be able to #{ action } project" do
@ability.should_not be_able_to(action, Project)
end
end end
it "should be able to read platform" do it "should be able to read platform" do