Merge master into 429-uname_format_error_explain
This commit is contained in:
commit
5ad43c684e
|
@ -112,6 +112,8 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
@build_list.container_path = params[:container_path]
|
||||
@build_list.save
|
||||
|
||||
@build_list.set_packages(ActiveSupport::JSON.decode(params[:pkg_info])) if params[:status].to_i == BuildServer::SUCCESS and params[:pkg_info].present?
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
||||
|
|
|
@ -64,7 +64,8 @@ class Ability
|
|||
can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
|
||||
can [:read, :related], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can(:read, BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project}
|
||||
can(:create, BuildList) {|build_list| build_list.project.is_rpm && can?(:write, build_list.project)}
|
||||
can([:create, :update], BuildList) {|build_list| build_list.project.is_rpm && can?(:write, build_list.project)}
|
||||
|
||||
can(:publish, BuildList) do |build_list|
|
||||
build_list.can_publish? and build_list.save_to_platform.released ? local_admin?(build_list.save_to_platform) : can?(:write, build_list.project)
|
||||
end
|
||||
|
|
|
@ -5,16 +5,15 @@ class BuildList < ActiveRecord::Base
|
|||
belongs_to :save_to_platform, :class_name => 'Platform'
|
||||
belongs_to :build_for_platform, :class_name => 'Platform'
|
||||
belongs_to :user
|
||||
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
|
||||
|
||||
belongs_to :advisory
|
||||
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
|
||||
has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy
|
||||
|
||||
validates :project_id, :project_version, :arch, :include_repos, :presence => true
|
||||
validates_numericality_of :priority, :greater_than_or_equal_to => 0
|
||||
|
||||
UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage]
|
||||
RELEASE_UPDATE_TYPES = %w[security bugfix]
|
||||
|
||||
validates :project_id, :project_version, :arch, :include_repos, :presence => true
|
||||
validates_numericality_of :priority, :greater_than_or_equal_to => 0
|
||||
validates :update_type, :inclusion => UPDATE_TYPES,
|
||||
:unless => Proc.new { |b| b.save_to_platform.released }
|
||||
validates :update_type, :inclusion => RELEASE_UPDATE_TYPES,
|
||||
|
@ -71,7 +70,6 @@ class BuildList < ActiveRecord::Base
|
|||
}
|
||||
|
||||
scope :recent, order("#{table_name}.updated_at DESC")
|
||||
|
||||
scope :for_status, lambda {|status| where(:status => status) }
|
||||
scope :for_user, lambda { |user| where(:user_id => user.id) }
|
||||
scope :scoped_to_arch, lambda {|arch| where(:arch_id => arch) }
|
||||
|
@ -90,7 +88,6 @@ class BuildList < ActiveRecord::Base
|
|||
s
|
||||
}
|
||||
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
|
||||
|
||||
scope :outdated, where('updated_at < ? AND status <> ?', Time.now - LIVE_TIME, BUILD_PUBLISHED)
|
||||
|
||||
serialize :additional_repos
|
||||
|
@ -117,6 +114,13 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def set_packages(pkg_hash)
|
||||
build_package(pkg_hash['srpm'], 'source') {|p| p.save!}
|
||||
pkg_hash['rpm'].each do |rpm_hash|
|
||||
build_package(rpm_hash, 'binary') {|p| p.save!}
|
||||
end
|
||||
end
|
||||
|
||||
def publish
|
||||
return false unless can_publish?
|
||||
has_published = BuildServer.publish_container bs_id
|
||||
|
@ -170,18 +174,26 @@ class BuildList < ActiveRecord::Base
|
|||
#[WAITING_FOR_RESPONSE, BuildServer::BUILD_PENDING, BuildServer::BUILD_STARTED].include?(status)
|
||||
end
|
||||
|
||||
private
|
||||
def set_default_status
|
||||
self.status = WAITING_FOR_RESPONSE unless self.status.present?
|
||||
return true
|
||||
end
|
||||
protected
|
||||
|
||||
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
|
||||
#handle_asynchronously :place_build
|
||||
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 build_package(pkg_hash, package_type)
|
||||
packages.create(pkg_hash) do |p|
|
||||
p.project = Project.joins(:repositories => :platform).where('platforms.id = ?', save_to_platform.id).find_by_name!(pkg_hash['name'])
|
||||
p.platform = save_to_platform
|
||||
p.package_type = package_type
|
||||
yield p
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
class BuildList::Package < ActiveRecord::Base
|
||||
PACKAGE_TYPES = %w(source binary)
|
||||
|
||||
belongs_to :build_list
|
||||
belongs_to :project
|
||||
belongs_to :platform
|
||||
|
||||
attr_accessible :fullname, :name, :release, :version
|
||||
|
||||
validates :build_list_id, :project_id, :platform_id, :fullname, :package_type, :name, :release, :version, :presence => true
|
||||
validates :package_type, :inclusion => PACKAGE_TYPES
|
||||
end
|
|
@ -15,6 +15,8 @@ class Platform < ActiveRecord::Base
|
|||
|
||||
has_and_belongs_to_many :advisories
|
||||
|
||||
has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy
|
||||
|
||||
validates :description, :presence => true
|
||||
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
|
||||
validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ }
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
class Project < ActiveRecord::Base
|
||||
VISIBILITIES = ['open', 'hidden']
|
||||
MAX_OWN_PROJECTS = 32000
|
||||
NAME_REGEXP = /[a-zA-Z0-9_\-\+\.]+/
|
||||
|
||||
belongs_to :owner, :polymorphic => true, :counter_cache => :own_projects_count
|
||||
|
||||
|
@ -17,9 +18,10 @@ class Project < ActiveRecord::Base
|
|||
has_many :collaborators, :through => :relations, :source => :actor, :source_type => 'User'
|
||||
has_many :groups, :through => :relations, :source => :actor, :source_type => 'Group'
|
||||
|
||||
has_many :advisories
|
||||
has_many :advisories # should be without :dependent => :destroy
|
||||
has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy
|
||||
|
||||
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/, :message => I18n.t("activerecord.errors.project.uname")}
|
||||
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^#{NAME_REGEXP}$/, :message => I18n.t("activerecord.errors.project.uname")}
|
||||
validates :owner, :presence => true
|
||||
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
.rightlist
|
||||
= link_to @build_list.user.try(:fullname), @build_list.user
|
||||
.both
|
||||
.leftlist= t("activerecord.attributes.build_list.bpl")
|
||||
.leftlist= t("activerecord.attributes.build_list.build_for_platform")
|
||||
.rightlist
|
||||
= link_to @build_list.build_for_platform.name, @build_list.build_for_platform
|
||||
.both
|
||||
.leftlist= t("activerecord.attributes.build_list.pl")
|
||||
.leftlist= t("activerecord.attributes.build_list.save_to_platform")
|
||||
.rightlist
|
||||
= link_to @build_list.save_to_platform.name, @build_list.save_to_platform
|
||||
.both
|
||||
|
@ -102,6 +102,25 @@
|
|||
%td= item.human_status
|
||||
.both
|
||||
|
||||
- if @build_list.packages.present?
|
||||
.hr
|
||||
%h3= t("layout.build_lists.packages_header")
|
||||
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
|
||||
%thead
|
||||
%tr
|
||||
%th= t("activerecord.attributes.build_list/package.fullname")
|
||||
%th= t("activerecord.attributes.build_list/package.name")
|
||||
%th= t("activerecord.attributes.build_list/package.version")
|
||||
%th= t("activerecord.attributes.build_list/package.release")
|
||||
%tbody
|
||||
- @build_list.packages.each do |package|
|
||||
%tr
|
||||
%td= package.fullname
|
||||
%td= package.name
|
||||
%td= package.version
|
||||
%td= package.release
|
||||
.both
|
||||
|
||||
:javascript
|
||||
$('article .all').addClass('bigpadding');
|
||||
|
||||
|
|
|
@ -36,6 +36,12 @@ en:
|
|||
version: Version
|
||||
build_list: Build list
|
||||
|
||||
build_list/package:
|
||||
name: Name
|
||||
fullname: Fullname
|
||||
release: Release
|
||||
version: Version
|
||||
|
||||
layout:
|
||||
build_lists:
|
||||
filter_header: Filter
|
||||
|
@ -48,6 +54,7 @@ en:
|
|||
project_name_search: Search by project name
|
||||
bs_id_not_set: Id has not been configured yet
|
||||
items_header: Build items
|
||||
packages_header: Container data
|
||||
no_items_data: No data
|
||||
show: Show
|
||||
cancel_success: 'Build canceled'
|
||||
|
|
|
@ -35,6 +35,12 @@ ru:
|
|||
version: Версия
|
||||
build_list: Сборочный лист
|
||||
|
||||
build_list/package:
|
||||
name: Название
|
||||
fullname: Полное имя
|
||||
release: Релиз
|
||||
version: Версия
|
||||
|
||||
layout:
|
||||
build_lists:
|
||||
filter_header: Фильтр
|
||||
|
@ -47,6 +53,7 @@ ru:
|
|||
project_name_search: Поиск по названию проекта
|
||||
bs_id_not_set: Id еще не присвоен
|
||||
items_header: Элементы сборки
|
||||
packages_header: Данные о контейнере
|
||||
no_items_data: Данных нет
|
||||
show: Просмотр
|
||||
cancel_success: 'Сборка отменена.'
|
||||
|
|
|
@ -3,23 +3,26 @@ en:
|
|||
'Editing'
|
||||
at: at
|
||||
users:
|
||||
profile:
|
||||
title: 'Your Profile'
|
||||
build_lists:
|
||||
index:
|
||||
title: 'Projects Monitoring'
|
||||
product_build_lists:
|
||||
index:
|
||||
title: 'Products Monitoring'
|
||||
git:
|
||||
commits:
|
||||
settings:
|
||||
profile:
|
||||
title: 'Your Profile'
|
||||
projects:
|
||||
build_lists:
|
||||
index:
|
||||
title: 'Commit History'
|
||||
issues:
|
||||
index:
|
||||
title: 'Tracker'
|
||||
wiki:
|
||||
compare:
|
||||
title: 'Compare Revisions'
|
||||
searching:
|
||||
title: 'Search in Wiki'
|
||||
title: 'Projects Monitoring'
|
||||
git:
|
||||
commits:
|
||||
index:
|
||||
title: 'Commit History'
|
||||
issues:
|
||||
index:
|
||||
title: 'Tracker'
|
||||
wiki:
|
||||
compare:
|
||||
title: 'Compare Revisions'
|
||||
searching:
|
||||
title: 'Search in Wiki'
|
||||
platforms:
|
||||
product_build_lists:
|
||||
index:
|
||||
title: 'Products Monitoring'
|
|
@ -3,23 +3,26 @@ ru:
|
|||
'Редактирование'
|
||||
at: at
|
||||
users:
|
||||
profile:
|
||||
title: 'Ваш профиль'
|
||||
build_lists:
|
||||
index:
|
||||
title: 'Мониторинг проектов'
|
||||
product_build_lists:
|
||||
index:
|
||||
title: 'Мониторинг продуктов'
|
||||
git:
|
||||
commits:
|
||||
settings:
|
||||
profile:
|
||||
title: 'Ваш профиль'
|
||||
projects:
|
||||
build_lists:
|
||||
index:
|
||||
title: 'История коммитов'
|
||||
issues:
|
||||
index:
|
||||
title: 'Трекер'
|
||||
wiki:
|
||||
compare:
|
||||
title: 'Сравнение версий'
|
||||
searching:
|
||||
title: 'Поиск в вики'
|
||||
title: 'Мониторинг проектов'
|
||||
git:
|
||||
commits:
|
||||
index:
|
||||
title: 'История коммитов'
|
||||
issues:
|
||||
index:
|
||||
title: 'Трекер'
|
||||
wiki:
|
||||
compare:
|
||||
title: 'Сравнение версий'
|
||||
searching:
|
||||
title: 'Поиск в вики'
|
||||
platforms:
|
||||
product_build_lists:
|
||||
index:
|
||||
title: 'Мониторинг продуктов'
|
|
@ -118,7 +118,7 @@ Rosa::Application.routes.draw do
|
|||
|
||||
resources :projects, :only => [:index, :new, :create]
|
||||
|
||||
scope ':owner_name/:project_name' do # project
|
||||
scope ':owner_name/:project_name', :constraints => {:project_name => Project::NAME_REGEXP} do # project
|
||||
scope :as => 'project' do
|
||||
resources :wiki do
|
||||
collection do
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class CreateBuildListPackages < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :build_list_packages do |t|
|
||||
t.references :build_list
|
||||
t.references :project
|
||||
t.references :platform
|
||||
t.string :fullname
|
||||
t.string :name
|
||||
t.string :version
|
||||
t.string :release
|
||||
t.string :package_type
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :build_list_packages, :build_list_id
|
||||
add_index :build_list_packages, :project_id
|
||||
add_index :build_list_packages, :platform_id
|
||||
end
|
||||
end
|
19
db/schema.rb
19
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120505101650) do
|
||||
ActiveRecord::Schema.define(:version => 20120512102707) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -75,6 +75,23 @@ ActiveRecord::Schema.define(:version => 20120505101650) do
|
|||
|
||||
add_index "build_list_items", ["build_list_id"], :name => "index_build_list_items_on_build_list_id"
|
||||
|
||||
create_table "build_list_packages", :force => true do |t|
|
||||
t.integer "build_list_id"
|
||||
t.integer "project_id"
|
||||
t.integer "platform_id"
|
||||
t.string "fullname"
|
||||
t.string "name"
|
||||
t.string "version"
|
||||
t.string "release"
|
||||
t.string "package_type"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "build_list_packages", ["build_list_id"], :name => "index_build_list_packages_on_build_list_id"
|
||||
add_index "build_list_packages", ["platform_id"], :name => "index_build_list_packages_on_platform_id"
|
||||
add_index "build_list_packages", ["project_id"], :name => "index_build_list_packages_on_project_id"
|
||||
|
||||
create_table "build_lists", :force => true do |t|
|
||||
t.integer "bs_id"
|
||||
t.string "container_path"
|
||||
|
|
|
@ -344,10 +344,28 @@ describe Projects::BuildListsController do
|
|||
end
|
||||
|
||||
describe 'status_build' do
|
||||
before { @item = build_list.items.create(:name => build_list.project.name, :version => build_list.project_version, :level => 0) }
|
||||
before do
|
||||
@item = build_list.items.create(:name => build_list.project.name, :version => build_list.project_version, :level => 0)
|
||||
repo = build_list.save_to_platform.repositories.first
|
||||
repo.projects << build_list.project
|
||||
@project2 = FactoryGirl.create(:project)
|
||||
repo.projects << @project2
|
||||
end
|
||||
|
||||
def do_get
|
||||
get :status_build, :id => build_list.bs_id, :package_name => build_list.project.name, :status => BuildServer::SUCCESS, :container_path => '/path/to'
|
||||
get :status_build, :id => build_list.bs_id, :package_name => build_list.project.name, :status => BuildServer::SUCCESS, :container_path => '/path/to',
|
||||
:pkg_info => ActiveSupport::JSON.encode({'srpm' => {'fullname' => 'srpm_filename.srpm',
|
||||
'name' => build_list.project.name,
|
||||
'version' => 'version1',
|
||||
'release' => 'release1'},
|
||||
'rpm' => [{'fullname' => 'filename1.rpm',
|
||||
'name' => build_list.project.name,
|
||||
'version' => 'version2',
|
||||
'release' => 'release2'},
|
||||
{'fullname' => 'filename2.rpm',
|
||||
'name' => @project2.name,
|
||||
'version' => 'version2',
|
||||
'release' => 'release2'}]})
|
||||
build_list.reload
|
||||
@item.reload
|
||||
end
|
||||
|
@ -356,6 +374,19 @@ describe Projects::BuildListsController do
|
|||
it { lambda{ do_get }.should change(@item, :status) }
|
||||
it { lambda{ do_get }.should change(build_list, :container_path) }
|
||||
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
||||
it('should create packages for build list') { lambda{ do_get }.should change(build_list.packages, :count).to(3) }
|
||||
it 'should create correct packages for build list' do
|
||||
do_get
|
||||
package = build_list.packages.order('created_at ASC').first
|
||||
package.fullname.should == 'srpm_filename.srpm'
|
||||
package.name.should == build_list.project.name
|
||||
package.version.should == 'version1'
|
||||
package.release.should == 'release1'
|
||||
package.package_type == 'source'
|
||||
package.build_list.should == build_list
|
||||
package.platform.should == build_list.save_to_platform
|
||||
package.project.should == build_list.project
|
||||
end
|
||||
end
|
||||
|
||||
describe 'pre_build' do
|
||||
|
|
|
@ -12,20 +12,20 @@ describe Projects::Git::TreesController do
|
|||
|
||||
@project = FactoryGirl.create(:project)
|
||||
@another_user = FactoryGirl.create(:user)
|
||||
@params = {:owner_name => @project.owner.uname, :project_name => @project.name, :format => 'tar'}
|
||||
@params = {:owner_name => @project.owner.uname, :project_name => @project.name}
|
||||
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
|
||||
get :archive, @params.merge(:format => 'tar')
|
||||
response.should be_success
|
||||
end
|
||||
else
|
||||
it 'should not be able to perform archive action without anonymous acccess' do
|
||||
fill_project
|
||||
get :archive, @params
|
||||
get :archive, @params.merge(:format => 'tar')
|
||||
response.code.should == '401'
|
||||
end
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ describe Projects::Git::TreesController 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)
|
||||
expect { get :archive, @params.merge(:format => 'tar') }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'should not be able to injection code with format' do
|
||||
|
@ -56,7 +56,7 @@ describe Projects::Git::TreesController do
|
|||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
fill_project
|
||||
get :archive, @params
|
||||
get :archive, @params.merge(:format => 'tar')
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
require "spec_helper"
|
||||
|
||||
describe Projects::ProjectsController do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
get("/projects").should route_to("projects/projects#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
get("/projects/new").should route_to("projects/projects#new")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
get("/import/glib2.0-mib/edit").should route_to("projects/projects#edit", :owner_name => 'import', :project_name => 'glib2.0-mib')
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
post("/projects").should route_to("projects/projects#create")
|
||||
end
|
||||
|
||||
it "routes to #update" do
|
||||
put("/import/glib2.0-mib").should route_to("projects/projects#update", :owner_name => 'import', :project_name => 'glib2.0-mib')
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
delete("/import/glib2.0-mib").should route_to("projects/projects#destroy", :owner_name => 'import', :project_name => 'glib2.0-mib')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe Projects::Git::TreesController do
|
||||
describe "routing" 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/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/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')
|
||||
end
|
||||
|
||||
# TODO write more specs also with slash in branch name!
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue