2011-10-08 17:36:38 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Project do
|
2011-10-26 09:46:25 -04:00
|
|
|
describe :authorization do
|
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
@p1 = Factory :project
|
|
|
|
@u1 = Factory :user
|
|
|
|
@u2 = Factory :user
|
|
|
|
@abilities = Six.new
|
|
|
|
@abilities << Ability
|
|
|
|
end
|
|
|
|
|
2011-12-07 02:48:44 -05:00
|
|
|
describe "read access" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2012-08-10 18:07:50 -04:00
|
|
|
@p1.users_projects.create(project: @p1, user: @u2, project_access: UsersProject::REPORTER)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it { @abilities.allowed?(@u1, :read_project, @p1).should be_false }
|
|
|
|
it { @abilities.allowed?(@u2, :read_project, @p1).should be_true }
|
|
|
|
end
|
|
|
|
|
2011-12-07 02:48:44 -05:00
|
|
|
describe "write access" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2012-08-10 18:07:50 -04:00
|
|
|
@p1.users_projects.create(project: @p1, user: @u2, project_access: UsersProject::DEVELOPER)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it { @abilities.allowed?(@u1, :write_project, @p1).should be_false }
|
|
|
|
it { @abilities.allowed?(@u2, :write_project, @p1).should be_true }
|
|
|
|
end
|
|
|
|
|
2011-12-07 02:48:44 -05:00
|
|
|
describe "admin access" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2012-08-10 18:07:50 -04:00
|
|
|
@p1.users_projects.create(project: @p1, user: @u1, project_access: UsersProject::DEVELOPER)
|
|
|
|
@p1.users_projects.create(project: @p1, user: @u2, project_access: UsersProject::MASTER)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it { @abilities.allowed?(@u1, :admin_project, @p1).should be_false }
|
|
|
|
it { @abilities.allowed?(@u2, :admin_project, @p1).should be_true }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: projects
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# name :string(255)
|
|
|
|
# path :string(255)
|
|
|
|
# description :text
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
# private_flag :boolean default(TRUE), not null
|
|
|
|
# code :string(255)
|
|
|
|
#
|
|
|
|
|