summaryrefslogtreecommitdiff
path: root/spec/models/project_security_spec.rb
diff options
context:
space:
mode:
authorgitlabhq <m@gitlabhq.com>2011-10-09 00:36:38 +0300
committergitlabhq <m@gitlabhq.com>2011-10-09 00:36:38 +0300
commit9ba1224867665844b117fa037e1465bb706b3685 (patch)
tree52fbfc1cdb55df21843965479c97be0c91121a9a /spec/models/project_security_spec.rb
parent93efff945215a4407afcaf0cba15ac601b56df0d (diff)
downloadgitlab-ce-9ba1224867665844b117fa037e1465bb706b3685.tar.gz
init commit
Diffstat (limited to 'spec/models/project_security_spec.rb')
-rw-r--r--spec/models/project_security_spec.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb
new file mode 100644
index 00000000000..8eb8ee80f6c
--- /dev/null
+++ b/spec/models/project_security_spec.rb
@@ -0,0 +1,57 @@
+require 'spec_helper'
+
+describe Project do
+ describe :authorization do
+ before do
+ @p1 = Factory :project
+ @u1 = Factory :user
+ @u2 = Factory :user
+ @abilities = Six.new
+ @abilities << Ability
+ end
+
+ describe :read do
+ before do
+ @p1.users_projects.create(:project => @p1, :user => @u1, :read => false)
+ @p1.users_projects.create(:project => @p1, :user => @u2, :read => true)
+ end
+
+ it { @abilities.allowed?(@u1, :read_project, @p1).should be_false }
+ it { @abilities.allowed?(@u2, :read_project, @p1).should be_true }
+ end
+
+ describe :write do
+ before do
+ @p1.users_projects.create(:project => @p1, :user => @u1, :write => false)
+ @p1.users_projects.create(:project => @p1, :user => @u2, :write => true)
+ end
+
+ it { @abilities.allowed?(@u1, :write_project, @p1).should be_false }
+ it { @abilities.allowed?(@u2, :write_project, @p1).should be_true }
+ end
+
+ describe :admin do
+ before do
+ @p1.users_projects.create(:project => @p1, :user => @u1, :admin => false)
+ @p1.users_projects.create(:project => @p1, :user => @u2, :admin => true)
+ 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)
+#
+