Merge branch 'master' into 90-pull
Conflicts: app/models/project.rb db/schema.rb
This commit is contained in:
commit
9e5db741d3
|
@ -816,6 +816,10 @@ ul.ui-autocomplete.has_results {
|
|||
overflow: auto;
|
||||
}
|
||||
|
||||
#add_collaborator_form div.admin-search.withimage {
|
||||
width: 301px;
|
||||
}
|
||||
|
||||
#add_collaborator_form div.search_string {
|
||||
margin-left: 5px;
|
||||
float: left;
|
||||
|
@ -824,13 +828,9 @@ ul.ui-autocomplete.has_results {
|
|||
#add_collaborator_form div.img {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
// border: 1px solid #DDDDDD;
|
||||
// border-radius: 2px;
|
||||
}
|
||||
|
||||
#add_collaborator_form div.img img {
|
||||
// margin-top: 1px;
|
||||
// margin-left: 1px;
|
||||
}
|
||||
|
||||
#add_collaborator_form .admin-role .lineForm {
|
||||
|
|
|
@ -41,7 +41,8 @@ class BuildListsController < ApplicationController
|
|||
|
||||
def create
|
||||
notices, errors = [], []
|
||||
params[:build_list].delete(:auto_publish) if @platform.released
|
||||
# Disable auto_publish if platform released
|
||||
params[:build_list][:auto_publish] = false if @platform.released
|
||||
Arch.where(:id => params[:arches]).each do |arch|
|
||||
Platform.main.where(:id => params[:bpls]).each do |bpl|
|
||||
@build_list = @project.build_lists.build(params[:build_list])
|
||||
|
|
|
@ -39,7 +39,6 @@ class CollaboratorsController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
puts params.inspect
|
||||
@collaborator = Collaborator.new(params[:collaborator])
|
||||
@collaborator.project = @project
|
||||
if @collaborator.save
|
||||
|
|
|
@ -20,6 +20,9 @@ class Git::TreesController < Git::BaseController
|
|||
treeish = params[:treeish].presence || @project.default_branch
|
||||
format = params[:format] || 'tar'
|
||||
commit = @project.git_repository.log(treeish, nil, :max_count => 1).first
|
||||
if !commit or !['tar', 'zip'].include?(format)
|
||||
raise ActiveRecord::RecordNotFound#("Couldn't send Project archive with id=#{@project.id}, treeish=#{treeish} and format=#{format}")
|
||||
end
|
||||
name = "#{@project.owner.uname}-#{@project.name}#{@project.tags.include?(treeish) ? "-#{treeish}" : ''}-#{commit.id[0..19]}"
|
||||
fullname = "#{name}.#{format == 'tar' ? 'tar.gz' : 'zip'}"
|
||||
file = Tempfile.new fullname, 'tmp'
|
||||
|
|
|
@ -33,10 +33,10 @@ class MembersController < ApplicationController
|
|||
params['user'].keys.each { |user_id|
|
||||
role = params['user'][user_id]
|
||||
|
||||
if relation = parent.objects.find_by_object_id_and_object_type(user_id, 'User')
|
||||
if relation = parent.actors.where(:actor_id => user_id, :actor_type => 'User') #find_by_actor_id_and_actor_type(user_id, 'User')
|
||||
relation.update_attribute(:role, role)
|
||||
else
|
||||
relation = parent.objects.build(:object_id => user_id, :object_type => 'User', :role => role)
|
||||
relation = parent.actors.build(:actor_id => user_id, :actor_type => 'User', :role => role)
|
||||
relation.save!
|
||||
end
|
||||
} if params['user']
|
||||
|
@ -53,7 +53,7 @@ class MembersController < ApplicationController
|
|||
def remove
|
||||
if params[:id]
|
||||
u = User.find(params[:id])
|
||||
Relation.by_object(u).by_target(parent)[0].destroy
|
||||
Relation.by_actor(u).by_target(parent)[0].destroy
|
||||
|
||||
redirect_to groups_path
|
||||
else
|
||||
|
@ -65,7 +65,7 @@ class MembersController < ApplicationController
|
|||
|
||||
all_user_ids.each do |user_id|
|
||||
u = User.find(user_id)
|
||||
Relation.by_object(u).by_target(parent).each {|r| r.destroy}
|
||||
Relation.by_actor(u).by_target(parent).each {|r| r.destroy}
|
||||
end
|
||||
|
||||
redirect_to edit_group_members_path(parent)
|
||||
|
@ -75,8 +75,8 @@ class MembersController < ApplicationController
|
|||
def add
|
||||
if params['user_id'] and !params['user_id'].empty?
|
||||
@user = User.find_by_uname(params['user_id'])
|
||||
unless parent.objects.exists? :object_id => @user.id, :object_type => 'User'
|
||||
relation = parent.objects.build(:object_id => @user.id, :object_type => 'User', :role => params[:role])
|
||||
unless parent.actors.exists? :actor_id => @user.id, :actor_type => 'User'
|
||||
relation = parent.actors.build(:actor_id => @user.id, :actor_type => 'User', :role => params[:role])
|
||||
if relation.save
|
||||
flash[:notice] = t("flash.members.successfully_added")
|
||||
else
|
||||
|
|
|
@ -95,14 +95,14 @@ class PlatformsController < ApplicationController
|
|||
def remove_members
|
||||
all_user_ids = params['user_remove'].inject([]) {|a, (k, v)| a << k if v.first == '1'; a}
|
||||
all_user_ids.each do |uid|
|
||||
Relation.by_target(@platform).where(:object_id => uid, :object_type => 'User').each{|r| r.destroy}
|
||||
Relation.by_target(@platform).where(:actor_id => uid, :actor_type => 'User').each{|r| r.destroy}
|
||||
end
|
||||
redirect_to members_platform_path(@platform)
|
||||
end
|
||||
|
||||
def remove_member
|
||||
u = User.find(params[:member_id])
|
||||
Relation.by_object(u).by_target(@platform).each{|r| r.destroy}
|
||||
Relation.by_actor(u).by_target(@platform).each{|r| r.destroy}
|
||||
|
||||
redirect_to members_platform_path(@platform)
|
||||
end
|
||||
|
@ -110,11 +110,11 @@ class PlatformsController < ApplicationController
|
|||
def add_member
|
||||
if params[:member_id].present?
|
||||
member = User.find(params[:member_id])
|
||||
if @platform.relations.exists?(:object_id => member.id, :object_type => member.class.to_s) or @platform.owner == member
|
||||
if @platform.relations.exists?(:actor_id => member.id, :actor_type => member.class.to_s) or @platform.owner == member
|
||||
flash[:warning] = t('flash.platform.members.already_added', :name => member.uname)
|
||||
else
|
||||
rel = @platform.relations.build(:role => 'admin')
|
||||
rel.object = member
|
||||
rel.actor = member
|
||||
if rel.save
|
||||
flash[:notice] = t('flash.platform.members.successfully_added', :name => member.uname)
|
||||
else
|
||||
|
|
|
@ -28,7 +28,7 @@ module ProjectsHelper
|
|||
end
|
||||
|
||||
def alone_member?(project)
|
||||
Relation.by_target(project).by_object(current_user).size > 0
|
||||
Relation.by_target(project).by_actor(current_user).size > 0
|
||||
end
|
||||
|
||||
def participant_path(participant)
|
||||
|
|
|
@ -46,7 +46,7 @@ class Ability
|
|||
|
||||
can [:read, :create, :autocomplete_group_uname], Group
|
||||
can [:update, :manage_members], Group do |group|
|
||||
group.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin') # or group.owner_id = user.id
|
||||
group.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin') # or group.owner_id = user.id
|
||||
end
|
||||
can :destroy, Group, :owner_id => user.id
|
||||
|
||||
|
@ -60,7 +60,7 @@ class Ability
|
|||
can(:fork, Project) {|project| can? :read, project}
|
||||
can(:fork_to_group, Project) {|project| project.owner_type == 'Group' and can? :update, project.owner}
|
||||
can(:destroy, Project) {|project| owner? project}
|
||||
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin')}
|
||||
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')}
|
||||
can :remove_user, Project
|
||||
|
||||
can [:read, :owned], BuildList, :user_id => user.id
|
||||
|
@ -81,7 +81,7 @@ class Ability
|
|||
can [:read, :related, :members], Platform, :owner_type => 'Group', :owner_id => user.group_ids
|
||||
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
||||
can([:update, :members], Platform) {|platform| local_admin? platform}
|
||||
can([:destroy, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner? platform}
|
||||
can([:destroy, :members, :add_member, :remove_member, :remove_members, :build_all] , Platform) {|platform| owner? platform}
|
||||
can :autocomplete_user_uname, Platform
|
||||
|
||||
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
|
||||
|
@ -143,28 +143,28 @@ class Ability
|
|||
parent ||= table
|
||||
["#{table}.#{key} IN (
|
||||
SELECT target_id FROM relations WHERE relations.target_type = ? AND
|
||||
(relations.object_type = 'User' AND relations.object_id = ? OR
|
||||
relations.object_type = 'Group' AND relations.object_id IN (?)))", parent.classify, @user, @user.group_ids]
|
||||
(relations.actor_type = 'User' AND relations.actor_id = ? OR
|
||||
relations.actor_type = 'Group' AND relations.actor_id IN (?)))", parent.classify, @user, @user.group_ids]
|
||||
end
|
||||
|
||||
def relation_exists_for(object, roles)
|
||||
object.relations.exists?(:object_id => @user.id, :object_type => 'User', :role => roles) or
|
||||
object.relations.exists?(:object_id => @user.group_ids, :object_type => 'Group', :role => roles)
|
||||
def relation_exists_for(target, roles)
|
||||
target.relations.exists?(:actor_id => @user.id, :actor_type => 'User', :role => roles) or
|
||||
target.relations.exists?(:actor_id => @user.group_ids, :actor_type => 'Group', :role => roles)
|
||||
end
|
||||
|
||||
def local_reader?(object)
|
||||
relation_exists_for(object, %w{reader writer admin}) or owner?(object)
|
||||
def local_reader?(target)
|
||||
relation_exists_for(target, %w{reader writer admin}) or owner?(target)
|
||||
end
|
||||
|
||||
def local_writer?(object)
|
||||
relation_exists_for(object, %w{writer admin}) or owner?(object)
|
||||
def local_writer?(target)
|
||||
relation_exists_for(target, %w{writer admin}) or owner?(target)
|
||||
end
|
||||
|
||||
def local_admin?(object)
|
||||
relation_exists_for(object, 'admin') or owner?(object)
|
||||
def local_admin?(target)
|
||||
relation_exists_for(target, 'admin') or owner?(target)
|
||||
end
|
||||
|
||||
def owner?(object)
|
||||
object.owner == @user or @user.own_groups.include?(object.owner)
|
||||
def owner?(target)
|
||||
target.owner == @user or @user.own_groups.include?(target.owner)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ class Collaborator
|
|||
def find_by_project(project)
|
||||
res = []
|
||||
project.relations.each do |r|
|
||||
res << from_relation(r) unless project.owner_id == r.object_id and project.owner_type == r.object_type
|
||||
res << from_relation(r) unless project.owner_id == r.actor_id and project.owner_type == r.actor_type
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
@ -27,11 +27,14 @@ class Collaborator
|
|||
end
|
||||
|
||||
def create(args)
|
||||
self.new(args).save
|
||||
c = self.new(args)
|
||||
return c.save ? c : false
|
||||
end
|
||||
|
||||
def create!(args)
|
||||
self.new(args).save!
|
||||
c = self.new(args)
|
||||
c.save!
|
||||
return c
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -49,11 +52,7 @@ class Collaborator
|
|||
@actor = args[:actor_type].classify.constantize.find(args[:actor_id])
|
||||
end
|
||||
|
||||
if @relation.nil? and @actor.present? and @project.present?
|
||||
@relation = Relation.by_object(@actor).by_target(@project).limit(1).first
|
||||
@relation ||= Relation.new(:object => @actor, :target => @project)
|
||||
end
|
||||
@relation.role = args[:role] if @relation.present? and args[:role].present?
|
||||
relation.role = args[:role] if args[:role].present? #if @relation.present? and args[:role].present?
|
||||
end
|
||||
|
||||
def update_attributes(attributes, options = {})
|
||||
|
@ -65,12 +64,12 @@ class Collaborator
|
|||
|
||||
def relation=(model)
|
||||
@relation = model
|
||||
@actor = @relation.object
|
||||
@actor = @relation.actor
|
||||
@project = @relation.target
|
||||
end
|
||||
|
||||
def id
|
||||
@relation.try(:id)
|
||||
relation.try(:id)
|
||||
end
|
||||
|
||||
def actor_id
|
||||
|
@ -94,23 +93,23 @@ class Collaborator
|
|||
end
|
||||
|
||||
def role
|
||||
@relation.try(:role)
|
||||
relation.try(:role)
|
||||
end
|
||||
|
||||
def role=(arg)
|
||||
@relation.role = arg
|
||||
relation.role = arg
|
||||
end
|
||||
|
||||
def save
|
||||
@relation.try(:save)
|
||||
relation.try(:save)
|
||||
end
|
||||
|
||||
def save!
|
||||
@relation.try(:save!)
|
||||
relation.try(:save!)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@relation.try(:destroy)
|
||||
relation.try(:destroy)
|
||||
end
|
||||
|
||||
def attributes
|
||||
|
@ -135,15 +134,15 @@ class Collaborator
|
|||
end
|
||||
|
||||
def relation
|
||||
return @relation if @relation.present? and @relation.object == @actor and @relation.target == @project
|
||||
return @relation if @relation.present? and @relation.actor == @actor and @relation.target == @project
|
||||
|
||||
if @actor.present? and @project.present?
|
||||
@relation = Relation.by_object(@actor).by_target(@project).limit(1).first
|
||||
@relation ||= Relation.new(:object_id => @actor.id, :object_type => @actor.class.to_s,
|
||||
@relation = Relation.by_actor(@actor).by_target(@project).limit(1).first
|
||||
@relation ||= Relation.new(:actor_id => @actor.id, :actor_type => @actor.class.to_s,
|
||||
:target_id => @project.id, :target_type => 'Project')
|
||||
else
|
||||
@relation = Relation.new
|
||||
@relation.object = @actor
|
||||
@relation.actor = @actor
|
||||
@relation.target = @project
|
||||
end
|
||||
@relation
|
||||
|
|
|
@ -61,7 +61,7 @@ class Comment < ActiveRecord::Base
|
|||
if issue_comment?
|
||||
commentable.subscribes.create(:user => user) if !commentable.subscribes.exists?(:user_id => user.id)
|
||||
elsif commit_comment?
|
||||
recipients = project.relations.by_role('admin').where(:object_type => 'User').map &:object # admins
|
||||
recipients = project.relations.by_role('admin').where(:actor_type => 'User').map &:actor # admins
|
||||
recipients << user << User.where(:email => commentable.committer.email).first # commentor and committer
|
||||
recipients << project.owner if project.owner_type == 'User' # project owner
|
||||
recipients.compact.uniq.each do |user|
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class EventLog < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :object, :polymorphic => true
|
||||
belongs_to :eventable, :polymorphic => true
|
||||
|
||||
# self.per_page = 1
|
||||
|
||||
|
@ -10,7 +10,7 @@ class EventLog < ActiveRecord::Base
|
|||
|
||||
before_create do
|
||||
self.user_name = user.try(:uname) || 'guest'
|
||||
self.object_name ||= object.name if object.respond_to?(:name)
|
||||
self.eventable_name ||= eventable.name if eventable.respond_to?(:name)
|
||||
end
|
||||
# after_create { self.class.current_controller = nil }
|
||||
|
||||
|
|
|
@ -3,24 +3,24 @@ class EventLogObserver < ActiveRecord::Observer
|
|||
observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :product_build_list
|
||||
|
||||
def after_create(record)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => record)
|
||||
end
|
||||
|
||||
def before_update(record)
|
||||
case record.class.to_s
|
||||
when 'BuildList'
|
||||
if record.status_changed? and [BuildList::BUILD_CANCELED, BuildList::BUILD_PUBLISHED].include?(record.status)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => record)
|
||||
end
|
||||
when 'Platform'
|
||||
if record.visibility_changed?
|
||||
ActiveSupport::Notifications.instrument "event_log.observer", :object => record,
|
||||
ActiveSupport::Notifications.instrument "event_log.observer", :eventable => record,
|
||||
:message => I18n.t("activerecord.attributes.platform.visibility_types.#{record.visibility}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def after_destroy(record)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => record)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
class Group < ActiveRecord::Base
|
||||
belongs_to :owner, :class_name => 'User'
|
||||
|
||||
has_many :relations, :as => :object, :dependent => :destroy
|
||||
has_many :objects, :as => :target, :class_name => 'Relation'
|
||||
has_many :targets, :as => :object, :class_name => 'Relation'
|
||||
has_many :relations, :as => :actor, :dependent => :destroy
|
||||
has_many :actors, :as => :target, :class_name => 'Relation'
|
||||
has_many :targets, :as => :actor, :class_name => 'Relation'
|
||||
|
||||
has_many :members, :through => :objects, :source => :object, :source_type => 'User', :autosave => true
|
||||
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
||||
has_many :members, :through => :actors, :source => :actor, :source_type => 'User', :autosave => true
|
||||
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
||||
|
||||
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
|
||||
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
|
||||
|
@ -18,7 +18,7 @@ class Group < ActiveRecord::Base
|
|||
|
||||
scope :opened, where('1=1')
|
||||
scope :by_owner, lambda {|owner| where(:owner_id => owner.id)}
|
||||
scope :by_admin, lambda {|admin| joins(:objects).where(:'relations.role' => 'admin', :'relations.object_id' => admin.id, :'relations.object_type' => 'User')}
|
||||
scope :by_admin, lambda {|admin| joins(:actors).where(:'relations.role' => 'admin', :'relations.actor_id' => admin.id, :'relations.actor_type' => 'User')}
|
||||
|
||||
include Modules::Models::ActsLikeMember
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class Issue < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def collect_recipient_ids
|
||||
recipients = self.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) }
|
||||
recipients = self.project.relations.by_role('admin').where(:actor_type => 'User').map { |rel| rel.read_attribute(:actor_id) }
|
||||
recipients = recipients | [self.assignee_id] if self.assignee_id
|
||||
recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User'
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ class Platform < ActiveRecord::Base
|
|||
has_many :products, :dependent => :destroy
|
||||
|
||||
has_many :relations, :as => :target, :dependent => :destroy
|
||||
has_many :objects, :as => :target, :class_name => 'Relation', :dependent => :destroy
|
||||
has_many :members, :through => :objects, :source => :object, :source_type => 'User'
|
||||
has_many :actors, :as => :target, :class_name => 'Relation', :dependent => :destroy
|
||||
has_many :members, :through => :actors, :source => :actor, :source_type => 'User'
|
||||
|
||||
validates :description, :presence => true
|
||||
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
|
||||
|
@ -148,20 +148,22 @@ class Platform < ActiveRecord::Base
|
|||
|
||||
def update_owner_relation
|
||||
if owner_id_was != owner_id
|
||||
r = relations.where(:object_id => owner_id_was, :object_type => owner_type_was)[0]
|
||||
r.update_attributes(:object_id => owner_id, :object_type => owner_type)
|
||||
r = relations.where(:actor_id => owner_id_was, :actor_type => owner_type_was)[0]
|
||||
r.update_attributes(:actor_id => owner_id, :actor_type => owner_type)
|
||||
end
|
||||
end
|
||||
|
||||
def build_all(user)
|
||||
repositories.find_by_name('main').projects.find_in_batches(:batch_size => 2) do |group|
|
||||
sleep 1
|
||||
group.each do |p|
|
||||
%w(i586 x86_64).each do |arch|
|
||||
begin
|
||||
p.build_for(self, user, arch)
|
||||
rescue RuntimeError, Exception
|
||||
p.delay.build_for(self, user, arch)
|
||||
repositories.each do |rep|
|
||||
rep.projects.find_in_batches(:batch_size => 2) do |group|
|
||||
sleep 1
|
||||
group.each do |p|
|
||||
Arch.all.map(&:name).each do |arch|
|
||||
begin
|
||||
p.build_for(self, user, arch)
|
||||
rescue RuntimeError, Exception
|
||||
p.delay.build_for(self, user, arch)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,8 +14,8 @@ class Project < ActiveRecord::Base
|
|||
has_many :repositories, :through => :project_to_repositories
|
||||
|
||||
has_many :relations, :as => :target, :dependent => :destroy
|
||||
has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User'
|
||||
has_many :groups, :through => :relations, :source => :object, :source_type => 'Group'
|
||||
has_many :collaborators, :through => :relations, :source => :actor, :source_type => 'User'
|
||||
has_many :groups, :through => :relations, :source => :actor, :source_type => 'Group'
|
||||
has_many :labels
|
||||
|
||||
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/}
|
||||
|
@ -52,7 +52,7 @@ class Project < ActiveRecord::Base
|
|||
|
||||
include Modules::Models::Owner
|
||||
|
||||
def build_for(platform, user, arch = 'i586')
|
||||
def build_for(platform, user, arch = 'i586', priority = 0)
|
||||
# Select main and project platform repository(contrib, non-free and etc)
|
||||
# If main does not exist, will connect only project platform repository
|
||||
# If project platform repository is main, only main will be connect
|
||||
|
@ -71,6 +71,7 @@ class Project < ActiveRecord::Base
|
|||
bl.user = user
|
||||
bl.auto_publish = true # already set as db default
|
||||
bl.include_repos = build_ids
|
||||
bl.priority = priority
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -206,7 +207,7 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def owner_and_admin_ids
|
||||
recipients = self.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) }
|
||||
recipients = self.relations.by_role('admin').where(:actor_type => 'User').map { |rel| rel.read_attribute(:actor_id) }
|
||||
recipients = recipients | [self.owner_id] if self.owner_type == 'User'
|
||||
recipients
|
||||
end
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class Relation < ActiveRecord::Base
|
||||
belongs_to :target, :polymorphic => true
|
||||
belongs_to :object, :polymorphic => true
|
||||
belongs_to :actor, :polymorphic => true
|
||||
|
||||
ROLES = %w[reader writer admin]
|
||||
validates :role, :inclusion => {:in => ROLES}
|
||||
|
||||
# validate { errors.add(:object, :taken) if Relation.where(:object_type => self.object_type, :object_id => self.object_id).present? }
|
||||
# validate { errors.add(:actor, :taken) if Relation.where(:actor_type => self.actor_type, :actor_id => self.actor_id).present? }
|
||||
before_validation :add_default_role
|
||||
|
||||
scope :by_user_through_groups, lambda {|u| where("object_type = 'User' AND object_id = ? OR object_type = 'Group' AND object_id IN (?)", u.id, u.group_ids)}
|
||||
scope :by_object, lambda {|obj| {:conditions => ['object_id = ? AND object_type = ?', obj.id, obj.class.to_s]}}
|
||||
scope :by_user_through_groups, lambda {|u| where("actor_type = 'User' AND actor_id = ? OR actor_type = 'Group' AND actor_id IN (?)", u.id, u.group_ids)}
|
||||
scope :by_actor, lambda {|obj| {:conditions => ['actor_id = ? AND actor_type = ?', obj.id, obj.class.to_s]}}
|
||||
scope :by_target, lambda {|tar| {:conditions => ['target_id = ? AND target_type = ?', tar.id, tar.class.to_s]}}
|
||||
scope :by_role, lambda {|role| {:conditions => ['role = ?', role]}}
|
||||
|
||||
def self.create_with_role(object, target, role)
|
||||
r = new
|
||||
r.object = object
|
||||
def self.create_with_role(actor, target, role)
|
||||
r = self.new
|
||||
r.actor = actor
|
||||
r.target = target
|
||||
r.role = role
|
||||
r.save
|
||||
|
|
|
@ -24,8 +24,8 @@ class User < ActiveRecord::Base
|
|||
has_many :subscribes, :foreign_key => :user_id, :dependent => :destroy
|
||||
has_many :comments, :dependent => :destroy
|
||||
|
||||
has_many :relations, :as => :object, :dependent => :destroy
|
||||
has_many :targets, :as => :object, :class_name => 'Relation', :dependent => :destroy
|
||||
has_many :relations, :as => :actor, :dependent => :destroy
|
||||
has_many :targets, :as => :actor, :class_name => 'Relation', :dependent => :destroy
|
||||
|
||||
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
||||
has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
%td
|
||||
= link_to t("layout.activity_feed.all_my_projects"), projects_path
|
||||
.block
|
||||
- midnight = Date.today
|
||||
- midnight = Time.now.utc.to_date
|
||||
%h3= t("layout.activity_feed.my_builds_by_day")
|
||||
%table{:cellpadding => "0", :cellspacing => "0"}
|
||||
%tbody
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
.notify.blue
|
||||
%div{:class => build_list_status_color(@build_list.status)}
|
||||
%p= @build_list.human_status
|
||||
%p 2012-01-27 17:28:05 UTC
|
||||
%p= @build_list.updated_at
|
||||
.both
|
||||
%h3= t("layout.build_lists.main_data")
|
||||
.leftside.width125= t("activerecord.attributes.build_list.container_path")
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
- Relation::ROLES.each_with_index do |role, i|
|
||||
%td
|
||||
.radio
|
||||
= radio_button_tag "user[#{user.id}]", role, ((@project.relations.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio'
|
||||
= radio_button_tag "user[#{user.id}]", role, ((@project.relations.exists? :actor_id => user.id, :actor_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio'
|
||||
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||
= link_to_function t("layout.delete_selected"), "deleteAdminMember();", :class => 'button'
|
||||
= link_to_function t("layout.save"), "saveAdminMember();", :class => 'button right_floated'
|
||||
|
@ -84,7 +84,7 @@
|
|||
- Relation::ROLES.each_with_index do |role, i|
|
||||
%td
|
||||
.radio
|
||||
= radio_button_tag "group[#{group.id}]", role, ((@project.relations.exists? :object_id => group.id, :object_type => 'Group', :role => role) ? :checked : nil), :class => 'niceRadio'
|
||||
= radio_button_tag "group[#{group.id}]", role, ((@project.relations.exists? :actor_id => group.id, :actor_type => 'Group', :role => role) ? :checked : nil), :class => 'niceRadio'
|
||||
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||
= link_to_function t("layout.delete_selected"), "deleteAdminGroup();", :class => 'button'
|
||||
= link_to_function t("layout.save"), "saveAdminGroup();", :class => 'button right_floated'
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
.admin-role
|
||||
.lineForm
|
||||
= select_tag 'role', options_for_collaborators_roles_select
|
||||
%a{:id => 'add_collaborator_button', :class => 'button', :rel => 'nofollow', :href => 'javascript:void(0)'}
|
||||
= t('layout.add')
|
||||
.admin-add
|
||||
%a{:id => 'add_collaborator_button', :class => 'button', :rel => 'nofollow', :href => 'javascript:void(0)'}
|
||||
= t('layout.add')
|
||||
.both
|
||||
|
||||
%table#collaborators.tablesorter{:cellpadding => "0", :cellspacing => "0"}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
= surround '[', ']' do
|
||||
= I18n.t "event_log.controllers.#{el.controller.underscore}", :default => el.controller
|
||||
= I18n.t "event_log.actions.#{el.controller.underscore}.#{el.action}", :default => :"event_log.actions.#{el.action}"
|
||||
- if el.object_id.present? and el.object_type.present?
|
||||
= I18n.t "activerecord.models.#{el.object_type.underscore}"
|
||||
= el.object_name
|
||||
= "(id##{el.object_id})" # link_to "id##{el.object_id}", el.object
|
||||
- if el.eventable_id.present? and el.eventable_type.present?
|
||||
= I18n.t "activerecord.models.#{el.eventable_type.underscore}"
|
||||
= el.eventable_name
|
||||
= "(id##{el.eventable_id})" # link_to "id##{el.eventable_id}", el.eventable
|
||||
= el.message
|
||||
|
|
|
@ -10,4 +10,15 @@
|
|||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<!-- Yandex.Metrika counter -->
|
||||
<script type="text/javascript">
|
||||
(function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter14076919 = new Ya.Metrika({id:14076919, enableAll: true, ut:"noindex", webvisor:true}); } catch(e) {} }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f); } else { f(); } })(document, window, "yandex_metrika_callbacks");
|
||||
</script>
|
||||
<noscript>
|
||||
<div>
|
||||
<img src="//mc.yandex.ru/watch/14076919?ut=noindex" style="position:absolute; left:-9999px;" alt="" />
|
||||
</div>
|
||||
</noscript>
|
||||
<!-- /Yandex.Metrika counter -->
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
= csrf_meta_tag
|
||||
= display_meta_tags :site => APP_CONFIG['project_name'], :reverse => true, :separator => '-'
|
||||
- if user_signed_in?
|
||||
= auto_discovery_link_tag :atom, atom_activity_feeds_url(:format => 'atom', :token => current_user.authentication_token), :title => t("layout.atom_link_tag_title", :nickname => current_user.name, :app_name => APP_CONFIG['project_name'])
|
||||
= auto_discovery_link_tag :atom, atom_activity_feeds_path(:format => 'atom', :token => current_user.authentication_token), :title => t("layout.atom_link_tag_title", :nickname => current_user.uname, :app_name => APP_CONFIG['project_name'])
|
||||
|
||||
%body
|
||||
.wrap{:class => content_for?(:sidebar) ? 'columns' : ''}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
- Relation::ROLES.each_with_index do |role, i|
|
||||
%td
|
||||
.radio
|
||||
= radio_button_tag "user[#{user.id}]", role, ((parent.objects.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio'
|
||||
= radio_button_tag "user[#{user.id}]", role, ((parent.actors.exists? :actor_id => user.id, :actor_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio'
|
||||
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||
= link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button'
|
||||
.both
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
.description-top
|
||||
%ul.nav.zip
|
||||
%li#menu-archive.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#menu-archive"}
|
||||
=image_tag 'zip.png', :alt => 'ZIP'
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li=link_to "tar.gz", archive_path(project.id, 'tar', @treeish)
|
||||
%li=link_to "zip", archive_path(project.id, 'zip', @treeish)
|
||||
-if @commit
|
||||
%ul.nav.zip
|
||||
%li#menu-archive.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#menu-archive"}
|
||||
=image_tag 'zip.png', :alt => 'ZIP'
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li=link_to "tar.gz", archive_path(project.id, 'tar', @treeish)
|
||||
%li=link_to "zip", archive_path(project.id, 'zip', @treeish)
|
||||
|
||||
= text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :spellcheck => 'false', :readonly => true
|
||||
.git_help ?
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
%li{:class => (act == :sections && contr == :projects) ? 'active' : ''}
|
||||
= link_to t("layout.projects.sections"), sections_project_path(@project)
|
||||
- if can? :manage_collaborators, @project
|
||||
%li{:class => (act == :edit && contr == :collaborators) ? 'active' : ''}
|
||||
%li{:class => (act == :index && contr == :collaborators) ? 'active' : ''}
|
||||
= link_to t("layout.projects.edit_collaborators"), project_collaborators_path(@project)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
Warden::Manager.after_authentication do |user,auth,opts| # after_set_user, :except => fetch
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => user)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => user)
|
||||
end
|
||||
|
||||
Warden::Manager.before_failure do |env, opts|
|
||||
|
@ -10,14 +10,14 @@ Warden::Manager.before_failure do |env, opts|
|
|||
end
|
||||
|
||||
Warden::Manager.before_logout do |user,auth,opts|
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => user)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => user)
|
||||
end
|
||||
|
||||
ActiveSupport::Notifications.subscribe "event_log.observer" do |name, start, finish, id, payload|
|
||||
if c = EventLog.current_controller
|
||||
object = payload[:object]
|
||||
message = payload[:message].presence; message ||= object.event_log_message if object.respond_to?(:event_log_message)
|
||||
eventable = payload[:eventable]
|
||||
message = payload[:message].presence; message ||= eventable.event_log_message if eventable.respond_to?(:event_log_message)
|
||||
EventLog.create_with_current_controller :kind => (payload[:kind].presence || 'info'), :message => message,
|
||||
:object => object, :object_name => payload[:object_name].presence
|
||||
:eventable => eventable, :eventable_name => payload[:eventable_name].presence
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class ChangeObjectToActorInRelation < ActiveRecord::Migration
|
||||
def up
|
||||
change_table :relations do |t|
|
||||
t.rename :object_id, :actor_id
|
||||
t.rename :object_type, :actor_type
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
change_table :relations do |t|
|
||||
t.rename :actor_id, :object_id
|
||||
t.rename :actor_type, :object_type
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
class ChangeObjectToEventableInEventLog < ActiveRecord::Migration
|
||||
def up
|
||||
change_table :event_logs do |t|
|
||||
t.rename :object_id, :eventable_id
|
||||
t.rename :object_type, :eventable_type
|
||||
t.rename :object_name, :eventable_name
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
change_table :event_logs do |t|
|
||||
t.rename :eventable_id, :object_id
|
||||
t.rename :eventable_type, :object_type
|
||||
t.rename :eventable_name, :object_name
|
||||
end
|
||||
end
|
||||
end
|
16
db/schema.rb
16
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120418100619) do
|
||||
ActiveRecord::Schema.define(:version => 20120425190938) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -112,17 +112,17 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
|
|||
create_table "event_logs", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.string "user_name"
|
||||
t.integer "object_id"
|
||||
t.string "object_type"
|
||||
t.string "object_name"
|
||||
t.integer "eventable_id"
|
||||
t.string "eventable_type"
|
||||
t.string "eventable_name"
|
||||
t.string "ip"
|
||||
t.string "kind"
|
||||
t.string "protocol"
|
||||
t.string "controller"
|
||||
t.string "action"
|
||||
t.text "message"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "groups", :force => true do |t|
|
||||
|
@ -288,8 +288,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
|
|||
add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false
|
||||
|
||||
create_table "relations", :force => true do |t|
|
||||
t.integer "object_id"
|
||||
t.string "object_type"
|
||||
t.integer "actor_id"
|
||||
t.string "actor_type"
|
||||
t.integer "target_id"
|
||||
t.string "target_type"
|
||||
t.datetime "created_at", :null => false
|
||||
|
|
|
@ -8,10 +8,10 @@ module Modules
|
|||
scope :not_member_of, lambda { |item|
|
||||
where("
|
||||
#{klass.table_name}.id NOT IN (
|
||||
SELECT relations.object_id
|
||||
SELECT relations.actor_id
|
||||
FROM relations
|
||||
WHERE (
|
||||
relations.object_type = '#{klass.to_s}'
|
||||
relations.actor_type = '#{klass.to_s}'
|
||||
AND relations.target_type = '#{item.class.to_s}'
|
||||
AND relations.target_id = #{item.id}
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ module Modules
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_create lambda { relations.create :object_id => owner.id, :object_type => owner.class.to_s, :role => 'admin' }
|
||||
after_create lambda { relations.create :actor_id => owner.id, :actor_type => owner.class.to_s, :role => 'admin' }
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
|
|
@ -103,7 +103,7 @@ describe BuildListsController do
|
|||
@owner_user = @project.owner
|
||||
@member_user = FactoryGirl.create(:user)
|
||||
rel = @project.relations.build(:role => 'reader')
|
||||
rel.object = @member_user
|
||||
rel.actor = @member_user
|
||||
rel.save
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
|
@ -116,7 +116,7 @@ describe BuildListsController do
|
|||
@build_list2 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :visibility => 'hidden'))
|
||||
@build_list3 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :owner => @user, :visibility => 'hidden'))
|
||||
@build_list4 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :visibility => 'hidden'))
|
||||
@build_list4.project.relations.create :role => 'reader', :object_id => @user.id, :object_type => 'User'
|
||||
@build_list4.project.relations.create :role => 'reader', :actor_id => @user.id, :actor_type => 'User'
|
||||
end
|
||||
|
||||
it 'should be able to perform index action' do
|
||||
|
@ -177,17 +177,17 @@ describe BuildListsController do
|
|||
before(:each) do
|
||||
@owner_group = FactoryGirl.create(:group)
|
||||
@owner_user = FactoryGirl.create(:user)
|
||||
@owner_group.objects.create :role => 'reader', :object_id => @owner_user.id, :object_type => 'User'
|
||||
@owner_group.actors.create :role => 'reader', :actor_id => @owner_user.id, :actor_type => 'User'
|
||||
@member_group = FactoryGirl.create(:group)
|
||||
@member_user = FactoryGirl.create(:user)
|
||||
@member_group.objects.create :role => 'reader', :object_id => @member_user.id, :object_type => 'User'
|
||||
@member_group.actors.create :role => 'reader', :actor_id => @member_user.id, :actor_type => 'User'
|
||||
|
||||
@group = FactoryGirl.create(:group)
|
||||
@user = FactoryGirl.create(:user)
|
||||
@group.objects.create :role => 'reader', :object_id => @user.id, :object_type => 'User'
|
||||
@group.actors.create :role => 'reader', :actor_id => @user.id, :actor_type => 'User'
|
||||
|
||||
@project = FactoryGirl.create(:project, :owner => @owner_group)
|
||||
@project.relations.create :role => 'reader', :object_id => @member_group.id, :object_type => 'Group'
|
||||
@project.relations.create :role => 'reader', :actor_id => @member_group.id, :actor_type => 'Group'
|
||||
|
||||
@build_list = FactoryGirl.create(:build_list_core, :project => @project)
|
||||
|
||||
|
@ -201,7 +201,7 @@ describe BuildListsController do
|
|||
@build_list2 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :visibility => 'hidden'))
|
||||
@build_list3 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :owner => @group, :visibility => 'hidden'))
|
||||
@build_list4 = FactoryGirl.create(:build_list_core, :project => FactoryGirl.create(:project, :visibility => 'hidden'))
|
||||
@build_list4.project.relations.create :role => 'reader', :object_id => @group.id, :object_type => 'Group'
|
||||
@build_list4.project.relations.create :role => 'reader', :actor_id => @group.id, :actor_type => 'Group'
|
||||
end
|
||||
|
||||
it 'should be able to perform index action' do
|
||||
|
|
|
@ -1,19 +1,46 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
require 'spec_helper'
|
||||
|
||||
def create_params
|
||||
@user_params = {
|
||||
:actor_id => @another_user.id.to_s,
|
||||
:actor_type => 'user',
|
||||
:role => 'reader'
|
||||
}
|
||||
@group_params = {
|
||||
:actor_id => @group.id.to_s,
|
||||
:actor_type => 'group',
|
||||
:role => 'reader'
|
||||
}
|
||||
@create_params = {
|
||||
:project_id => @project.id.to_s,
|
||||
:format => :json
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'project admin user' do
|
||||
it 'should be able to view collaborators list' do
|
||||
get :index, :project_id => @project.id
|
||||
response.should redirect_to(edit_project_collaborators_path(@project))
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'should be able to perform update action' do
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(edit_project_collaborators_path(@project))
|
||||
put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params)
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'should add new collaborator with reader role' do
|
||||
post :create, @create_params.merge(:collaborator => @user_params)
|
||||
@project.relations.exists?(:actor_type => 'User', :actor_id => @another_user.id, :role => 'reader').should be_true
|
||||
end
|
||||
|
||||
it 'should add new group with reader role' do
|
||||
post :create, @create_params.merge(:collaborator => @group_params)
|
||||
@project.relations.exists?(:actor_type => 'Group', :actor_id => @group.id, :role => 'reader').should be_true
|
||||
end
|
||||
|
||||
it 'should be able to set reader role for any user' do
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params)
|
||||
@another_user.relations.exists? :target_id => @project.id, :target_type => 'Project', :role => 'read'
|
||||
end
|
||||
end
|
||||
|
@ -21,45 +48,50 @@ end
|
|||
shared_examples_for 'user with no rights for this project' do
|
||||
it 'should not be able to view collaborators list' do
|
||||
get :index, :project_id => @project.id
|
||||
response.should redirect_to(edit_project_collaborators_path(@project))
|
||||
response.should redirect_to(forbidden_path)
|
||||
end
|
||||
|
||||
it 'should not be able to perform update action' do
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(edit_project_collaborators_path(@project))
|
||||
put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params)
|
||||
response.should redirect_to(forbidden_path)
|
||||
end
|
||||
|
||||
it 'should not be able to set reader role for any user' do
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params)
|
||||
!@another_user.relations.exists? :target_id => @project.id, :target_type => 'Project', :role => 'read'
|
||||
end
|
||||
end
|
||||
|
||||
describe CollaboratorsController do
|
||||
before(:each) do
|
||||
before(:each) do
|
||||
stub_rsync_methods
|
||||
@project = FactoryGirl.create(:project)
|
||||
@another_user = FactoryGirl.create(:user)
|
||||
@update_params = {:user => {@another_user.id => :reader}}
|
||||
end
|
||||
@member_user = FactoryGirl.create(:user)
|
||||
@update_params = {:collaborator => {:role => :reader}, :format => :json}
|
||||
# Create relation with 'writer' rights
|
||||
@collaborator = Collaborator.create(:actor => @member_user, :project => @project, :role => 'writer')
|
||||
end
|
||||
|
||||
context 'for guest' do
|
||||
context 'for guest' do
|
||||
it 'should not be able to perform index action' do
|
||||
get :index, :project_id => @project.id
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
|
||||
it 'should not be able to perform update action' do
|
||||
post :update, {:project_id => @project.id}.merge(@update_params)
|
||||
response.should redirect_to(new_user_session_path)
|
||||
put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params)
|
||||
response.code.should == '401'
|
||||
end
|
||||
end
|
||||
|
||||
context 'for global admin' do
|
||||
before(:each) do
|
||||
@admin = FactoryGirl.create(:admin)
|
||||
set_session_for(@admin)
|
||||
end
|
||||
before(:each) do
|
||||
@admin = FactoryGirl.create(:admin)
|
||||
set_session_for(@admin)
|
||||
@group = FactoryGirl.create(:group)
|
||||
create_params
|
||||
end
|
||||
|
||||
it_should_behave_like 'project admin user'
|
||||
end
|
||||
|
@ -67,57 +99,48 @@ describe CollaboratorsController do
|
|||
context 'for admin user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
@user.relations
|
||||
# @user.relations
|
||||
set_session_for(@user)
|
||||
@group = FactoryGirl.create(:group)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
create_params
|
||||
end
|
||||
|
||||
it_should_behave_like 'project admin user'
|
||||
|
||||
it 'should add new collaborator with reader role' do
|
||||
@params = {:member_id => @another_user.id.to_s, :project_id => @project.id.to_s}
|
||||
post :add, @params
|
||||
@project.relations.exists?(:object_type => 'User', :object_id => @another_user.id, :role => 'reader').should be_true
|
||||
end
|
||||
|
||||
it 'should add new group with reader role' do
|
||||
@params = {:group_id => @group.id.to_s, :project_id => @project.id.to_s}
|
||||
post :add, @params
|
||||
@project.relations.exists?(:object_type => 'Group', :object_id => @group.id, :role => 'reader').should be_true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'for owner user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.update_attribute(:owner, @user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
end
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@group = FactoryGirl.create(:group)
|
||||
|
||||
@project.update_attribute(:owner, @user)
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
|
||||
create_params
|
||||
end
|
||||
|
||||
it_should_behave_like 'project admin user'
|
||||
end
|
||||
|
||||
context 'for reader user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.update_attribute(:owner, @user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||
end
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user with no rights for this project'
|
||||
end
|
||||
|
||||
context 'for writer user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.update_attribute(:owner, @user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
||||
end
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user with no rights for this project'
|
||||
end
|
||||
|
|
|
@ -93,7 +93,7 @@ describe CommentsController do
|
|||
|
||||
context 'for project admin user' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user with create comment rights for commits'
|
||||
|
@ -119,7 +119,7 @@ describe CommentsController do
|
|||
|
||||
context 'for project reader user' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user with create comment rights for commits'
|
||||
|
@ -130,7 +130,7 @@ describe CommentsController do
|
|||
|
||||
context 'for project writer user' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user with create comment rights for commits'
|
||||
|
|
|
@ -90,7 +90,7 @@ describe CommentsController do
|
|||
|
||||
context 'for project admin user' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user with create comment rights'
|
||||
|
@ -112,7 +112,7 @@ describe CommentsController do
|
|||
|
||||
context 'for project reader user' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user with create comment rights'
|
||||
|
@ -123,7 +123,7 @@ describe CommentsController do
|
|||
|
||||
context 'for project writer user' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user with create comment rights'
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
require 'spec_helper'
|
||||
|
||||
describe Git::TreesController do
|
||||
|
||||
def fill_project
|
||||
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.git_repository.path}) # maybe FIXME ?
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
stub_rsync_methods
|
||||
|
||||
@project = FactoryGirl.create(:project)
|
||||
@another_user = FactoryGirl.create(:user)
|
||||
@params = {:project_id => @project.id, :format => 'tar'}
|
||||
end
|
||||
|
||||
context 'for guest' do
|
||||
if APP_CONFIG['anonymous_access']
|
||||
it 'should be able to perform archive action with anonymous acccess' do
|
||||
fill_project
|
||||
get :archive, @params
|
||||
response.should be_success
|
||||
end
|
||||
else
|
||||
it 'should not be able to perform archive action without anonymous acccess' do
|
||||
fill_project
|
||||
get :archive, @params
|
||||
response.code.should == '401'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'for other user' do
|
||||
it 'should not be able to archive empty project' do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
expect { get :archive, @params }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'should not be able to injection code with format' do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
fill_project
|
||||
expect { get :archive, @params.merge(:format => "tar master > /dev/null; echo 'I am hacker!';\#") }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'should not be able to injection code with treeish' do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
fill_project
|
||||
expect { get :archive, @params.merge(:treeish => "master > /dev/null; echo 'I am hacker!';\#") }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'should be able to perform archive action' do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
fill_project
|
||||
get :archive, @params
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
end
|
|
@ -117,7 +117,7 @@ describe GroupsController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'update_member_relation'
|
||||
|
@ -130,7 +130,7 @@ describe GroupsController do
|
|||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@group.update_attribute(:owner, @user)
|
||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'update_member_relation'
|
||||
|
@ -141,7 +141,7 @@ describe GroupsController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||
@group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
end
|
||||
|
||||
it_should_behave_like 'no group user'
|
||||
|
|
|
@ -115,7 +115,7 @@ describe IssuesController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'issue user with project reader rights'
|
||||
|
@ -130,7 +130,7 @@ describe IssuesController do
|
|||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.update_attribute(:owner, @user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'issue user with project reader rights'
|
||||
|
@ -144,7 +144,7 @@ describe IssuesController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
end
|
||||
|
||||
it_should_behave_like 'issue user with project reader rights'
|
||||
|
@ -166,7 +166,7 @@ describe IssuesController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
|
||||
end
|
||||
|
||||
it_should_behave_like 'issue user with project reader rights'
|
||||
|
|
|
@ -15,12 +15,12 @@ describe MembersController do
|
|||
it 'should add member to group' do
|
||||
post :add, @add_params
|
||||
response.should redirect_to(edit_group_members_path(@group))
|
||||
Relation.by_target(@group).by_object(@another_user).count.should eql(1)
|
||||
Relation.by_target(@group).by_actor(@another_user).count.should eql(1)
|
||||
end
|
||||
|
||||
it 'should add reader member to group' do
|
||||
post :add, @add_params
|
||||
Relation.by_target(@group).by_object(@another_user).first.role.should eql('reader')
|
||||
Relation.by_target(@group).by_actor(@another_user).first.role.should eql('reader')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -105,7 +105,7 @@ describe PlatformsController do
|
|||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@platform.update_attribute(:owner, @user)
|
||||
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'user without create rights'
|
||||
|
@ -127,7 +127,7 @@ describe PlatformsController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||
@platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
end
|
||||
|
||||
it_should_behave_like 'platform index viewer'
|
||||
|
|
|
@ -92,7 +92,7 @@ describe ProductBuildListsController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@pbl.product.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@pbl.product.platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'admin'
|
||||
|
|
|
@ -64,7 +64,7 @@ describe ProductsController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'admin user'
|
||||
|
|
|
@ -48,7 +48,7 @@ describe ProjectsController do
|
|||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.update_attribute(:owner, @user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'projects user with admin rights'
|
||||
|
@ -74,7 +74,7 @@ describe ProjectsController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
end
|
||||
|
||||
it_should_behave_like 'projects user with reader rights'
|
||||
|
@ -84,7 +84,7 @@ describe ProjectsController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
|
||||
end
|
||||
|
||||
it_should_behave_like 'projects user with reader rights'
|
||||
|
@ -103,7 +103,7 @@ describe ProjectsController do
|
|||
|
||||
it 'should be able to fork project to group' do
|
||||
group = FactoryGirl.create(:group)
|
||||
group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
post :fork, :id => @project.id, :group => group.id
|
||||
response.should redirect_to(project_path(group.projects.first.id))
|
||||
end
|
||||
|
|
|
@ -108,7 +108,7 @@ describe RepositoriesController do
|
|||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
@repository.platform.update_attribute(:owner, @user)
|
||||
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@repository.platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it_should_behave_like 'platform admin user'
|
||||
|
|
|
@ -66,7 +66,7 @@ describe SubscribesController do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:admin)
|
||||
set_session_for(@user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
@destroy_params = @destroy_params.merge({:id => @user.id})
|
||||
end
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ describe CanCan do
|
|||
|
||||
context 'with read rights' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||
@project.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'reader')
|
||||
end
|
||||
|
||||
it 'should be able to read project' do
|
||||
|
@ -165,7 +165,7 @@ describe CanCan do
|
|||
|
||||
context 'with writer rights' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'writer')
|
||||
@project.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'writer')
|
||||
end
|
||||
|
||||
[:read, :create, :new].each do |action|
|
||||
|
@ -184,7 +184,7 @@ describe CanCan do
|
|||
|
||||
context 'with admin rights' do
|
||||
before(:each) do
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'admin')
|
||||
@project.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'admin')
|
||||
end
|
||||
|
||||
[:read, :update].each do |action|
|
||||
|
@ -258,7 +258,7 @@ describe CanCan do
|
|||
|
||||
context 'with read rights' do
|
||||
before(:each) do
|
||||
@platform.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||
@platform.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'reader')
|
||||
end
|
||||
|
||||
it "should be able to read platform" do
|
||||
|
@ -286,7 +286,7 @@ describe CanCan do
|
|||
|
||||
context 'with read rights' do
|
||||
before(:each) do
|
||||
@repository.platform.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||
@repository.platform.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'reader')
|
||||
end
|
||||
|
||||
it "should be able to read repository" do
|
||||
|
@ -298,7 +298,7 @@ describe CanCan do
|
|||
context 'build list relations' do
|
||||
before(:each) do
|
||||
@project = FactoryGirl.create(:project)
|
||||
@project.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'writer')
|
||||
@project.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'writer')
|
||||
@build_list = FactoryGirl.create(:build_list, :project => @project)
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ describe Comment do
|
|||
set_comments_data_for_commit
|
||||
@admin = FactoryGirl.create(:user)
|
||||
@ability = Ability.new(@admin)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @admin.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @admin.id, :role => 'admin')
|
||||
ActionMailer::Base.deliveries = []
|
||||
end
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ describe Comment do
|
|||
|
||||
set_commentable_data
|
||||
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it 'should create comment' do
|
||||
|
@ -85,7 +85,7 @@ describe Comment do
|
|||
set_commentable_data
|
||||
|
||||
@project.update_attribute(:owner, @user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
||||
it 'should create comment' do
|
||||
|
|
|
@ -34,7 +34,7 @@ describe Group do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
@another_user = FactoryGirl.create(:user)
|
||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
@ability = Ability.new(@user)
|
||||
end
|
||||
|
||||
|
@ -63,7 +63,7 @@ describe Group do
|
|||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
@group.update_attribute(:owner, @user)
|
||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
@group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
|
||||
@ability = Ability.new(@user)
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ describe Group do
|
|||
context 'for group reader and writer user' do
|
||||
before(:each) do
|
||||
@user = FactoryGirl.create(:user)
|
||||
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||
@group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
|
||||
@ability = Ability.new(@user)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue