Merge branch 'master' into 263-refactoring
Conflicts: app/models/project.rb app/views/projects/_repo_block.html.haml db/schema.rb spec/controllers/issues_controller_spec.rb spec/controllers/projects_controller_spec.rb
This commit is contained in:
commit
b957600eda
|
@ -20,6 +20,9 @@ class Git::TreesController < Git::BaseController
|
||||||
treeish = params[:treeish].presence || @project.default_branch
|
treeish = params[:treeish].presence || @project.default_branch
|
||||||
format = params[:format] || 'tar'
|
format = params[:format] || 'tar'
|
||||||
commit = @project.git_repository.log(treeish, nil, :max_count => 1).first
|
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]}"
|
name = "#{@project.owner.uname}-#{@project.name}#{@project.tags.include?(treeish) ? "-#{treeish}" : ''}-#{commit.id[0..19]}"
|
||||||
fullname = "#{name}.#{format == 'tar' ? 'tar.gz' : 'zip'}"
|
fullname = "#{name}.#{format == 'tar' ? 'tar.gz' : 'zip'}"
|
||||||
file = Tempfile.new fullname, 'tmp'
|
file = Tempfile.new fullname, 'tmp'
|
||||||
|
|
|
@ -33,10 +33,10 @@ class MembersController < ApplicationController
|
||||||
params['user'].keys.each { |user_id|
|
params['user'].keys.each { |user_id|
|
||||||
role = params['user'][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)
|
relation.update_attribute(:role, role)
|
||||||
else
|
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!
|
relation.save!
|
||||||
end
|
end
|
||||||
} if params['user']
|
} if params['user']
|
||||||
|
@ -53,7 +53,7 @@ class MembersController < ApplicationController
|
||||||
def remove
|
def remove
|
||||||
if params[:id]
|
if params[:id]
|
||||||
u = User.find(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
|
redirect_to groups_path
|
||||||
else
|
else
|
||||||
|
@ -65,7 +65,7 @@ class MembersController < ApplicationController
|
||||||
|
|
||||||
all_user_ids.each do |user_id|
|
all_user_ids.each do |user_id|
|
||||||
u = User.find(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
|
end
|
||||||
|
|
||||||
redirect_to edit_group_members_path(parent)
|
redirect_to edit_group_members_path(parent)
|
||||||
|
@ -75,8 +75,8 @@ class MembersController < ApplicationController
|
||||||
def add
|
def add
|
||||||
if params['user_id'] and !params['user_id'].empty?
|
if params['user_id'] and !params['user_id'].empty?
|
||||||
@user = User.find_by_uname(params['user_id'])
|
@user = User.find_by_uname(params['user_id'])
|
||||||
unless parent.objects.exists? :object_id => @user.id, :object_type => 'User'
|
unless parent.actors.exists? :actor_id => @user.id, :actor_type => 'User'
|
||||||
relation = parent.objects.build(:object_id => @user.id, :object_type => 'User', :role => params[:role])
|
relation = parent.actors.build(:actor_id => @user.id, :actor_type => 'User', :role => params[:role])
|
||||||
if relation.save
|
if relation.save
|
||||||
flash[:notice] = t("flash.members.successfully_added")
|
flash[:notice] = t("flash.members.successfully_added")
|
||||||
else
|
else
|
||||||
|
|
|
@ -95,14 +95,14 @@ class PlatformsController < ApplicationController
|
||||||
def remove_members
|
def remove_members
|
||||||
all_user_ids = params['user_remove'].inject([]) {|a, (k, v)| a << k if v.first == '1'; a}
|
all_user_ids = params['user_remove'].inject([]) {|a, (k, v)| a << k if v.first == '1'; a}
|
||||||
all_user_ids.each do |uid|
|
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
|
end
|
||||||
redirect_to members_platform_path(@platform)
|
redirect_to members_platform_path(@platform)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_member
|
def remove_member
|
||||||
u = User.find(params[:member_id])
|
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)
|
redirect_to members_platform_path(@platform)
|
||||||
end
|
end
|
||||||
|
@ -110,11 +110,11 @@ class PlatformsController < ApplicationController
|
||||||
def add_member
|
def add_member
|
||||||
if params[:member_id].present?
|
if params[:member_id].present?
|
||||||
member = User.find(params[:member_id])
|
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)
|
flash[:warning] = t('flash.platform.members.already_added', :name => member.uname)
|
||||||
else
|
else
|
||||||
rel = @platform.relations.build(:role => 'admin')
|
rel = @platform.relations.build(:role => 'admin')
|
||||||
rel.object = member
|
rel.actor = member
|
||||||
if rel.save
|
if rel.save
|
||||||
flash[:notice] = t('flash.platform.members.successfully_added', :name => member.uname)
|
flash[:notice] = t('flash.platform.members.successfully_added', :name => member.uname)
|
||||||
else
|
else
|
||||||
|
|
|
@ -28,7 +28,7 @@ module ProjectsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def alone_member?(project)
|
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
|
end
|
||||||
|
|
||||||
def participant_path(participant)
|
def participant_path(participant)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Ability
|
||||||
|
|
||||||
can [:read, :create, :autocomplete_group_uname], Group
|
can [:read, :create, :autocomplete_group_uname], Group
|
||||||
can [:update, :manage_members], Group do |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
|
end
|
||||||
can :destroy, Group, :owner_id => user.id
|
can :destroy, Group, :owner_id => user.id
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class Ability
|
||||||
can(:fork, Project) {|project| can? :read, project}
|
can(:fork, Project) {|project| can? :read, project}
|
||||||
can(:fork, Project) {|project| project.owner_type == 'Group' and can? :update, project.owner}
|
can(:fork, Project) {|project| project.owner_type == 'Group' and can? :update, project.owner}
|
||||||
can(:destroy, Project) {|project| owner? project}
|
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 :remove_user, Project
|
||||||
|
|
||||||
can [:read, :owned], BuildList, :user_id => user.id
|
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, :owner_type => 'Group', :owner_id => user.group_ids
|
||||||
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
||||||
can([:update, :members], Platform) {|platform| local_admin? 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 :autocomplete_user_uname, Platform
|
||||||
|
|
||||||
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
|
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
|
||||||
|
@ -140,28 +140,28 @@ class Ability
|
||||||
parent ||= table
|
parent ||= table
|
||||||
["#{table}.#{key} IN (
|
["#{table}.#{key} IN (
|
||||||
SELECT target_id FROM relations WHERE relations.target_type = ? AND
|
SELECT target_id FROM relations WHERE relations.target_type = ? AND
|
||||||
(relations.object_type = 'User' AND relations.object_id = ? OR
|
(relations.actor_type = 'User' AND relations.actor_id = ? OR
|
||||||
relations.object_type = 'Group' AND relations.object_id IN (?)))", parent.classify, @user, @user.group_ids]
|
relations.actor_type = 'Group' AND relations.actor_id IN (?)))", parent.classify, @user, @user.group_ids]
|
||||||
end
|
end
|
||||||
|
|
||||||
def relation_exists_for(object, roles)
|
def relation_exists_for(target, roles)
|
||||||
object.relations.exists?(:object_id => @user.id, :object_type => 'User', :role => roles) or
|
target.relations.exists?(:actor_id => @user.id, :actor_type => 'User', :role => roles) or
|
||||||
object.relations.exists?(:object_id => @user.group_ids, :object_type => 'Group', :role => roles)
|
target.relations.exists?(:actor_id => @user.group_ids, :actor_type => 'Group', :role => roles)
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_reader?(object)
|
def local_reader?(target)
|
||||||
relation_exists_for(object, %w{reader writer admin}) or owner?(object)
|
relation_exists_for(target, %w{reader writer admin}) or owner?(target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_writer?(object)
|
def local_writer?(target)
|
||||||
relation_exists_for(object, %w{writer admin}) or owner?(object)
|
relation_exists_for(target, %w{writer admin}) or owner?(target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_admin?(object)
|
def local_admin?(target)
|
||||||
relation_exists_for(object, 'admin') or owner?(object)
|
relation_exists_for(target, 'admin') or owner?(target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def owner?(object)
|
def owner?(target)
|
||||||
object.owner == @user or @user.own_groups.include?(object.owner)
|
target.owner == @user or @user.own_groups.include?(target.owner)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Collaborator
|
||||||
def find_by_project(project)
|
def find_by_project(project)
|
||||||
res = []
|
res = []
|
||||||
project.relations.each do |r|
|
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
|
end
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
@ -64,7 +64,7 @@ class Collaborator
|
||||||
|
|
||||||
def relation=(model)
|
def relation=(model)
|
||||||
@relation = model
|
@relation = model
|
||||||
@actor = @relation.object
|
@actor = @relation.actor
|
||||||
@project = @relation.target
|
@project = @relation.target
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,15 +134,15 @@ class Collaborator
|
||||||
end
|
end
|
||||||
|
|
||||||
def relation
|
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?
|
if @actor.present? and @project.present?
|
||||||
@relation = Relation.by_object(@actor).by_target(@project).limit(1).first
|
@relation = Relation.by_actor(@actor).by_target(@project).limit(1).first
|
||||||
@relation ||= Relation.new(:object_id => @actor.id, :object_type => @actor.class.to_s,
|
@relation ||= Relation.new(:actor_id => @actor.id, :actor_type => @actor.class.to_s,
|
||||||
:target_id => @project.id, :target_type => 'Project')
|
:target_id => @project.id, :target_type => 'Project')
|
||||||
else
|
else
|
||||||
@relation = Relation.new
|
@relation = Relation.new
|
||||||
@relation.object = @actor
|
@relation.actor = @actor
|
||||||
@relation.target = @project
|
@relation.target = @project
|
||||||
end
|
end
|
||||||
@relation
|
@relation
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Comment < ActiveRecord::Base
|
||||||
if issue_comment?
|
if issue_comment?
|
||||||
commentable.subscribes.create(:user => user) if !commentable.subscribes.exists?(:user_id => user.id)
|
commentable.subscribes.create(:user => user) if !commentable.subscribes.exists?(:user_id => user.id)
|
||||||
elsif commit_comment?
|
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 << user << User.where(:email => commentable.committer.email).first # commentor and committer
|
||||||
recipients << project.owner if project.owner_type == 'User' # project owner
|
recipients << project.owner if project.owner_type == 'User' # project owner
|
||||||
recipients.compact.uniq.each do |user|
|
recipients.compact.uniq.each do |user|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class EventLog < ActiveRecord::Base
|
class EventLog < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :object, :polymorphic => true
|
belongs_to :eventable, :polymorphic => true
|
||||||
|
|
||||||
# self.per_page = 1
|
# self.per_page = 1
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class EventLog < ActiveRecord::Base
|
||||||
|
|
||||||
before_create do
|
before_create do
|
||||||
self.user_name = user.try(:uname) || 'guest'
|
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
|
end
|
||||||
# after_create { self.class.current_controller = nil }
|
# 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
|
observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :product_build_list
|
||||||
|
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => record)
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_update(record)
|
def before_update(record)
|
||||||
case record.class.to_s
|
case record.class.to_s
|
||||||
when 'BuildList'
|
when 'BuildList'
|
||||||
if record.status_changed? and [BuildList::BUILD_CANCELED, BuildList::BUILD_PUBLISHED].include?(record.status)
|
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
|
end
|
||||||
when 'Platform'
|
when 'Platform'
|
||||||
if record.visibility_changed?
|
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}")
|
:message => I18n.t("activerecord.attributes.platform.visibility_types.#{record.visibility}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy(record)
|
def after_destroy(record)
|
||||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => record)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
class Group < ActiveRecord::Base
|
class Group < ActiveRecord::Base
|
||||||
belongs_to :owner, :class_name => 'User'
|
belongs_to :owner, :class_name => 'User'
|
||||||
|
|
||||||
has_many :relations, :as => :object, :dependent => :destroy
|
has_many :relations, :as => :actor, :dependent => :destroy
|
||||||
has_many :objects, :as => :target, :class_name => 'Relation'
|
has_many :actors, :as => :target, :class_name => 'Relation'
|
||||||
has_many :targets, :as => :object, :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 :members, :through => :actors, :source => :actor, :source_type => 'User', :autosave => true
|
||||||
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :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_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
|
||||||
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :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 :opened, where('1=1')
|
||||||
scope :by_owner, lambda {|owner| where(:owner_id => owner.id)}
|
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
|
include Modules::Models::ActsLikeMember
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Issue < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def collect_recipient_ids
|
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.assignee_id] if self.assignee_id
|
||||||
recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User'
|
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 :products, :dependent => :destroy
|
||||||
|
|
||||||
has_many :relations, :as => :target, :dependent => :destroy
|
has_many :relations, :as => :target, :dependent => :destroy
|
||||||
has_many :objects, :as => :target, :class_name => 'Relation', :dependent => :destroy
|
has_many :actors, :as => :target, :class_name => 'Relation', :dependent => :destroy
|
||||||
has_many :members, :through => :objects, :source => :object, :source_type => 'User'
|
has_many :members, :through => :actors, :source => :actor, :source_type => 'User'
|
||||||
|
|
||||||
validates :description, :presence => true
|
validates :description, :presence => true
|
||||||
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
|
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
|
||||||
|
@ -148,20 +148,22 @@ class Platform < ActiveRecord::Base
|
||||||
|
|
||||||
def update_owner_relation
|
def update_owner_relation
|
||||||
if owner_id_was != owner_id
|
if owner_id_was != owner_id
|
||||||
r = relations.where(:object_id => owner_id_was, :object_type => owner_type_was)[0]
|
r = relations.where(:actor_id => owner_id_was, :actor_type => owner_type_was)[0]
|
||||||
r.update_attributes(:object_id => owner_id, :object_type => owner_type)
|
r.update_attributes(:actor_id => owner_id, :actor_type => owner_type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_all(user)
|
def build_all(user)
|
||||||
repositories.find_by_name('main').projects.find_in_batches(:batch_size => 2) do |group|
|
repositories.each do |rep|
|
||||||
sleep 1
|
rep.projects.find_in_batches(:batch_size => 2) do |group|
|
||||||
group.each do |p|
|
sleep 1
|
||||||
%w(i586 x86_64).each do |arch|
|
group.each do |p|
|
||||||
begin
|
Arch.all.map(&:name).each do |arch|
|
||||||
p.build_for(self, user, arch)
|
begin
|
||||||
rescue RuntimeError, Exception
|
p.build_for(self, user, arch)
|
||||||
p.delay.build_for(self, user, arch)
|
rescue RuntimeError, Exception
|
||||||
|
p.delay.build_for(self, user, arch)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,8 +13,8 @@ class Project < ActiveRecord::Base
|
||||||
has_many :repositories, :through => :project_to_repositories
|
has_many :repositories, :through => :project_to_repositories
|
||||||
|
|
||||||
has_many :relations, :as => :target, :dependent => :destroy
|
has_many :relations, :as => :target, :dependent => :destroy
|
||||||
has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User'
|
has_many :collaborators, :through => :relations, :source => :actor, :source_type => 'User'
|
||||||
has_many :groups, :through => :relations, :source => :object, :source_type => 'Group'
|
has_many :groups, :through => :relations, :source => :actor, :source_type => 'Group'
|
||||||
has_many :labels
|
has_many :labels
|
||||||
|
|
||||||
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/}
|
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/}
|
||||||
|
@ -63,7 +63,7 @@ class Project < ActiveRecord::Base
|
||||||
find_by_owner_and_name(owner_name, project_name) or raise ActiveRecord::RecordNotFound
|
find_by_owner_and_name(owner_name, project_name) or raise ActiveRecord::RecordNotFound
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
# Select main and project platform repository(contrib, non-free and etc)
|
||||||
# If main does not exist, will connect only project platform repository
|
# If main does not exist, will connect only project platform repository
|
||||||
# If project platform repository is main, only main will be connect
|
# If project platform repository is main, only main will be connect
|
||||||
|
@ -81,6 +81,7 @@ class Project < ActiveRecord::Base
|
||||||
bl.user = user
|
bl.user = user
|
||||||
bl.auto_publish = true # already set as db default
|
bl.auto_publish = true # already set as db default
|
||||||
bl.include_repos = build_ids
|
bl.include_repos = build_ids
|
||||||
|
bl.priority = priority
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -216,7 +217,7 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def owner_and_admin_ids
|
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 = recipients | [self.owner_id] if self.owner_type == 'User'
|
||||||
recipients
|
recipients
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class Relation < ActiveRecord::Base
|
class Relation < ActiveRecord::Base
|
||||||
belongs_to :target, :polymorphic => true
|
belongs_to :target, :polymorphic => true
|
||||||
belongs_to :object, :polymorphic => true
|
belongs_to :actor, :polymorphic => true
|
||||||
|
|
||||||
ROLES = %w[reader writer admin]
|
ROLES = %w[reader writer admin]
|
||||||
validates :role, :inclusion => {:in => ROLES}
|
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
|
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_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_object, lambda {|obj| {:conditions => ['object_id = ? AND object_type = ?', obj.id, obj.class.to_s]}}
|
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_target, lambda {|tar| {:conditions => ['target_id = ? AND target_type = ?', tar.id, tar.class.to_s]}}
|
||||||
scope :by_role, lambda {|role| {:conditions => ['role = ?', role]}}
|
scope :by_role, lambda {|role| {:conditions => ['role = ?', role]}}
|
||||||
|
|
||||||
def self.create_with_role(object, target, role)
|
def self.create_with_role(actor, target, role)
|
||||||
r = new
|
r = self.new
|
||||||
r.object = object
|
r.actor = actor
|
||||||
r.target = target
|
r.target = target
|
||||||
r.role = role
|
r.role = role
|
||||||
r.save
|
r.save
|
||||||
|
|
|
@ -24,8 +24,8 @@ class User < ActiveRecord::Base
|
||||||
has_many :subscribes, :foreign_key => :user_id, :dependent => :destroy
|
has_many :subscribes, :foreign_key => :user_id, :dependent => :destroy
|
||||||
has_many :comments, :dependent => :destroy
|
has_many :comments, :dependent => :destroy
|
||||||
|
|
||||||
has_many :relations, :as => :object, :dependent => :destroy
|
has_many :relations, :as => :actor, :dependent => :destroy
|
||||||
has_many :targets, :as => :object, :class_name => 'Relation', :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 :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
||||||
has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
|
has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
%td
|
%td
|
||||||
= link_to t("layout.activity_feed.all_my_projects"), projects_path
|
= link_to t("layout.activity_feed.all_my_projects"), projects_path
|
||||||
.block
|
.block
|
||||||
- midnight = Date.today
|
- midnight = Time.now.utc.to_date
|
||||||
%h3= t("layout.activity_feed.my_builds_by_day")
|
%h3= t("layout.activity_feed.my_builds_by_day")
|
||||||
%table{:cellpadding => "0", :cellspacing => "0"}
|
%table{:cellpadding => "0", :cellspacing => "0"}
|
||||||
%tbody
|
%tbody
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
- Relation::ROLES.each_with_index do |role, i|
|
- Relation::ROLES.each_with_index do |role, i|
|
||||||
%td
|
%td
|
||||||
.radio
|
.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 }")
|
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||||
= link_to_function t("layout.delete_selected"), "deleteAdminMember();", :class => 'button'
|
= link_to_function t("layout.delete_selected"), "deleteAdminMember();", :class => 'button'
|
||||||
= link_to_function t("layout.save"), "saveAdminMember();", :class => 'button right_floated'
|
= link_to_function t("layout.save"), "saveAdminMember();", :class => 'button right_floated'
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
- Relation::ROLES.each_with_index do |role, i|
|
- Relation::ROLES.each_with_index do |role, i|
|
||||||
%td
|
%td
|
||||||
.radio
|
.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 }")
|
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||||
= link_to_function t("layout.delete_selected"), "deleteAdminGroup();", :class => 'button'
|
= link_to_function t("layout.delete_selected"), "deleteAdminGroup();", :class => 'button'
|
||||||
= link_to_function t("layout.save"), "saveAdminGroup();", :class => 'button right_floated'
|
= link_to_function t("layout.save"), "saveAdminGroup();", :class => 'button right_floated'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
= surround '[', ']' do
|
= surround '[', ']' do
|
||||||
= I18n.t "event_log.controllers.#{el.controller.underscore}", :default => el.controller
|
= 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}"
|
= 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?
|
- if el.eventable_id.present? and el.eventable_type.present?
|
||||||
= I18n.t "activerecord.models.#{el.object_type.underscore}"
|
= I18n.t "activerecord.models.#{el.eventable_type.underscore}"
|
||||||
= el.object_name
|
= el.eventable_name
|
||||||
= "(id##{el.object_id})" # link_to "id##{el.object_id}", el.object
|
= "(id##{el.eventable_id})" # link_to "id##{el.eventable_id}", el.eventable
|
||||||
= el.message
|
= el.message
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
- Relation::ROLES.each_with_index do |role, i|
|
- Relation::ROLES.each_with_index do |role, i|
|
||||||
%td
|
%td
|
||||||
.radio
|
.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 }")
|
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||||
= link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button'
|
= link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button'
|
||||||
.both
|
.both
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
.description-top
|
.description-top
|
||||||
%ul.nav.zip
|
-if @commit
|
||||||
%li#menu-archive.dropdown
|
%ul.nav.zip
|
||||||
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#menu-archive"}
|
%li#menu-archive.dropdown
|
||||||
=image_tag 'zip.png', :alt => 'ZIP'
|
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#menu-archive"}
|
||||||
%b.caret
|
=image_tag 'zip.png', :alt => 'ZIP'
|
||||||
%ul.dropdown-menu
|
%b.caret
|
||||||
%li=link_to "tar.gz", archive_path(project, 'tar', @treeish)
|
%ul.dropdown-menu
|
||||||
%li=link_to "zip", archive_path(project, 'zip', @treeish)
|
%li=link_to "tar.gz", archive_path(project, 'tar', @treeish)
|
||||||
|
%li=link_to "zip", archive_path(project, 'zip', @treeish)
|
||||||
|
|
||||||
= text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :spellcheck => 'false', :readonly => true
|
= text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :spellcheck => 'false', :readonly => true
|
||||||
.git_help ?
|
.git_help ?
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Warden::Manager.after_authentication do |user,auth,opts| # after_set_user, :except => fetch
|
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
|
end
|
||||||
|
|
||||||
Warden::Manager.before_failure do |env, opts|
|
Warden::Manager.before_failure do |env, opts|
|
||||||
|
@ -10,14 +10,14 @@ Warden::Manager.before_failure do |env, opts|
|
||||||
end
|
end
|
||||||
|
|
||||||
Warden::Manager.before_logout do |user,auth,opts|
|
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
|
end
|
||||||
|
|
||||||
ActiveSupport::Notifications.subscribe "event_log.observer" do |name, start, finish, id, payload|
|
ActiveSupport::Notifications.subscribe "event_log.observer" do |name, start, finish, id, payload|
|
||||||
if c = EventLog.current_controller
|
if c = EventLog.current_controller
|
||||||
object = payload[:object]
|
eventable = payload[:eventable]
|
||||||
message = payload[:message].presence; message ||= object.event_log_message if object.respond_to?(:event_log_message)
|
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,
|
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
|
||||||
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
|
12
db/schema.rb
12
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# 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|
|
create_table "activity_feeds", :force => true do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
|
@ -112,9 +112,9 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
|
||||||
create_table "event_logs", :force => true do |t|
|
create_table "event_logs", :force => true do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.string "user_name"
|
t.string "user_name"
|
||||||
t.integer "object_id"
|
t.integer "eventable_id"
|
||||||
t.string "object_type"
|
t.string "eventable_type"
|
||||||
t.string "object_name"
|
t.string "eventable_name"
|
||||||
t.string "ip"
|
t.string "ip"
|
||||||
t.string "kind"
|
t.string "kind"
|
||||||
t.string "protocol"
|
t.string "protocol"
|
||||||
|
@ -280,8 +280,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
|
||||||
add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false
|
add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false
|
||||||
|
|
||||||
create_table "relations", :force => true do |t|
|
create_table "relations", :force => true do |t|
|
||||||
t.integer "object_id"
|
t.integer "actor_id"
|
||||||
t.string "object_type"
|
t.string "actor_type"
|
||||||
t.integer "target_id"
|
t.integer "target_id"
|
||||||
t.string "target_type"
|
t.string "target_type"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
|
|
@ -8,10 +8,10 @@ module Modules
|
||||||
scope :not_member_of, lambda { |item|
|
scope :not_member_of, lambda { |item|
|
||||||
where("
|
where("
|
||||||
#{klass.table_name}.id NOT IN (
|
#{klass.table_name}.id NOT IN (
|
||||||
SELECT relations.object_id
|
SELECT relations.actor_id
|
||||||
FROM relations
|
FROM relations
|
||||||
WHERE (
|
WHERE (
|
||||||
relations.object_type = '#{klass.to_s}'
|
relations.actor_type = '#{klass.to_s}'
|
||||||
AND relations.target_type = '#{item.class.to_s}'
|
AND relations.target_type = '#{item.class.to_s}'
|
||||||
AND relations.target_id = #{item.id}
|
AND relations.target_id = #{item.id}
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Modules
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
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
|
end
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
|
|
|
@ -103,7 +103,7 @@ describe BuildListsController do
|
||||||
@owner_user = @project.owner
|
@owner_user = @project.owner
|
||||||
@member_user = FactoryGirl.create(:user)
|
@member_user = FactoryGirl.create(:user)
|
||||||
rel = @project.relations.build(:role => 'reader')
|
rel = @project.relations.build(:role => 'reader')
|
||||||
rel.object = @member_user
|
rel.actor = @member_user
|
||||||
rel.save
|
rel.save
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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_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_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 = 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
|
end
|
||||||
|
|
||||||
it 'should be able to perform index action' do
|
it 'should be able to perform index action' do
|
||||||
|
@ -177,17 +177,17 @@ describe BuildListsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@owner_group = FactoryGirl.create(:group)
|
@owner_group = FactoryGirl.create(:group)
|
||||||
@owner_user = FactoryGirl.create(:user)
|
@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_group = FactoryGirl.create(:group)
|
||||||
@member_user = FactoryGirl.create(:user)
|
@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)
|
@group = FactoryGirl.create(:group)
|
||||||
@user = FactoryGirl.create(:user)
|
@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 = 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)
|
@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_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_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 = 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
|
end
|
||||||
|
|
||||||
it 'should be able to perform index action' do
|
it 'should be able to perform index action' do
|
||||||
|
|
|
@ -31,12 +31,12 @@ shared_examples_for 'project admin user' do
|
||||||
|
|
||||||
it 'should add new collaborator with reader role' do
|
it 'should add new collaborator with reader role' do
|
||||||
post :create, @create_params.merge(:collaborator => @user_params)
|
post :create, @create_params.merge(:collaborator => @user_params)
|
||||||
@project.relations.exists?(:object_type => 'User', :object_id => @another_user.id, :role => 'reader').should be_true
|
@project.relations.exists?(:actor_type => 'User', :actor_id => @another_user.id, :role => 'reader').should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should add new group with reader role' do
|
it 'should add new group with reader role' do
|
||||||
post :create, @create_params.merge(:collaborator => @group_params)
|
post :create, @create_params.merge(:collaborator => @group_params)
|
||||||
@project.relations.exists?(:object_type => 'Group', :object_id => @group.id, :role => 'reader').should be_true
|
@project.relations.exists?(:actor_type => 'Group', :actor_id => @group.id, :role => 'reader').should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to set reader role for any user' do
|
it 'should be able to set reader role for any user' do
|
||||||
|
@ -102,7 +102,7 @@ describe CollaboratorsController do
|
||||||
# @user.relations
|
# @user.relations
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@group = FactoryGirl.create(:group)
|
@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
|
create_params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ describe CollaboratorsController do
|
||||||
@group = FactoryGirl.create(:group)
|
@group = FactoryGirl.create(:group)
|
||||||
|
|
||||||
@project.update_attribute(:owner, @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')
|
||||||
|
|
||||||
create_params
|
create_params
|
||||||
end
|
end
|
||||||
|
@ -129,7 +129,7 @@ describe CollaboratorsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user with no rights for this project'
|
it_should_behave_like 'user with no rights for this project'
|
||||||
|
@ -139,7 +139,7 @@ describe CollaboratorsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user with no rights for this project'
|
it_should_behave_like 'user with no rights for this project'
|
||||||
|
|
|
@ -93,7 +93,7 @@ describe CommentsController do
|
||||||
|
|
||||||
context 'for project admin user' do
|
context 'for project admin user' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user with create comment rights for commits'
|
it_should_behave_like 'user with create comment rights for commits'
|
||||||
|
@ -119,7 +119,7 @@ describe CommentsController do
|
||||||
|
|
||||||
context 'for project reader user' do
|
context 'for project reader user' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user with create comment rights for commits'
|
it_should_behave_like 'user with create comment rights for commits'
|
||||||
|
@ -130,7 +130,7 @@ describe CommentsController do
|
||||||
|
|
||||||
context 'for project writer user' do
|
context 'for project writer user' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user with create comment rights for commits'
|
it_should_behave_like 'user with create comment rights for commits'
|
||||||
|
|
|
@ -90,7 +90,7 @@ describe CommentsController do
|
||||||
|
|
||||||
context 'for project admin user' do
|
context 'for project admin user' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user with create comment rights'
|
it_should_behave_like 'user with create comment rights'
|
||||||
|
@ -113,7 +113,7 @@ describe CommentsController do
|
||||||
|
|
||||||
context 'for project reader user' do
|
context 'for project reader user' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user with create comment rights'
|
it_should_behave_like 'user with create comment rights'
|
||||||
|
@ -124,7 +124,7 @@ describe CommentsController do
|
||||||
|
|
||||||
context 'for project writer user' do
|
context 'for project writer user' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user with create comment rights'
|
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
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'update_member_relation'
|
it_should_behave_like 'update_member_relation'
|
||||||
|
@ -130,7 +130,7 @@ describe GroupsController do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@group.update_attribute(:owner, @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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'update_member_relation'
|
it_should_behave_like 'update_member_relation'
|
||||||
|
@ -141,7 +141,7 @@ describe GroupsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'no group user'
|
it_should_behave_like 'no group user'
|
||||||
|
|
|
@ -114,7 +114,7 @@ describe IssuesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'issue user with project reader rights'
|
it_should_behave_like 'issue user with project reader rights'
|
||||||
|
@ -129,7 +129,7 @@ describe IssuesController do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.update_attribute(:owner, @user); @create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname
|
@project.update_attribute(:owner, @user); @create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname
|
||||||
@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'issue user with project reader rights'
|
it_should_behave_like 'issue user with project reader rights'
|
||||||
|
@ -143,7 +143,7 @@ describe IssuesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'issue user with project reader rights'
|
it_should_behave_like 'issue user with project reader rights'
|
||||||
|
@ -165,7 +165,7 @@ describe IssuesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'issue user with project reader rights'
|
it_should_behave_like 'issue user with project reader rights'
|
||||||
|
|
|
@ -15,12 +15,12 @@ describe MembersController do
|
||||||
it 'should add member to group' do
|
it 'should add member to group' do
|
||||||
post :add, @add_params
|
post :add, @add_params
|
||||||
response.should redirect_to(edit_group_members_path(@group))
|
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
|
end
|
||||||
|
|
||||||
it 'should add reader member to group' do
|
it 'should add reader member to group' do
|
||||||
post :add, @add_params
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -105,7 +105,7 @@ describe PlatformsController do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@platform.update_attribute(:owner, @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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'user without create rights'
|
it_should_behave_like 'user without create rights'
|
||||||
|
@ -127,7 +127,7 @@ describe PlatformsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'platform index viewer'
|
it_should_behave_like 'platform index viewer'
|
||||||
|
|
|
@ -92,7 +92,7 @@ describe ProductBuildListsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'admin'
|
it_should_behave_like 'admin'
|
||||||
|
|
|
@ -64,7 +64,7 @@ describe ProductsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'admin user'
|
it_should_behave_like 'admin user'
|
||||||
|
|
|
@ -48,7 +48,7 @@ describe ProjectsController do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@project.update_attribute(:owner, @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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'projects user with admin rights'
|
it_should_behave_like 'projects user with admin rights'
|
||||||
|
@ -75,7 +75,7 @@ describe ProjectsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'projects user with reader rights'
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
@ -85,7 +85,7 @@ describe ProjectsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'projects user with reader rights'
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
@ -104,9 +104,9 @@ describe ProjectsController do
|
||||||
|
|
||||||
it 'should be able to fork project to group' do
|
it 'should be able to fork project to group' do
|
||||||
group = FactoryGirl.create(:group)
|
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, :owner_name => @project.owner.uname, :project_name => @project.name, :group => group.id
|
post :fork, :owner_name => @project.owner.uname, :project_name => @project.name, :group => group.id
|
||||||
response.should redirect_to(project_path(group.projects.first))
|
response.should redirect_to(project_path(group.projects.first.id))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ describe RepositoriesController do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@repository.platform.update_attribute(:owner, @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
|
end
|
||||||
|
|
||||||
it_should_behave_like 'platform admin user'
|
it_should_behave_like 'platform admin user'
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe SubscribesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:admin)
|
@user = FactoryGirl.create(:admin)
|
||||||
set_session_for(@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')
|
||||||
@destroy_params = @destroy_params.merge({:id => @user.id})
|
@destroy_params = @destroy_params.merge({:id => @user.id})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ describe CanCan do
|
||||||
|
|
||||||
context 'with read rights' do
|
context 'with read rights' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it 'should be able to read project' do
|
it 'should be able to read project' do
|
||||||
|
@ -165,7 +165,7 @@ describe CanCan do
|
||||||
|
|
||||||
context 'with writer rights' do
|
context 'with writer rights' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
[:read, :create, :new].each do |action|
|
[:read, :create, :new].each do |action|
|
||||||
|
@ -184,7 +184,7 @@ describe CanCan do
|
||||||
|
|
||||||
context 'with admin rights' do
|
context 'with admin rights' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
[:read, :update].each do |action|
|
[:read, :update].each do |action|
|
||||||
|
@ -258,7 +258,7 @@ describe CanCan do
|
||||||
|
|
||||||
context 'with read rights' do
|
context 'with read rights' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it "should be able to read platform" do
|
it "should be able to read platform" do
|
||||||
|
@ -286,7 +286,7 @@ describe CanCan do
|
||||||
|
|
||||||
context 'with read rights' do
|
context 'with read rights' do
|
||||||
before(:each) 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
|
end
|
||||||
|
|
||||||
it "should be able to read repository" do
|
it "should be able to read repository" do
|
||||||
|
@ -298,7 +298,7 @@ describe CanCan do
|
||||||
context 'build list relations' do
|
context 'build list relations' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@project = FactoryGirl.create(:project)
|
@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)
|
@build_list = FactoryGirl.create(:build_list, :project => @project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ describe Comment do
|
||||||
set_comments_data_for_commit
|
set_comments_data_for_commit
|
||||||
@admin = FactoryGirl.create(:user)
|
@admin = FactoryGirl.create(:user)
|
||||||
@ability = Ability.new(@admin)
|
@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 = []
|
ActionMailer::Base.deliveries = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ describe Comment do
|
||||||
|
|
||||||
set_commentable_data
|
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
|
end
|
||||||
|
|
||||||
it 'should create comment' do
|
it 'should create comment' do
|
||||||
|
@ -85,7 +85,7 @@ describe Comment do
|
||||||
set_commentable_data
|
set_commentable_data
|
||||||
|
|
||||||
@project.update_attribute(:owner, @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
|
end
|
||||||
|
|
||||||
it 'should create comment' do
|
it 'should create comment' do
|
||||||
|
|
|
@ -34,7 +34,7 @@ describe Group do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@another_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)
|
@ability = Ability.new(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ describe Group do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@group.update_attribute(:owner, @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)
|
@ability = Ability.new(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ describe Group do
|
||||||
context 'for group reader and writer user' do
|
context 'for group reader and writer user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = FactoryGirl.create(:user)
|
@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)
|
@ability = Ability.new(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue