Rewrite project security model tests

This commit is contained in:
Dmitriy Zaporozhets 2012-12-05 17:06:15 +02:00
parent 674efd38d8
commit a350b52c9b
2 changed files with 94 additions and 11 deletions

View file

@ -36,6 +36,10 @@ class Project < ActiveRecord::Base
# Relations
belongs_to :group, foreign_key: "namespace_id", conditions: "type = 'Group'"
belongs_to :namespace
# TODO: replace owner with creator.
# With namespaces a project owner will be a namespace owner
# so this field makes sense only for global projects
belongs_to :owner, class_name: "User"
has_many :users, through: :users_projects
has_many :events, dependent: :destroy
@ -296,4 +300,12 @@ class Project < ActiveRecord::Base
def namespace_owner
namespace.try(:owner)
end
def chief
if namespace
namespace_owner
else
owner
end
end
end