[issue #428] Merge branch 'master' into 428-advisory
Conflicts: app/assets/stylesheets/design/custom.scss db/schema.rb
This commit is contained in:
commit
e00e88340b
1
Gemfile
1
Gemfile
|
@ -20,6 +20,7 @@ gem 'resque_mailer', '~> 2.1.0'
|
||||||
gem 'perform_later', '~> 1.3.0' # should be after resque_mailer
|
gem 'perform_later', '~> 1.3.0' # should be after resque_mailer
|
||||||
gem 'russian', '~> 0.6.0'
|
gem 'russian', '~> 0.6.0'
|
||||||
gem 'highline', '~> 1.6.11'
|
gem 'highline', '~> 1.6.11'
|
||||||
|
gem 'state_machine'
|
||||||
|
|
||||||
# gem 'rugged', '~> 0.16.0'
|
# gem 'rugged', '~> 0.16.0'
|
||||||
gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
|
gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
|
||||||
|
|
|
@ -389,6 +389,7 @@ DEPENDENCIES
|
||||||
sass-rails (~> 3.2.5)
|
sass-rails (~> 3.2.5)
|
||||||
shotgun
|
shotgun
|
||||||
shoulda
|
shoulda
|
||||||
|
state_machine
|
||||||
therubyracer (~> 0.10.1)
|
therubyracer (~> 0.10.1)
|
||||||
therubyrhino (~> 1.73.1)
|
therubyrhino (~> 1.73.1)
|
||||||
trinidad (~> 1.0.2)
|
trinidad (~> 1.0.2)
|
||||||
|
|
|
@ -71,4 +71,14 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".toggle_btn").click(function() {
|
||||||
|
var target = $( $(this).attr('data-target') );
|
||||||
|
//target.toggle();
|
||||||
|
if ( target.css('visibility') == 'hidden' ) {
|
||||||
|
target.css('visibility', 'visible');
|
||||||
|
} else {
|
||||||
|
target.css('visibility', 'hidden');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -71,7 +71,7 @@ function setBranchSelected() {
|
||||||
var pl_id = $('#build_list_save_to_platform_id').val();
|
var pl_id = $('#build_list_save_to_platform_id').val();
|
||||||
// Checks if selected platform is main or not:
|
// Checks if selected platform is main or not:
|
||||||
if ( $('.all_platforms').find('input[type="checkbox"][value=' + pl_id + '].build_bpl_ids').size() > 0 ) {
|
if ( $('.all_platforms').find('input[type="checkbox"][value=' + pl_id + '].build_bpl_ids').size() > 0 ) {
|
||||||
var pl_name = $('#build_list_save_to_platform_id option[value="' + pl_id + '"]').text().match(/([\w-]+)\/[\w-]+/)[1];
|
var pl_name = $('#build_list_save_to_platform_id option[value="' + pl_id + '"]').text().match(/([\w-.]+)\/[\w-.]+/)[1];
|
||||||
var branch_pl_opt = $('#build_list_project_version option[value="latest_' + pl_name + '"]');
|
var branch_pl_opt = $('#build_list_project_version option[value="latest_' + pl_name + '"]');
|
||||||
// If there is branch we need - set it selected:
|
// If there is branch we need - set it selected:
|
||||||
if ( branch_pl_opt.size() > 0 ) {
|
if ( branch_pl_opt.size() > 0 ) {
|
||||||
|
|
|
@ -1126,6 +1126,17 @@ form.mass_build section.right {
|
||||||
margin-right: 50px;
|
margin-right: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.toggle {
|
||||||
|
overflow: hidden;
|
||||||
|
padding-top: 10px;
|
||||||
|
display: block;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.min_width_120 {
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
.chzn-select {
|
.chzn-select {
|
||||||
width: 350px;
|
width: 350px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Platforms::PlatformsController < Platforms::BaseController
|
||||||
if mass_build.save
|
if mass_build.save
|
||||||
redirect_to(mass_builds_platform_path(@platform), :notice => t("flash.platform.build_all_success"))
|
redirect_to(mass_builds_platform_path(@platform), :notice => t("flash.platform.build_all_success"))
|
||||||
else
|
else
|
||||||
|
@auto_publish_selected = params[:auto_publish].present?
|
||||||
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
||||||
flash[:warning] = mass_build.errors.full_messages.join('. ')
|
flash[:warning] = mass_build.errors.full_messages.join('. ')
|
||||||
flash[:error] = t("flash.platform.build_all_error")
|
flash[:error] = t("flash.platform.build_all_error")
|
||||||
|
@ -26,9 +27,15 @@ class Platforms::PlatformsController < Platforms::BaseController
|
||||||
|
|
||||||
def mass_builds
|
def mass_builds
|
||||||
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
||||||
|
@auto_publish_selected = true
|
||||||
render :action => :build_all
|
render :action => :build_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def failed_builds_list
|
||||||
|
@mass_build = MassBuild.find params[:mass_build_id]
|
||||||
|
render :text => @mass_build.generate_failed_builds_list
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@platforms = @platforms.accessible_by(current_ability, :related).paginate(:page => params[:page], :per_page => 20)
|
@platforms = @platforms.accessible_by(current_ability, :related).paginate(:page => params[:page], :per_page => 20)
|
||||||
end
|
end
|
||||||
|
@ -143,4 +150,11 @@ class Platforms::PlatformsController < Platforms::BaseController
|
||||||
def advisories
|
def advisories
|
||||||
@advisories = @platform.advisories.paginate(:page => params[:page])
|
@advisories = @platform.advisories.paginate(:page => params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear
|
||||||
|
@platform.clear
|
||||||
|
flash[:notice] = t('flash.repository.clear')
|
||||||
|
redirect_to edit_platform_path(@platform)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,14 +11,13 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
|
||||||
before_filter :find_product_build_list, :only => [:status_build]
|
before_filter :find_product_build_list, :only => [:status_build]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@product.product_build_lists.create! :base_url => "http://#{request.host_with_port}", :notified_at => Time.current
|
@product.product_build_lists.create! :base_url => "http://#{request.host_with_port}"
|
||||||
flash[:notice] = t('flash.product.build_started')
|
flash[:notice] = t('flash.product.build_started')
|
||||||
redirect_to [@platform, @product]
|
redirect_to [@platform, @product]
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_build
|
def status_build
|
||||||
@product_build_list.status = params[:status].to_i # ProductBuildList::BUILD_COMPLETED : ProductBuildList::BUILD_FAILED)
|
@product_build_list.status = params[:status].to_i # ProductBuildList::BUILD_COMPLETED : ProductBuildList::BUILD_FAILED)
|
||||||
@product_build_list.notified_at = Time.current
|
|
||||||
@product_build_list.save!
|
@product_build_list.save!
|
||||||
render :nothing => true
|
render :nothing => true
|
||||||
end
|
end
|
||||||
|
@ -46,7 +45,8 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_product_builder!
|
def authenticate_product_builder!
|
||||||
unless APP_CONFIG['product_builder_ip'].values.include?(request.remote_ip)
|
# FIXME: Rails(?) interpret the internal IP as 127.0.0.1
|
||||||
|
unless (APP_CONFIG['product_builder_ip'].values + ["127.0.0.1"]).include?(request.remote_ip)
|
||||||
render :nothing => true, :status => 403
|
render :nothing => true, :status => 403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -94,13 +94,10 @@ class Projects::BuildListsController < Projects::BaseController
|
||||||
|
|
||||||
def publish_build
|
def publish_build
|
||||||
if params[:status].to_i == 0 # ok
|
if params[:status].to_i == 0 # ok
|
||||||
@build_list.status = BuildList::BUILD_PUBLISHED
|
@build_list.published
|
||||||
@build_list.package_version = "#{params[:version]}-#{params[:release]}"
|
|
||||||
system("cd #{@build_list.project.git_repository.path} && git tag #{@build_list.package_version} #{@build_list.commit_hash}") # TODO REDO through grit
|
|
||||||
else
|
else
|
||||||
@build_list.status = BuildList::FAILED_PUBLISH
|
@build_list.fail_publish
|
||||||
end
|
end
|
||||||
@build_list.save
|
|
||||||
|
|
||||||
render :nothing => true, :status => 200
|
render :nothing => true, :status => 200
|
||||||
end
|
end
|
||||||
|
@ -119,14 +116,13 @@ class Projects::BuildListsController < Projects::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def pre_build
|
def pre_build
|
||||||
@build_list.status = BuildServer::BUILD_STARTED
|
@build_list.start_build
|
||||||
@build_list.save
|
|
||||||
|
|
||||||
render :nothing => true, :status => 200
|
render :nothing => true, :status => 200
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_build
|
def post_build
|
||||||
@build_list.status = params[:status]
|
params[:status].to_i == BuildServer::SUCCESS ? @build_list.build_success : @build_list.build_error
|
||||||
@build_list.container_path = params[:container_path]
|
@build_list.container_path = params[:container_path]
|
||||||
@build_list.save
|
@build_list.save
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Ability
|
||||||
can :read, Issue, :project => {:visibility => 'open'}
|
can :read, Issue, :project => {:visibility => 'open'}
|
||||||
can :search, BuildList
|
can :search, BuildList
|
||||||
can :read, BuildList, :project => {:visibility => 'open'}
|
can :read, BuildList, :project => {:visibility => 'open'}
|
||||||
can :read, ProductBuildList, :product => {:platform => {:visibility => 'open'}}
|
can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
|
||||||
can :read, Advisory
|
can :read, Advisory
|
||||||
can(:advisories, Platform) {APP_CONFIG['anonymous_access']}
|
can(:advisories, Platform) {APP_CONFIG['anonymous_access']}
|
||||||
# Core callbacks
|
# Core callbacks
|
||||||
|
@ -91,6 +91,7 @@ class Ability
|
||||||
can [:read, :projects_list], Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
|
can [:read, :projects_list], Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||||
can([:read, :projects_list], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
|
can([:read, :projects_list], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
|
||||||
can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform}
|
can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform}
|
||||||
|
can(:clear, Platform) {|platform| local_admin?(platform) && platform.platform_type == 'personal'}
|
||||||
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
|
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
|
||||||
|
|
||||||
can :read, Product, :platform => {:visibility => 'open'}
|
can :read, Product, :platform => {:visibility => 'open'}
|
||||||
|
@ -120,6 +121,7 @@ class Ability
|
||||||
# Shared cannot rights for all users (registered, admin)
|
# Shared cannot rights for all users (registered, admin)
|
||||||
cannot :destroy, Platform, :platform_type => 'personal'
|
cannot :destroy, Platform, :platform_type => 'personal'
|
||||||
cannot [:create, :destroy, :add_project, :remove_project], Repository, :platform => {:platform_type => 'personal'}
|
cannot [:create, :destroy, :add_project, :remove_project], Repository, :platform => {:platform_type => 'personal'}
|
||||||
|
cannot :clear, Platform, :platform_type => 'main'
|
||||||
cannot :destroy, Issue
|
cannot :destroy, Issue
|
||||||
|
|
||||||
cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal'
|
cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal'
|
||||||
|
@ -146,21 +148,16 @@ class Ability
|
||||||
relations.actor_type = 'Group' AND relations.actor_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(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?(target)
|
def local_reader?(target)
|
||||||
relation_exists_for(target, %w{reader writer admin}) or owner?(target)
|
%w{reader writer admin}.include? @user.best_role(target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_writer?(target)
|
def local_writer?(target)
|
||||||
relation_exists_for(target, %w{writer admin}) or owner?(target)
|
%w{writer admin}.include? @user.best_role(target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_admin?(target)
|
def local_admin?(target)
|
||||||
relation_exists_for(target, 'admin') or owner?(target)
|
@user.best_role(target) == 'admin'
|
||||||
end
|
end
|
||||||
|
|
||||||
def owner?(target)
|
def owner?(target)
|
||||||
|
|
|
@ -6,7 +6,7 @@ class BuildList < ActiveRecord::Base
|
||||||
belongs_to :build_for_platform, :class_name => 'Platform'
|
belongs_to :build_for_platform, :class_name => 'Platform'
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :advisory
|
belongs_to :advisory
|
||||||
belongs_to :mass_build
|
belongs_to :mass_build, :counter_cache => true
|
||||||
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
|
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
|
||||||
has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy
|
has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy
|
||||||
|
|
||||||
|
@ -96,10 +96,121 @@ class BuildList < ActiveRecord::Base
|
||||||
serialize :additional_repos
|
serialize :additional_repos
|
||||||
serialize :include_repos
|
serialize :include_repos
|
||||||
|
|
||||||
before_create :set_default_status
|
after_commit :place_build
|
||||||
after_create :place_build
|
|
||||||
after_destroy :delete_container
|
after_destroy :delete_container
|
||||||
|
|
||||||
|
@queue = :clone_and_build
|
||||||
|
|
||||||
|
state_machine :status, :initial => :waiting_for_response do
|
||||||
|
|
||||||
|
# WTF? around_transition -> infinite loop
|
||||||
|
before_transition do |build_list, transition|
|
||||||
|
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status)
|
||||||
|
MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
after_transition do |build_list, transition|
|
||||||
|
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status)
|
||||||
|
MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
after_transition :on => :published, :do => :set_version_and_tag
|
||||||
|
|
||||||
|
event :place_build do
|
||||||
|
transition :waiting_for_response => :build_pending, :if => lambda { |build_list|
|
||||||
|
build_list.add_to_queue == BuildServer::SUCCESS
|
||||||
|
}
|
||||||
|
[
|
||||||
|
'BuildList::BUILD_PENDING',
|
||||||
|
'BuildServer::PLATFORM_PENDING',
|
||||||
|
'BuildServer::PLATFORM_NOT_FOUND',
|
||||||
|
'BuildServer::PROJECT_NOT_FOUND',
|
||||||
|
'BuildServer::PROJECT_VERSION_NOT_FOUND'
|
||||||
|
].each do |code|
|
||||||
|
transition :waiting_for_response => code.demodulize.downcase.to_sym, :if => lambda { |build_list|
|
||||||
|
build_list.add_to_queue == code.constantize
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
event :start_build do
|
||||||
|
transition [ :build_pending,
|
||||||
|
:platform_pending,
|
||||||
|
:platform_not_found,
|
||||||
|
:project_not_found,
|
||||||
|
:project_version_not_found ] => :build_started
|
||||||
|
end
|
||||||
|
|
||||||
|
event :cancel do
|
||||||
|
transition [:build_pending, :platform_pending] => :build_canceled, :if => lambda { |build_list|
|
||||||
|
build_list.can_cancel? && BuildServer.delete_build_list(build_list.bs_id) == BuildServer::SUCCESS
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
event :published do
|
||||||
|
transition [:build_publish, :rejected_publish] => :build_published
|
||||||
|
end
|
||||||
|
|
||||||
|
event :fail_publish do
|
||||||
|
transition [:build_publish, :rejected_publish] => :failed_publish
|
||||||
|
end
|
||||||
|
|
||||||
|
event :publish do
|
||||||
|
transition [:success, :failed_publish] => :build_publish, :if => lambda { |build_list|
|
||||||
|
BuildServer.publish_container(build_list.bs_id) == BuildServer::SUCCESS
|
||||||
|
}
|
||||||
|
transition [:success, :failed_publish] => :failed_publish
|
||||||
|
end
|
||||||
|
|
||||||
|
event :reject_publish do
|
||||||
|
transition :success => :rejected_publish, :if => :can_reject_publish?
|
||||||
|
end
|
||||||
|
|
||||||
|
event :build_success do
|
||||||
|
transition [:build_started, :build_canceled] => :success
|
||||||
|
end
|
||||||
|
|
||||||
|
event :build_error do
|
||||||
|
transition [:build_started, :build_canceled] => :build_error
|
||||||
|
end
|
||||||
|
|
||||||
|
HUMAN_STATUSES.each do |code,name|
|
||||||
|
state name, :value => code
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
later :publish, :queue => :clone_build
|
||||||
|
|
||||||
|
def set_version_and_tag
|
||||||
|
pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first
|
||||||
|
# TODO: remove 'return' after deployment ABF kernel 2.0
|
||||||
|
return if pkg.nil? # For old client that does not sends data about packages
|
||||||
|
self.package_version = "#{pkg.platform.name}-#{pkg.version}-#{pkg.release}"
|
||||||
|
system("cd #{self.project.git_repository.path} && git tag #{self.package_version} #{self.commit_hash}") # TODO REDO through grit
|
||||||
|
save
|
||||||
|
end
|
||||||
|
|
||||||
|
#TODO: Share this checking on product owner.
|
||||||
|
def can_cancel?
|
||||||
|
[BUILD_PENDING, BuildServer::PLATFORM_PENDING].include?(status) && bs_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_publish?
|
||||||
|
[BuildServer::SUCCESS, FAILED_PUBLISH].include? status
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_reject_publish?
|
||||||
|
can_publish? and save_to_platform.released
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def add_to_queue
|
||||||
|
#XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority
|
||||||
|
@status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority
|
||||||
|
end
|
||||||
|
|
||||||
def self.human_status(status)
|
def self.human_status(status)
|
||||||
I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}")
|
I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}")
|
||||||
end
|
end
|
||||||
|
@ -126,39 +237,6 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish
|
|
||||||
return false unless can_publish?
|
|
||||||
has_published = BuildServer.publish_container bs_id
|
|
||||||
update_attribute(:status, has_published == 0 ? BUILD_PUBLISH : FAILED_PUBLISH)
|
|
||||||
return has_published == 0
|
|
||||||
end
|
|
||||||
later :publish, :loner => true, :queue => :clone_build
|
|
||||||
|
|
||||||
def can_publish?
|
|
||||||
status == BuildServer::SUCCESS or status == FAILED_PUBLISH
|
|
||||||
end
|
|
||||||
|
|
||||||
def reject_publish
|
|
||||||
return false unless can_reject_publish?
|
|
||||||
update_attribute(:status, REJECTED_PUBLISH)
|
|
||||||
end
|
|
||||||
|
|
||||||
def can_reject_publish?
|
|
||||||
can_publish? and save_to_platform.released
|
|
||||||
end
|
|
||||||
|
|
||||||
def cancel
|
|
||||||
return false unless can_cancel?
|
|
||||||
has_canceled = BuildServer.delete_build_list bs_id
|
|
||||||
update_attribute(:status, BUILD_CANCELED) if has_canceled == 0
|
|
||||||
return has_canceled == 0
|
|
||||||
end
|
|
||||||
|
|
||||||
#TODO: Share this checking on product owner.
|
|
||||||
def can_cancel?
|
|
||||||
status == BUILD_PENDING && bs_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def event_log_message
|
def event_log_message
|
||||||
{:project => project.name, :version => project_version, :arch => arch.name}.inspect
|
{:project => project.name, :version => project_version, :arch => arch.name}.inspect
|
||||||
end
|
end
|
||||||
|
@ -182,19 +260,6 @@ class BuildList < ActiveRecord::Base
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def set_default_status
|
|
||||||
self.status = WAITING_FOR_RESPONSE unless self.status.present?
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
def place_build
|
|
||||||
#XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority
|
|
||||||
self.status = BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority
|
|
||||||
self.status = BUILD_PENDING if self.status == 0
|
|
||||||
save
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def delete_container
|
def delete_container
|
||||||
if can_cancel?
|
if can_cancel?
|
||||||
BuildServer.delete_build_list bs_id
|
BuildServer.delete_build_list bs_id
|
||||||
|
|
|
@ -7,13 +7,13 @@ class BuildListObserver < ActiveRecord::Observer
|
||||||
if [BuildServer::BUILD_ERROR, BuildServer::SUCCESS].include? record.status
|
if [BuildServer::BUILD_ERROR, BuildServer::SUCCESS].include? record.status
|
||||||
# stores time interval beetwin build start and finish in seconds
|
# stores time interval beetwin build start and finish in seconds
|
||||||
record.duration = record.current_duration
|
record.duration = record.current_duration
|
||||||
|
|
||||||
if record.status == BuildServer::SUCCESS
|
if record.status == BuildServer::SUCCESS
|
||||||
# Update project average build time
|
# Update project average build time
|
||||||
build_count = record.project.build_count
|
build_count = record.project.build_count
|
||||||
new_av_time = ( record.project.average_build_time * build_count + record.duration ) / ( build_count + 1 )
|
new_av_time = ( record.project.average_build_time * build_count + record.duration ) / ( build_count + 1 )
|
||||||
record.project.update_attributes({ :average_build_time => new_av_time, :build_count => build_count + 1 }, :without_protection => true)
|
record.project.update_attributes({ :average_build_time => new_av_time, :build_count => build_count + 1 }, :without_protection => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class GitHook
|
||||||
|
|
||||||
include Resque::Plugins::Status
|
include Resque::Plugins::Status
|
||||||
|
|
||||||
def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type)
|
def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, oldrev_type = nil)
|
||||||
@repo, @newrev, @oldrev, @refname, @newrev_type, @oldrev_type = repo, newrev, oldrev, ref, newrev_type, oldrev_type
|
@repo, @newrev, @oldrev, @refname, @newrev_type, @oldrev_type = repo, newrev, oldrev, ref, newrev_type, oldrev_type
|
||||||
if @owner = User.where(:uname => owner_uname).first || Group.where(:uname => owner_uname).first!
|
if @owner = User.where(:uname => owner_uname).first || Group.where(:uname => owner_uname).first!
|
||||||
@project = @owner.own_projects.where(:name => repo).first!
|
@project = @owner.own_projects.where(:name => repo).first!
|
||||||
|
|
|
@ -12,6 +12,15 @@ class MassBuild < ActiveRecord::Base
|
||||||
|
|
||||||
after_create :build_all
|
after_create :build_all
|
||||||
|
|
||||||
|
COUNT_STATUSES = [
|
||||||
|
:build_lists,
|
||||||
|
:build_published,
|
||||||
|
:build_pending,
|
||||||
|
:build_started,
|
||||||
|
:build_publish,
|
||||||
|
:build_error
|
||||||
|
]
|
||||||
|
|
||||||
def initialize(args = nil)
|
def initialize(args = nil)
|
||||||
super
|
super
|
||||||
|
|
||||||
|
@ -32,4 +41,13 @@ class MassBuild < ActiveRecord::Base
|
||||||
:auto_publish => self.auto_publish
|
:auto_publish => self.auto_publish
|
||||||
) # later with resque
|
) # later with resque
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_failed_builds_list
|
||||||
|
report = ""
|
||||||
|
BuildList.where(:status => BuildServer::BUILD_ERROR, :mass_build_id => self.id).each do |build_list|
|
||||||
|
report << "ID: #{build_list.id}; "
|
||||||
|
report << "PROJECT_NAME: #{build_list.project.name}\n"
|
||||||
|
end
|
||||||
|
report
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,6 +48,10 @@ class Platform < ActiveRecord::Base
|
||||||
|
|
||||||
include Modules::Models::Owner
|
include Modules::Models::Owner
|
||||||
|
|
||||||
|
def clear
|
||||||
|
system("rm -Rf #{ APP_CONFIG['root_path'] }/platforms/#{ self.name }/repository/*")
|
||||||
|
end
|
||||||
|
|
||||||
def urpmi_list(host, pair = nil)
|
def urpmi_list(host, pair = nil)
|
||||||
blank_pair = {:login => 'login', :pass => 'password'}
|
blank_pair = {:login => 'login', :pass => 'password'}
|
||||||
pair = blank_pair if pair.blank?
|
pair = blank_pair if pair.blank?
|
||||||
|
@ -184,7 +188,7 @@ class Platform < ActiveRecord::Base
|
||||||
def destroy
|
def destroy
|
||||||
with_skip {super} # avoid cascade XML RPC requests
|
with_skip {super} # avoid cascade XML RPC requests
|
||||||
end
|
end
|
||||||
later :destroy, :loner => true, :queue => :clone_build
|
later :destroy, :queue => :clone_build
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] }
|
validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] }
|
||||||
|
|
||||||
attr_accessor :base_url
|
attr_accessor :base_url
|
||||||
attr_accessible :status, :notified_at, :base_url
|
attr_accessible :status, :base_url
|
||||||
attr_readonly :product_id
|
attr_readonly :product_id
|
||||||
|
|
||||||
|
|
||||||
scope :default_order, order('notified_at DESC')
|
scope :default_order, order('updated_at DESC')
|
||||||
scope :for_status, lambda {|status| where(:status => status) }
|
scope :for_status, lambda {|status| where(:status => status) }
|
||||||
scope :for_user, lambda { |user| where(:user_id => user.id) }
|
scope :for_user, lambda { |user| where(:user_id => user.id) }
|
||||||
scope :scoped_to_product_name, lambda {|product_name| joins(:product).where('products.name LIKE ?', "%#{product_name}%")}
|
scope :scoped_to_product_name, lambda {|product_name| joins(:product).where('products.name LIKE ?', "%#{product_name}%")}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
after_create :attach_to_personal_repository
|
after_create :attach_to_personal_repository
|
||||||
after_create :create_git_repo
|
after_create :create_git_repo
|
||||||
after_create {|p| p.fork_git_repo unless is_root?} # later with resque
|
after_create {|p| p.fork_git_repo unless p.is_root?}
|
||||||
after_save :create_wiki
|
after_save :create_wiki
|
||||||
|
|
||||||
after_destroy :destroy_git_repo
|
after_destroy :destroy_git_repo
|
||||||
|
@ -247,15 +247,15 @@ class Project < ActiveRecord::Base
|
||||||
def create_git_repo
|
def create_git_repo
|
||||||
if is_root?
|
if is_root?
|
||||||
Grit::Repo.init_bare(path)
|
Grit::Repo.init_bare(path)
|
||||||
write_hook # later with resque
|
write_hook
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fork_git_repo
|
def fork_git_repo
|
||||||
dummy = Grit::Repo.new(path) rescue parent.git_repository.repo.fork_bare(path)
|
dummy = Grit::Repo.new(path) rescue parent.git_repository.repo.fork_bare(path)
|
||||||
now_write_hook
|
write_hook
|
||||||
end
|
end
|
||||||
later :fork_git_repo, :loner => true, :queue => :fork_import
|
later :fork_git_repo, :queue => :fork_import
|
||||||
|
|
||||||
def destroy_git_repo
|
def destroy_git_repo
|
||||||
FileUtils.rm_rf path
|
FileUtils.rm_rf path
|
||||||
|
@ -267,7 +267,7 @@ class Project < ActiveRecord::Base
|
||||||
self.srpm = nil; save # clear srpm
|
self.srpm = nil; save # clear srpm
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
later :import_attached_srpm, :loner => true, :queue => :fork_import
|
later :import_attached_srpm, :queue => :fork_import
|
||||||
|
|
||||||
def create_wiki
|
def create_wiki
|
||||||
if has_wiki && !FileTest.exist?(wiki_path)
|
if has_wiki && !FileTest.exist?(wiki_path)
|
||||||
|
@ -300,5 +300,4 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
rescue Exception # FIXME
|
rescue Exception # FIXME
|
||||||
end
|
end
|
||||||
later :write_hook, :loner => true, :queue => :hook
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -129,4 +129,28 @@ class User < ActiveRecord::Base
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def best_role target
|
||||||
|
roles = target_roles(target)
|
||||||
|
return nil if roles.count == 0
|
||||||
|
%w(admin writer reader).each {|role| return role if roles.include?(role)}
|
||||||
|
raise "unknown user #{self.uname} roles #{roles}"
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def target_roles target
|
||||||
|
rel, gr, roles = target.relations, self.groups, []
|
||||||
|
|
||||||
|
if target.owner.class == Group
|
||||||
|
owner_group = self.groups.where(:id => target.owner.id).first
|
||||||
|
roles += owner_group.actors.where(:actor_id => self) if owner_group# user group is owner
|
||||||
|
|
||||||
|
gr = gr.where('groups.id != ?', target.owner.id) # exclude target owner group from users group list
|
||||||
|
end
|
||||||
|
roles += rel.where(:actor_id => self.id, :actor_type => 'User') # user is member
|
||||||
|
roles += rel.where(:actor_id => gr, :actor_type => 'Group') # user group is member
|
||||||
|
roles.map(&:role).uniq
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
.both
|
.both
|
||||||
%h3= t("activerecord.attributes.build_list.preferences")
|
%h3= t("activerecord.attributes.build_list.preferences")
|
||||||
.both.bottom_20
|
.both.bottom_20
|
||||||
= check_box_tag :auto_publish, true, params[:auto_publish].present? ? params[:auto_publish].present? : false, :id => 'auto_publish'
|
= check_box_tag :auto_publish, true, @auto_publish_selected, :id => 'auto_publish'
|
||||||
= label_tag :auto_publish
|
= label_tag :auto_publish
|
||||||
|
|
||||||
%br
|
%br
|
||||||
|
@ -30,16 +30,31 @@
|
||||||
%tr
|
%tr
|
||||||
%th.lpadding16= t('activerecord.attributes.mass_build.id')
|
%th.lpadding16= t('activerecord.attributes.mass_build.id')
|
||||||
%th.lpadding16= t('activerecord.attributes.mass_build.name')
|
%th.lpadding16= t('activerecord.attributes.mass_build.name')
|
||||||
%th.lpadding16= t('activerecord.attributes.mass_build.arch_names')
|
%th.lpadding16= t("layout.mass_builds.statuses")
|
||||||
%th.lpadding16= t('activerecord.attributes.mass_build.user')
|
%th.lpadding16= t("layout.mass_builds.failed_builds_list")
|
||||||
%th.lpadding16= t('activerecord.attributes.mass_build.auto_publish')
|
%th.lpadding16= t("layout.mass_builds.extended_data")
|
||||||
%th.lpadding16= t('activerecord.attributes.mass_build.created_at')
|
|
||||||
- @mass_builds.each do |mass_build|
|
- @mass_builds.each do |mass_build|
|
||||||
%tr
|
%tr
|
||||||
%td= mass_build.id
|
%td= mass_build.id
|
||||||
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id})
|
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id})
|
||||||
%td= mass_build.arch_names
|
%td.min_width_120
|
||||||
%td= link_to mass_build.user.fullname, mass_build.user
|
- MassBuild::COUNT_STATUSES.each do |status|
|
||||||
%td= mass_build.auto_publish
|
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:status => status, :mass_build_id => mass_build.id})
|
||||||
%td= mass_build.created_at
|
= mass_build.read_attribute "#{status}_count"
|
||||||
|
.both
|
||||||
|
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platforms_path(:mass_build_id => mass_build.id), :target => "_blank"
|
||||||
|
%td
|
||||||
|
%a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
|
||||||
|
.toggle{:id => "toggle_#{ mass_build.id }"}
|
||||||
|
= t('activerecord.attributes.mass_build.arch_names') + ": "
|
||||||
|
= mass_build.arch_names
|
||||||
|
.both
|
||||||
|
= t('activerecord.attributes.mass_build.user') + ": "
|
||||||
|
= link_to mass_build.user.fullname, mass_build.user
|
||||||
|
.both
|
||||||
|
= t('activerecord.attributes.mass_build.auto_publish') + ": "
|
||||||
|
= mass_build.auto_publish
|
||||||
|
.both
|
||||||
|
= t('activerecord.attributes.mass_build.created_at') + ": "
|
||||||
|
= mass_build.created_at
|
||||||
= will_paginate @mass_builds
|
= will_paginate @mass_builds
|
||||||
|
|
|
@ -9,3 +9,8 @@
|
||||||
.hr
|
.hr
|
||||||
.leftside= t("layout.platforms.delete_warning")
|
.leftside= t("layout.platforms.delete_warning")
|
||||||
.rightside= link_to t("layout.delete"), platform_path(@platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete"), :class => 'button'
|
.rightside= link_to t("layout.delete"), platform_path(@platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete"), :class => 'button'
|
||||||
|
- if can? :clear, @platform
|
||||||
|
.hr
|
||||||
|
.leftside= t("layout.repositories.clear_warning")
|
||||||
|
.rightside= link_to t("layout.repositories.clear"), clear_platform_path(@platform), :class => 'button', :confirm => t('layout.repositories.clear_confirm'), :method => :post
|
||||||
|
.both
|
||||||
|
|
|
@ -3,6 +3,5 @@
|
||||||
%td= product_build_list.human_status
|
%td= product_build_list.human_status
|
||||||
%td= link_to nil, product_build_list.container_path
|
%td= link_to nil, product_build_list.container_path
|
||||||
%td= link_to product_build_list.product.name, platform_product_path(product_build_list.product.platform, product_build_list.product)
|
%td= link_to product_build_list.product.name, platform_product_path(product_build_list.product.platform, product_build_list.product)
|
||||||
-#%td= link_to product_build_list.user.try(:fullname), product_build_list.user
|
|
||||||
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(product_build_list.product.platform, product_build_list.product, product_build_list), :method => :delete, :confirm => t("layout.confirm") if can? :destroy, product_build_list
|
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(product_build_list.product.platform, product_build_list.product, product_build_list), :method => :delete, :confirm => t("layout.confirm") if can? :destroy, product_build_list
|
||||||
%td= l(product_build_list.notified_at, :format => :long)
|
%td= l(product_build_list.updated_at, :format => :long)
|
|
@ -6,7 +6,6 @@
|
||||||
%th.lpadding16= t("activerecord.attributes.product_build_list.status")
|
%th.lpadding16= t("activerecord.attributes.product_build_list.status")
|
||||||
%th.lpadding16= t("activerecord.attributes.product_build_list.container_path")
|
%th.lpadding16= t("activerecord.attributes.product_build_list.container_path")
|
||||||
%th.lpadding16= t("activerecord.attributes.product_build_list.product")
|
%th.lpadding16= t("activerecord.attributes.product_build_list.product")
|
||||||
-#%th.lpadding16= t("activerecord.attributes.product_build_list.user")
|
|
||||||
%th= t("layout.product_build_lists.action")
|
%th= t("layout.product_build_lists.action")
|
||||||
%th.lpadding16= t("activerecord.attributes.product_build_list.notified_at")
|
%th.lpadding16= t("activerecord.attributes.product_build_list.notified_at")
|
||||||
%tbody= render :partial => 'platforms/product_build_lists/product_build_list', :collection => @product_build_lists
|
%tbody= render :partial => 'platforms/product_build_lists/product_build_list', :collection => @product_build_lists
|
||||||
|
|
|
@ -12,4 +12,4 @@
|
||||||
- if can? :add_project, @repository
|
- if can? :add_project, @repository
|
||||||
= link_to t("layout.projects.add"), add_project_platform_repository_path(@platform, @repository), :class => 'button'
|
= link_to t("layout.projects.add"), add_project_platform_repository_path(@platform, @repository), :class => 'button'
|
||||||
|
|
||||||
= render 'proj_list'
|
= render 'proj_list'
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
%td= link_to build_list.project_version, "#"
|
%td= link_to build_list.project_version, "#"
|
||||||
%td= build_list.arch.name
|
%td= build_list.arch.name
|
||||||
%td= link_to build_list.user.try(:fullname), build_list.user
|
%td= link_to build_list.user.try(:fullname), build_list.user
|
||||||
%td= link_to image_tag('x.png', :class => 'delete-row', :id => "delete-row#{build_list_counter}"), cancel_build_list_path(build_list), :method => :put, :confirm => t('layout.confirm') if build_list.can_cancel? and can?(:cancel, build_list)
|
%td= link_to image_tag('x.png', :class => 'delete-row', :id => "delete-row#{build_list_counter}"), cancel_build_list_path(build_list), :method => :put, :confirm => t('layout.confirm') if can?(:cancel, build_list)
|
||||||
%td= build_list.updated_at
|
%td= build_list.updated_at
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
%td
|
%td
|
||||||
- c = participant_class(alone_member, project)
|
- c = participant_class(alone_member, project)
|
||||||
%span{:class => c, :title => t("layout.relations.#{c}")}
|
%span{:class => c, :title => t("layout.relations.#{c}")}
|
||||||
= t("layout.collaborators.role_names.#{project.relations.by_user_through_groups(current_user).first.role}")
|
= t("layout.collaborators.role_names.#{current_user.best_role project}")
|
||||||
%td.td5
|
%td.td5
|
||||||
- unless project.owner == current_user or !alone_member
|
- unless project.owner == current_user or !alone_member
|
||||||
= link_to remove_user_project_path(project), :method => :delete, :confirm => t("layout.confirm") do
|
= link_to remove_user_project_path(project), :method => :delete, :confirm => t("layout.confirm") do
|
||||||
|
|
|
@ -5,7 +5,7 @@ json.project do |proj|
|
||||||
proj.description project.description
|
proj.description project.description
|
||||||
proj.link project_path(project)
|
proj.link project_path(project)
|
||||||
|
|
||||||
proj.role t("layout.collaborators.role_names.#{project.relations.by_user_through_groups(current_user).first.role}").force_encoding(Encoding::UTF_8)
|
proj.role t("layout.collaborators.role_names.#{current_user.best_role project}").force_encoding(Encoding::UTF_8)
|
||||||
|
|
||||||
proj.leave_link remove_user_project_path(project) unless project.owner == current_user or !alone_member? project
|
proj.leave_link remove_user_project_path(project) unless project.owner == current_user or !alone_member? project
|
||||||
proj.rights_class participant_class(alone_member?(project), project)
|
proj.rights_class participant_class(alone_member?(project), project)
|
||||||
|
|
|
@ -97,6 +97,7 @@ en:
|
||||||
git_error: Git error
|
git_error: Git error
|
||||||
|
|
||||||
statuses:
|
statuses:
|
||||||
|
build_lists: All
|
||||||
build_error: Build error
|
build_error: Build error
|
||||||
build_published: Build has been published
|
build_published: Build has been published
|
||||||
rejected_publish: Publishing rejected
|
rejected_publish: Publishing rejected
|
||||||
|
|
|
@ -96,6 +96,7 @@ ru:
|
||||||
git_error: проблема с гит
|
git_error: проблема с гит
|
||||||
|
|
||||||
statuses:
|
statuses:
|
||||||
|
build_lists: Всего
|
||||||
build_error: ошибка сборки
|
build_error: ошибка сборки
|
||||||
build_published: опубликован
|
build_published: опубликован
|
||||||
rejected_publish: публикация отклонена
|
rejected_publish: публикация отклонена
|
||||||
|
|
|
@ -2,6 +2,9 @@ en:
|
||||||
layout:
|
layout:
|
||||||
mass_builds:
|
mass_builds:
|
||||||
repositories: Repositories
|
repositories: Repositories
|
||||||
|
extended_data: Extended data
|
||||||
|
failed_builds_list: Failed Builds List
|
||||||
|
statuses: Statuses
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
mass_build: Mass Build
|
mass_build: Mass Build
|
||||||
|
|
|
@ -2,6 +2,9 @@ ru:
|
||||||
layout:
|
layout:
|
||||||
mass_builds:
|
mass_builds:
|
||||||
repositories: Репозитории
|
repositories: Репозитории
|
||||||
|
extended_data: Параметры задания
|
||||||
|
failed_builds_list: Список ошибок сборок
|
||||||
|
statuses: Статусы
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
mass_build: Массовая Сборка
|
mass_build: Массовая Сборка
|
||||||
|
|
|
@ -10,7 +10,7 @@ en:
|
||||||
'2': 'build in progress'
|
'2': 'build in progress'
|
||||||
build_failed: Build failed
|
build_failed: Build failed
|
||||||
build_started: Build in progress
|
build_started: Build in progress
|
||||||
build_completed: Build
|
build_completed: Builded
|
||||||
|
|
||||||
ownership:
|
ownership:
|
||||||
header: Build list ownership
|
header: Build list ownership
|
||||||
|
|
|
@ -3,5 +3,5 @@ ru:
|
||||||
relations:
|
relations:
|
||||||
user_owner: Я - владелец
|
user_owner: Я - владелец
|
||||||
group_owner: Я состою в группе-владельце
|
group_owner: Я состою в группе-владельце
|
||||||
user: Я участник
|
user: Я - участник
|
||||||
group: Я состою в группе-участнике
|
group: Я состою в группе-участнике
|
||||||
|
|
|
@ -14,6 +14,9 @@ en:
|
||||||
back_to_the_list: ⇐ List of repositories
|
back_to_the_list: ⇐ List of repositories
|
||||||
confirm_delete: Are you sure you want to delete this repository?
|
confirm_delete: Are you sure you want to delete this repository?
|
||||||
current_repository_header: Current repository
|
current_repository_header: Current repository
|
||||||
|
clear: Clear
|
||||||
|
clear_confirm: Are you sure you want to clear this platform?
|
||||||
|
clear_warning: Attention! Cleared packages cannot be restored!
|
||||||
|
|
||||||
personal_repositories:
|
personal_repositories:
|
||||||
settings_header: Settings
|
settings_header: Settings
|
||||||
|
@ -32,6 +35,7 @@ en:
|
||||||
project_not_added: Project adding error. A project with such name already exists in this repository. Remove the old project first
|
project_not_added: Project adding error. A project with such name already exists in this repository. Remove the old project first
|
||||||
project_removed: Project deleted
|
project_removed: Project deleted
|
||||||
project_not_removed: Unable to delete project from repository
|
project_not_removed: Unable to delete project from repository
|
||||||
|
clear: Platform successfully cleared!
|
||||||
|
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
|
|
@ -14,6 +14,9 @@ ru:
|
||||||
back_to_the_list: ⇐ К списку репозиториев
|
back_to_the_list: ⇐ К списку репозиториев
|
||||||
confirm_delete: Вы уверены, что хотите удалить этот репозиторий?
|
confirm_delete: Вы уверены, что хотите удалить этот репозиторий?
|
||||||
current_repository_header: Текущий репозиторий
|
current_repository_header: Текущий репозиторий
|
||||||
|
clear: Очистить
|
||||||
|
clear_confirm: Уверены, что хотите очистить платформу?
|
||||||
|
clear_warning: Внимание! Очищенные пакеты не могут быть восстановлены!
|
||||||
|
|
||||||
personal_repositories:
|
personal_repositories:
|
||||||
settings_header: Настройки
|
settings_header: Настройки
|
||||||
|
@ -32,6 +35,7 @@ ru:
|
||||||
project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект
|
project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект
|
||||||
project_removed: Проект удален из репозитория
|
project_removed: Проект удален из репозитория
|
||||||
project_not_removed: Не удалось удалить проект из репозитория
|
project_not_removed: Не удалось удалить проект из репозитория
|
||||||
|
clear: Платформа успешно очищена!
|
||||||
|
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
|
|
@ -46,6 +46,7 @@ Rosa::Application.routes.draw do
|
||||||
resources :platforms do
|
resources :platforms do
|
||||||
resources :private_users, :except => [:show, :destroy, :update]
|
resources :private_users, :except => [:show, :destroy, :update]
|
||||||
member do
|
member do
|
||||||
|
post :clear
|
||||||
get :clone
|
get :clone
|
||||||
get :members
|
get :members
|
||||||
post :remove_members
|
post :remove_members
|
||||||
|
@ -56,6 +57,9 @@ Rosa::Application.routes.draw do
|
||||||
get :mass_builds
|
get :mass_builds
|
||||||
get :advisories
|
get :advisories
|
||||||
end
|
end
|
||||||
|
collection do
|
||||||
|
get :failed_builds_list
|
||||||
|
end
|
||||||
get :autocomplete_user_uname, :on => :collection
|
get :autocomplete_user_uname, :on => :collection
|
||||||
resources :repositories do
|
resources :repositories do
|
||||||
member do
|
member do
|
||||||
|
@ -72,6 +76,7 @@ Rosa::Application.routes.draw do
|
||||||
match '/private/:platform_name/*file_path' => 'privates#show'
|
match '/private/:platform_name/*file_path' => 'privates#show'
|
||||||
|
|
||||||
resources :product_build_lists, :only => [:index]
|
resources :product_build_lists, :only => [:index]
|
||||||
|
match 'product_status', :to => 'product_build_lists#status_build'
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :module => 'users' do
|
scope :module => 'users' do
|
||||||
|
@ -115,7 +120,6 @@ Rosa::Application.routes.draw do
|
||||||
match 'build_lists/pre_build', :to => "build_lists#pre_build"
|
match 'build_lists/pre_build', :to => "build_lists#pre_build"
|
||||||
match 'build_lists/circle_build', :to => "build_lists#circle_build"
|
match 'build_lists/circle_build', :to => "build_lists#circle_build"
|
||||||
match 'build_lists/new_bbdt', :to => "build_lists#new_bbdt"
|
match 'build_lists/new_bbdt', :to => "build_lists#new_bbdt"
|
||||||
match 'product_status', :to => 'product_build_lists#status_build'
|
|
||||||
|
|
||||||
resources :build_lists, :only => [:index, :show, :update] do
|
resources :build_lists, :only => [:index, :show, :update] do
|
||||||
member do
|
member do
|
||||||
|
@ -177,31 +181,33 @@ Rosa::Application.routes.draw do
|
||||||
get '/sections' => 'projects#sections', :as => :sections_project
|
get '/sections' => 'projects#sections', :as => :sections_project
|
||||||
post '/sections' => 'projects#sections'
|
post '/sections' => 'projects#sections'
|
||||||
delete '/remove_user' => 'projects#remove_user', :as => :remove_user_project
|
delete '/remove_user' => 'projects#remove_user', :as => :remove_user_project
|
||||||
# Tree
|
constraints :treeish => /[^\/]+/ do
|
||||||
get '/' => "git/trees#show", :as => :project
|
# Tree
|
||||||
get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false
|
get '/' => "git/trees#show", :as => :project
|
||||||
# Commits
|
get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false
|
||||||
get '/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false
|
# Commits
|
||||||
get '/commit/:id(.:format)' => "git/commits#show", :as => :commit
|
get '/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false
|
||||||
# Commit comments
|
get '/commit/:id(.:format)' => "git/commits#show", :as => :commit
|
||||||
post '/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments
|
# Commit comments
|
||||||
get '/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment
|
post '/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments
|
||||||
put '/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment
|
get '/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment
|
||||||
delete '/commit/:commit_id/comments/:id(.:format)' => "comments#destroy"
|
put '/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment
|
||||||
# Commit subscribes
|
delete '/commit/:commit_id/comments/:id(.:format)' => "comments#destroy"
|
||||||
post '/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit
|
# Commit subscribes
|
||||||
delete '/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit
|
post '/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit
|
||||||
# Editing files
|
delete '/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit
|
||||||
get '/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob
|
# Editing files
|
||||||
put '/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false
|
get '/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob
|
||||||
# Blobs
|
put '/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false
|
||||||
get '/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false
|
# Blobs
|
||||||
# Blame
|
get '/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false
|
||||||
get '/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false
|
# Blame
|
||||||
# Raw
|
get '/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false
|
||||||
get '/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false
|
# Raw
|
||||||
# Archive
|
get '/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false
|
||||||
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
|
# Archive
|
||||||
|
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
class AddCountersToMassBuilds < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :mass_builds, :build_lists_count, :integer, :default => 0
|
||||||
|
add_column :mass_builds, :build_published_count, :integer, :default => 0
|
||||||
|
add_column :mass_builds, :build_pending_count, :integer, :default => 0
|
||||||
|
add_column :mass_builds, :build_started_count, :integer, :default => 0
|
||||||
|
add_column :mass_builds, :build_publish_count, :integer, :default => 0
|
||||||
|
add_column :mass_builds, :build_error_count, :integer, :default => 0
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class RemoveProductNotifiedAt < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
remove_column :product_build_lists, :notified_at
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
add_column :product_build_lists, :notified_at, :datetime
|
||||||
|
end
|
||||||
|
end
|
21
db/schema.rb
21
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 => 20120609163454) do
|
ActiveRecord::Schema.define(:version => 20120628165702) 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
|
||||||
|
@ -206,11 +206,17 @@ ActiveRecord::Schema.define(:version => 20120609163454) do
|
||||||
create_table "mass_builds", :force => true do |t|
|
create_table "mass_builds", :force => true do |t|
|
||||||
t.integer "platform_id"
|
t.integer "platform_id"
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.string "arch_names"
|
t.string "arch_names"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.boolean "auto_publish", :default => false, :null => false
|
t.boolean "auto_publish", :default => false, :null => false
|
||||||
|
t.integer "build_lists_count", :default => 0
|
||||||
|
t.integer "build_published_count", :default => 0
|
||||||
|
t.integer "build_pending_count", :default => 0
|
||||||
|
t.integer "build_started_count", :default => 0
|
||||||
|
t.integer "build_publish_count", :default => 0
|
||||||
|
t.integer "build_error_count", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "platforms", :force => true do |t|
|
create_table "platforms", :force => true do |t|
|
||||||
|
@ -240,10 +246,9 @@ ActiveRecord::Schema.define(:version => 20120609163454) do
|
||||||
|
|
||||||
create_table "product_build_lists", :force => true do |t|
|
create_table "product_build_lists", :force => true do |t|
|
||||||
t.integer "product_id"
|
t.integer "product_id"
|
||||||
t.integer "status", :default => 2, :null => false
|
t.integer "status", :default => 2, :null => false
|
||||||
t.datetime "notified_at"
|
t.datetime "created_at"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "updated_at"
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id"
|
add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id"
|
||||||
|
|
|
@ -11,7 +11,7 @@ class BuildServer
|
||||||
PROJECT_NOT_FOUND = 3
|
PROJECT_NOT_FOUND = 3
|
||||||
PROJECT_VERSION_NOT_FOUND = 4
|
PROJECT_VERSION_NOT_FOUND = 4
|
||||||
PROJECT_SOURCE_ERROR = 6
|
PROJECT_SOURCE_ERROR = 6
|
||||||
|
|
||||||
DEPENDENCY_TEST_FAILED = 21
|
DEPENDENCY_TEST_FAILED = 21
|
||||||
BINARY_TEST_FAILED = 22
|
BINARY_TEST_FAILED = 22
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,13 @@ Capistrano::Configuration.instance(:must_exist).load do
|
||||||
end
|
end
|
||||||
|
|
||||||
def stop_workers
|
def stop_workers
|
||||||
#run "kill -QUIT `ps aux | grep resque | grep -v grep | awk '{ print $2 }'`"
|
# ps = 'ps aux | grep resque | grep -v grep'
|
||||||
run "kill -QUIT `ps aux | grep resque | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1 &"
|
# run "#{ps} && kill -QUIT `#{ps} | awk '{ print $2 }'` || echo 'Workers already stopped!'"
|
||||||
|
run "cd #{fetch :current_path} && #{rails_env} bundle exec rake resque:stop_workers"
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_workers
|
def start_workers
|
||||||
run "cd #{fetch :current_path} && COUNT=#{ workers_count } QUEUE=fork_import,hook,clone_build,notification #{ rails_env } BACKGROUND=yes bundle exec rake resque:workers"
|
run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=fork_import,hook,clone_build,notification #{rails_env} BACKGROUND=yes bundle exec rake resque:workers"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace :resque do
|
||||||
|
desc 'Stop all Resque workers'
|
||||||
|
task :stop_workers => :environment do
|
||||||
|
pids = []
|
||||||
|
Resque.workers.each do |worker|
|
||||||
|
pids << worker.to_s.split(/:/).second
|
||||||
|
end
|
||||||
|
system("kill -QUIT #{pids.join(' ')}") if pids.size > 0
|
||||||
|
end
|
||||||
|
end
|
|
@ -13,23 +13,14 @@
|
||||||
<!--Main menu-->
|
<!--Main menu-->
|
||||||
<menu>
|
<menu>
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<a href="#"><img src="/pics/logo-mini.png" alt="Logo"></a>
|
<a href="/"><img src="/pics/logo-mini.png" alt="Logo"></a>
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
|
||||||
<a href="/">Main</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="/projects">Projects</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="/groups">Groups</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="/build_lists">Monitoring</a>
|
<a href="/build_lists">Monitoring</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/platforms">Platforms</a>
|
<a href="/advisories">Advisories</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -41,7 +32,7 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
</div>
|
</div>
|
||||||
|
@ -51,12 +42,12 @@
|
||||||
|
|
||||||
<div class="both">
|
<div class="both">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--Page-->
|
<!--Page-->
|
||||||
<article>
|
<article>
|
||||||
<!--Single page content-->
|
<!--Single page content-->
|
||||||
<div class="all error404">
|
<div class="all error404">
|
||||||
|
|
||||||
<h1>Error <span>404</span></h1>
|
<h1>Error <span>404</span></h1>
|
||||||
<h2>Page not found</h2>
|
<h2>Page not found</h2>
|
||||||
<p class="pages">
|
<p class="pages">
|
||||||
|
@ -66,9 +57,9 @@
|
||||||
Or use the search.
|
Or use the search.
|
||||||
</p>
|
</p>
|
||||||
<div class="both"></div>
|
<div class="both"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="both">
|
<div class="both">
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -13,23 +13,14 @@
|
||||||
<!--Main menu-->
|
<!--Main menu-->
|
||||||
<menu>
|
<menu>
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<a href="#"><img src="/pics/logo-mini.png" alt="Logo"></a>
|
<a href="/"><img src="/pics/logo-mini.png" alt="Logo"></a>
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
|
||||||
<a href="/">Main</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="/projects">Projects</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="/groups">Groups</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="/build_lists">Monitoring</a>
|
<a href="/build_lists">Monitoring</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/platforms">Platforms</a>
|
<a href="/advisories">Advisories</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -41,7 +32,7 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
</div>
|
</div>
|
||||||
|
@ -51,12 +42,12 @@
|
||||||
|
|
||||||
<div class="both">
|
<div class="both">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--Page-->
|
<!--Page-->
|
||||||
<article>
|
<article>
|
||||||
<!--Single page content-->
|
<!--Single page content-->
|
||||||
<div class="all error500">
|
<div class="all error500">
|
||||||
|
|
||||||
<h1>Error <span>500</span></h1>
|
<h1>Error <span>500</span></h1>
|
||||||
<h2>Something went wrong.<br>
|
<h2>Something went wrong.<br>
|
||||||
We've been notified about this issue<br>
|
We've been notified about this issue<br>
|
||||||
|
@ -68,9 +59,9 @@
|
||||||
Or use the search.
|
Or use the search.
|
||||||
</p>
|
</p>
|
||||||
<div class="both"></div>
|
<div class="both"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="both">
|
<div class="both">
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe Projects::BuildListsController do
|
||||||
response.should redirect_to(forbidden_url)
|
response.should redirect_to(forbidden_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'create build list' do
|
shared_examples_for 'create build list' do
|
||||||
before {test_git_commit(@project)}
|
before {test_git_commit(@project)}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ describe Projects::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.actors.create :role => 'reader', :actor_id => @owner_user.id, :actor_type => 'User'
|
@owner_group.actors.create :role => 'admin', :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.actors.create :role => 'reader', :actor_id => @member_user.id, :actor_type => 'User'
|
@member_group.actors.create :role => 'reader', :actor_id => @member_user.id, :actor_type => 'User'
|
||||||
|
@ -317,27 +317,37 @@ describe Projects::BuildListsController do
|
||||||
|
|
||||||
context 'callbacks' do
|
context 'callbacks' do
|
||||||
let(:build_list) { FactoryGirl.create(:build_list_core) }
|
let(:build_list) { FactoryGirl.create(:build_list_core) }
|
||||||
|
let(:build_list_package) { FactoryGirl.create(:build_list_package, :build_list_id => build_list.id, :platform_id => build_list.project.repositories.first.platform_id, :project_id => build_list.project_id, :version => "4.7.5.3", :release => 1) }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
mock(controller).authenticate_build_service! {true}
|
mock(controller).authenticate_build_service! {true}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'publish_build' do
|
describe 'publish_build' do
|
||||||
before { test_git_commit(build_list.project); build_list.update_attribute :commit_hash, build_list.project.git_repository.commits('master').last.id }
|
before {
|
||||||
|
test_git_commit(build_list.project)
|
||||||
|
build_list.update_attribute :commit_hash, build_list.project.git_repository.commits('master').last.id
|
||||||
|
build_list.update_attribute(:status, BuildList::BUILD_PUBLISH)
|
||||||
|
build_list_package
|
||||||
|
}
|
||||||
|
|
||||||
def do_get(status)
|
def do_get(status)
|
||||||
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
||||||
build_list.reload
|
build_list.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { do_get(BuildServer::SUCCESS); response.should be_ok }
|
it(:passes) {
|
||||||
|
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||||
|
do_get(BuildServer::SUCCESS)
|
||||||
|
response.should be_ok
|
||||||
|
}
|
||||||
it 'should create correct git tag for correct commit' do
|
it 'should create correct git tag for correct commit' do
|
||||||
do_get(BuildServer::SUCCESS)
|
do_get(BuildServer::SUCCESS)
|
||||||
build_list.project.git_repository.tags.last.name.should == build_list.package_version
|
build_list.project.git_repository.tags.last.name.should == build_list.package_version
|
||||||
build_list.project.git_repository.commits(build_list.package_version).last.id.should == build_list.commit_hash
|
build_list.project.git_repository.commits(build_list.package_version).last.id.should == build_list.commit_hash
|
||||||
end
|
end
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
it(:passes) { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to('4.7.5.3-1') }
|
it(:passes) { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to("#{ build_list_package.platform.name }-4.7.5.3-1") }
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildList::FAILED_PUBLISH) }
|
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildList::FAILED_PUBLISH) }
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should_not change(build_list, :package_version) }
|
it { lambda{ do_get(BuildServer::ERROR) }.should_not change(build_list, :package_version) }
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :updated_at) }
|
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :updated_at) }
|
||||||
|
@ -390,6 +400,10 @@ describe Projects::BuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'pre_build' do
|
describe 'pre_build' do
|
||||||
|
before do
|
||||||
|
build_list.update_attribute :status, BuildList::BUILD_PENDING
|
||||||
|
end
|
||||||
|
|
||||||
def do_get
|
def do_get
|
||||||
get :pre_build, :id => build_list.bs_id
|
get :pre_build, :id => build_list.bs_id
|
||||||
build_list.reload
|
build_list.reload
|
||||||
|
@ -413,15 +427,32 @@ describe Projects::BuildListsController do
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :updated_at) }
|
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :updated_at) }
|
||||||
|
|
||||||
context 'with auto_publish' do
|
context 'with auto_publish' do
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISH) }
|
it(:passes) {
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildServer::ERROR) }
|
build_list.update_attribute(:started_at, (Time.now - 1.day))
|
||||||
|
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||||
|
build_list.reload
|
||||||
|
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISH)
|
||||||
|
}
|
||||||
|
it(:passes) {
|
||||||
|
build_list.update_attribute(:started_at, (Time.now - 1.day))
|
||||||
|
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||||
|
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without auto_publish' do
|
context 'without auto_publish' do
|
||||||
before { build_list.update_attribute(:auto_publish, false) }
|
before { build_list.update_attribute(:auto_publish, false) }
|
||||||
|
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildServer::SUCCESS) }
|
it(:passes) {
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildServer::ERROR) }
|
build_list.update_attribute(:started_at, (Time.now - 1.day))
|
||||||
|
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||||
|
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildServer::SUCCESS)
|
||||||
|
}
|
||||||
|
it(:passes) {
|
||||||
|
build_list.update_attribute(:started_at, (Time.now - 1.day))
|
||||||
|
build_list.update_attribute(:status, BuildServer::BUILD_STARTED)
|
||||||
|
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,8 @@ describe Projects::CommentsController do
|
||||||
context 'for project owner user' do
|
context 'for project owner user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
|
@project.relations.destroy_all
|
||||||
|
@project.relations.create :actor_id => @project.owner.id, :actor_type => @project.owner.class.to_s, :role => 'admin'
|
||||||
@create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname
|
@create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ describe Projects::ProjectsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'projects user with reader rights'
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
it_should_behave_like 'user without update rights'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for writer user' do
|
context 'for writer user' do
|
||||||
|
@ -136,20 +137,115 @@ describe Projects::ProjectsController do
|
||||||
response.should redirect_to(forbidden_path)
|
response.should redirect_to(forbidden_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be able to edit project' do
|
it_should_behave_like 'user without update rights'
|
||||||
description = @project.description
|
end
|
||||||
put :update, :project=>{:description =>"hack"}, :owner_name => @project.owner.uname, :project_name => @project.name
|
|
||||||
response.should redirect_to(forbidden_path)
|
context 'for group' do
|
||||||
Project.find(@project.id).description.should == description
|
before(:each) do
|
||||||
|
@group = FactoryGirl.create(:group)
|
||||||
|
@group_user = FactoryGirl.create(:user)
|
||||||
|
@project.relations.destroy_all
|
||||||
|
set_session_for(@group_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be able to edit project sections' do
|
context 'owner of the project' do
|
||||||
has_wiki, has_issues = @project.has_wiki, @project.has_issues
|
before(:each) do
|
||||||
post :sections, :project =>{:has_wiki => !has_wiki, :has_issues => !has_issues}, :owner_name => @project.owner.uname, :project_name => @project.name
|
@project.update_attribute :owner, @group
|
||||||
response.should redirect_to(forbidden_path)
|
@project.relations.create :actor_id => @project.owner.id, :actor_type => @project.owner.class.to_s, :role => 'admin'
|
||||||
project = Project.find(@project.id)
|
end
|
||||||
project.has_wiki.should == has_wiki
|
|
||||||
project.has_issues.should == has_issues
|
context 'reader user' do
|
||||||
|
before(:each) do
|
||||||
|
@group.actors.create(:actor_id => @group_user.id, :actor_type => 'User', :role => 'reader')
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
it_should_behave_like 'user without update rights'
|
||||||
|
|
||||||
|
it 'should has reader role to group project' do
|
||||||
|
@group_user.best_role(@project).should eql('reader') # Need this?
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'user should has best role' do
|
||||||
|
before(:each) do
|
||||||
|
@project.relations.create :actor_id => @group_user.id, :actor_type => @group_user.class.to_s, :role => 'admin'
|
||||||
|
end
|
||||||
|
it_should_behave_like 'projects user with admin rights'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'admin user' do
|
||||||
|
before(:each) do
|
||||||
|
@group.actors.create(:actor_id => @group_user.id, :actor_type => 'User', :role => 'admin')
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like 'projects user with admin rights'
|
||||||
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'member of the project' do
|
||||||
|
context 'with admin rights' do
|
||||||
|
before(:each) do
|
||||||
|
@project.relations.create :actor_id => @group.id, :actor_type => @group.class.to_s, :role => 'admin'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'reader user' do
|
||||||
|
before(:each) do
|
||||||
|
@group.actors.create(:actor_id => @group_user.id, :actor_type => 'User', :role => 'reader')
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
it_should_behave_like 'projects user with admin rights'
|
||||||
|
|
||||||
|
context 'user should has best role' do
|
||||||
|
before(:each) do
|
||||||
|
@project.relations.create :actor_id => @group_user.id, :actor_type => @group_user.class.to_s, :role => 'reader'
|
||||||
|
end
|
||||||
|
it_should_behave_like 'projects user with admin rights'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'admin user' do
|
||||||
|
before(:each) do
|
||||||
|
@group.actors.create(:actor_id => @group_user.id, :actor_type => 'User', :role => 'admin')
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like 'projects user with admin rights'
|
||||||
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with reader rights' do
|
||||||
|
before(:each) do
|
||||||
|
@project.relations.create :actor_id => @group.id, :actor_type => @group.class.to_s, :role => 'reader'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'reader user' do
|
||||||
|
before(:each) do
|
||||||
|
@group.actors.create(:actor_id => @group_user.id, :actor_type => 'User', :role => 'reader')
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
it_should_behave_like 'user without update rights'
|
||||||
|
|
||||||
|
context 'user should has best role' do
|
||||||
|
before(:each) do
|
||||||
|
@project.relations.create :actor_id => @group_user.id, :actor_type => @group_user.class.to_s, :role => 'admin'
|
||||||
|
end
|
||||||
|
it_should_behave_like 'projects user with admin rights'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'admin user' do
|
||||||
|
before(:each) do
|
||||||
|
@group.actors.create(:actor_id => @group_user.id, :actor_type => 'User', :role => 'admin')
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like 'projects user with reader rights'
|
||||||
|
it_should_behave_like 'user without update rights'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,4 +16,15 @@ FactoryGirl.define do
|
||||||
factory :build_list_core, :parent => :build_list do
|
factory :build_list_core, :parent => :build_list do
|
||||||
bs_id { FactoryGirl.generate(:integer) }
|
bs_id { FactoryGirl.generate(:integer) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :build_list_package, :class => BuildList::Package do
|
||||||
|
association :build_list
|
||||||
|
association :project
|
||||||
|
association :platform
|
||||||
|
fullname "test_package"
|
||||||
|
name "test_package"
|
||||||
|
version "3.1.12"
|
||||||
|
release 6
|
||||||
|
package_type "source"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -208,6 +208,7 @@ describe CanCan do
|
||||||
context 'with owner rights' do
|
context 'with owner rights' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
|
@project.relations.create!(:actor_id => @user.id, :actor_type => 'User', :role => 'admin')
|
||||||
@issue.project.reload
|
@issue.project.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,14 @@ describe ProductBuildList do
|
||||||
it { should_not allow_mass_assignment_of(:product_id) }
|
it { should_not allow_mass_assignment_of(:product_id) }
|
||||||
|
|
||||||
it { should allow_mass_assignment_of(:status) }
|
it { should allow_mass_assignment_of(:status) }
|
||||||
it { should allow_mass_assignment_of(:notified_at) }
|
|
||||||
it { should allow_mass_assignment_of(:base_url) }
|
it { should allow_mass_assignment_of(:base_url) }
|
||||||
|
|
||||||
|
# see app/ability.rb
|
||||||
|
# can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
|
||||||
|
it 'should generate correct sql to get product build lists' do
|
||||||
|
stub_symlink_methods
|
||||||
|
user = FactoryGirl.create(:user)
|
||||||
|
ability = Ability.new user
|
||||||
|
ProductBuildList.accessible_by(ability).count.should == 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,93 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
#describe User do
|
describe User do
|
||||||
# pending "add some examples to (or delete) #{__FILE__}"
|
before { stub_symlink_methods }
|
||||||
#end
|
before(:each) do
|
||||||
|
@project = FactoryGirl.create(:project)
|
||||||
|
@group = FactoryGirl.create(:group)
|
||||||
|
@user = FactoryGirl.create(:user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'for own project' do
|
||||||
|
it 'should have admin role' do
|
||||||
|
@project.owner.best_role(@project).should == 'admin'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'other user' do
|
||||||
|
it 'should have not right to project' do
|
||||||
|
other_user = FactoryGirl.create(:user)
|
||||||
|
other_user.best_role(@project).should == nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
%w(reader writer admin).each do |group_role|
|
||||||
|
context "for group with #{group_role} role in project" do
|
||||||
|
before(:each) do
|
||||||
|
@project.relations.create :actor_id => @group.id, :actor_type => @group.class.to_s, :role => group_role
|
||||||
|
end
|
||||||
|
|
||||||
|
%w(reader writer admin).each do |role|
|
||||||
|
context "for user with #{role} role in group" do
|
||||||
|
before(:each) do
|
||||||
|
@group.actors.create(:actor_id => @user.id, :actor_type => 'User', :role => role)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should have #{group_role} role to project" do
|
||||||
|
@user.best_role(@project).should == group_role
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'for group project' do
|
||||||
|
before(:each) do
|
||||||
|
@project.relations.destroy_all
|
||||||
|
@project.update_attribute :owner, @group
|
||||||
|
@project.relations.create :actor_id => @project.owner.id, :actor_type => @project.owner.class.to_s, :role => 'admin'
|
||||||
|
end
|
||||||
|
|
||||||
|
%w(reader writer admin).each do |role|
|
||||||
|
context "for user with #{role} role in group" do
|
||||||
|
before(:each) do
|
||||||
|
@group.actors.create(:actor_id => @user.id, :actor_type => 'User', :role => role)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should have #{role} role to project" do
|
||||||
|
@user.best_role(@project).should == role
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
%w(reader writer admin).each do |role|
|
||||||
|
context "for user with #{role} role in project" do
|
||||||
|
before(:each) do
|
||||||
|
@project.relations.create(:actor_id => @user.id, :actor_type => 'User', :role => role)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should have #{role} role to project" do
|
||||||
|
@user.best_role(@project).should == role
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "for user with reader role in group and writer role in project" do
|
||||||
|
it "should have writer best role to project" do
|
||||||
|
@group.actors.create(:actor_id => @user.id, :actor_type => 'User', :role => 'reader')
|
||||||
|
@project.relations.create(:actor_id => @user.id, :actor_type => 'User', :role => 'writer')
|
||||||
|
@user.best_role(@project).should == 'writer'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "for user with admin role in group and reader role in project" do
|
||||||
|
it "should have admin best role to project" do
|
||||||
|
@group.actors.create(:actor_id => @user.id, :actor_type => 'User', :role => 'admin')
|
||||||
|
@project.relations.create(:actor_id => @user.id, :actor_type => 'User', :role => 'reader')
|
||||||
|
@user.best_role(@project).should == 'admin'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
|
@ -36,8 +36,9 @@ describe Projects::Git::TreesController do
|
||||||
|
|
||||||
it "routes to #show" do
|
it "routes to #show" do
|
||||||
get("/import/glib2.0-mib").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib')
|
get("/import/glib2.0-mib").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib')
|
||||||
get("/import/glib2.0-mib/tree/branch").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch')
|
get("/import/glib2.0-mib/tree/lib2safe-0.03").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'lib2safe-0.03')
|
||||||
get("/import/glib2.0-mib/tree/branch/some/path.to").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch', :path => 'some/path.to')
|
get("/import/glib2.0-mib/tree/branch-with.dot/folder_with.dot/path-with.dot").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch-with.dot', :path => 'folder_with.dot/path-with.dot')
|
||||||
|
# get("/import/glib2.0-mib/tree/ветка-с.точкой/папка_с.точкой/путь-с.точкой").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'ветка-с.точкой', :path => 'папка_с.точкой/путь-с.точкой')
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO write more specs also with slash in branch name!
|
# TODO write more specs also with slash in branch name!
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
shared_examples_for 'projects user with reader rights' do
|
shared_examples_for 'projects user with reader rights' do
|
||||||
it_should_behave_like 'user with rights to view projects'
|
include_examples 'user with rights to view projects' # nested shared_examples_for dont work
|
||||||
|
|
||||||
it 'should be able to fork project' do
|
it 'should be able to fork project' do
|
||||||
post :fork, :owner_name => @project.owner.uname, :project_name => @project.name
|
post :fork, :owner_name => @project.owner.uname, :project_name => @project.name
|
||||||
response.should redirect_to(project_path(Project.last))
|
response.should redirect_to(project_path(Project.last))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'projects user with admin rights' do
|
shared_examples_for 'projects user with admin rights' do
|
||||||
|
@ -21,3 +22,21 @@ shared_examples_for 'user with rights to view projects' do
|
||||||
response.should render_template(:index)
|
response.should render_template(:index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'user without update rights' do
|
||||||
|
it 'should not be able to edit project' do
|
||||||
|
description = @project.description
|
||||||
|
put :update, :project=>{:description =>"hack"}, :owner_name => @project.owner.uname, :project_name => @project.name
|
||||||
|
Project.find(@project.id).description.should == description
|
||||||
|
response.should redirect_to(forbidden_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not be able to edit project sections' do
|
||||||
|
has_wiki, has_issues = @project.has_wiki, @project.has_issues
|
||||||
|
post :sections, :project =>{:has_wiki => !has_wiki, :has_issues => !has_issues}, :owner_name => @project.owner.uname, :project_name => @project.name
|
||||||
|
project = Project.find(@project.id)
|
||||||
|
project.has_wiki.should == has_wiki
|
||||||
|
project.has_issues.should == has_issues
|
||||||
|
response.should redirect_to(forbidden_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue