#321: added specs
This commit is contained in:
parent
77b23780be
commit
1c961deced
|
@ -60,7 +60,7 @@ class Ability
|
|||
can :remove_user, Group
|
||||
|
||||
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, :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
|
||||
|
|
|
@ -65,6 +65,12 @@ describe CanCan do
|
|||
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
|
||||
@ability.should_not be_able_to(:update, register_request)
|
||||
end
|
||||
|
@ -93,6 +99,12 @@ describe CanCan do
|
|||
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
|
||||
@ability.should be_able_to(:show, User)
|
||||
end
|
||||
|
@ -260,6 +272,13 @@ describe CanCan do
|
|||
before(:each) do
|
||||
@platform.owner = @user
|
||||
@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
|
||||
|
||||
[:read, :update, :destroy, :change_visibility].each do |action|
|
||||
|
@ -272,6 +291,13 @@ describe CanCan do
|
|||
context 'with read rights' do
|
||||
before(:each) do
|
||||
@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
|
||||
|
||||
it "should be able to read platform" do
|
||||
|
|
Loading…
Reference in New Issue