From 944626d59ae833747df0f3618a82a0ff71920a9f Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 14 May 2012 16:51:08 +0600 Subject: [PATCH 1/7] [refs #455] add ability for build lists --- app/models/ability.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index d1fe8928d..0a11e7b7f 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 From f3358638815d614b1fe4ea9c5c0924758cc6b9a3 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Mon, 14 May 2012 16:24:01 +0300 Subject: [PATCH 2/7] Fix dot in project name routes. Refactor and write basic route specs. Refs #454 --- app/models/project.rb | 3 +- config/routes.rb | 2 +- .../projects/git/git_trees_controller_spec.rb | 10 ++-- spec/routing/projects_routing_spec.rb.rb | 46 +++++++++++++++++++ 4 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 spec/routing/projects_routing_spec.rb.rb diff --git a/app/models/project.rb b/app/models/project.rb index 3b34263c0..1fd0deb1b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 @@ -19,7 +20,7 @@ class Project < ActiveRecord::Base has_many :advisories - validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/} + validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^#{NAME_REGEXP}$/} validates :owner, :presence => true validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS } diff --git a/config/routes.rb b/config/routes.rb index a9eb1befc..21332c26d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/controllers/projects/git/git_trees_controller_spec.rb b/spec/controllers/projects/git/git_trees_controller_spec.rb index 16a10a40b..420234301 100644 --- a/spec/controllers/projects/git/git_trees_controller_spec.rb +++ b/spec/controllers/projects/git/git_trees_controller_spec.rb @@ -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 diff --git a/spec/routing/projects_routing_spec.rb.rb b/spec/routing/projects_routing_spec.rb.rb new file mode 100644 index 000000000..ac8d5d2e2 --- /dev/null +++ b/spec/routing/projects_routing_spec.rb.rb @@ -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 From aa38017daae437f4efd973e33803cca19473162d Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 14 May 2012 23:24:09 +0600 Subject: [PATCH 3/7] [refs #340] restore page titles --- config/locales/title.en.yml | 41 ++++++++++++++++++++----------------- config/locales/title.ru.yml | 41 ++++++++++++++++++++----------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/config/locales/title.en.yml b/config/locales/title.en.yml index 85ab39254..191ba53f6 100644 --- a/config/locales/title.en.yml +++ b/config/locales/title.en.yml @@ -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' \ No newline at end of file + 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' \ No newline at end of file diff --git a/config/locales/title.ru.yml b/config/locales/title.ru.yml index af631bc9a..b37f512f0 100644 --- a/config/locales/title.ru.yml +++ b/config/locales/title.ru.yml @@ -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: 'Мониторинг продуктов' \ No newline at end of file From 8470674c62046c1844cd3573ce4a07394ce8c877 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Mon, 14 May 2012 22:08:31 +0300 Subject: [PATCH 4/7] Apply basic build list packages store functionality. Display build list package content. Write specs. Refactor. Refs #444 --- .../projects/build_lists_controller.rb | 2 + app/models/build_list.rb | 51 ++++++++++++------- app/models/build_list/package.rb | 12 +++++ app/models/platform.rb | 2 + app/models/project.rb | 3 +- app/views/projects/build_lists/show.html.haml | 19 +++++++ config/locales/models/build_list.en.yml | 7 +++ config/locales/models/build_list.ru.yml | 7 +++ ...120512102707_create_build_list_packages.rb | 19 +++++++ db/schema.rb | 19 ++++++- .../projects/build_lists_controller_spec.rb | 23 ++++++++- 11 files changed, 141 insertions(+), 23 deletions(-) create mode 100644 app/models/build_list/package.rb create mode 100644 db/migrate/20120512102707_create_build_list_packages.rb diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 76098dc45..330f396b1 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -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 + render :nothing => true, :status => 200 end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 4d6cefaf2..1ff328c70 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -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,27 @@ 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 + #handle_asynchronously :place_build + + 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 diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb new file mode 100644 index 000000000..b491c0d13 --- /dev/null +++ b/app/models/build_list/package.rb @@ -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 diff --git a/app/models/platform.rb b/app/models/platform.rb index 4cf0de66a..dccf01e92 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -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_\-]+$/ } diff --git a/app/models/project.rb b/app/models/project.rb index 1fd0deb1b..c29a0b405 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -18,7 +18,8 @@ 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, :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 => /^#{NAME_REGEXP}$/} validates :owner, :presence => true diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 90e9756d5..cd3fb1c85 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -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'); diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 10c97a048..9688c14c0 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -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' diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 999d44f5d..faebb4372 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -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: 'Сборка отменена.' diff --git a/db/migrate/20120512102707_create_build_list_packages.rb b/db/migrate/20120512102707_create_build_list_packages.rb new file mode 100644 index 000000000..1e6b1acd9 --- /dev/null +++ b/db/migrate/20120512102707_create_build_list_packages.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 5e397546f..51043e17a 100644 --- a/db/schema.rb +++ b/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" diff --git a/spec/controllers/projects/build_lists_controller_spec.rb b/spec/controllers/projects/build_lists_controller_spec.rb index bdaf51cc0..546b93c99 100644 --- a/spec/controllers/projects/build_lists_controller_spec.rb +++ b/spec/controllers/projects/build_lists_controller_spec.rb @@ -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,7 @@ 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) } end describe 'pre_build' do From 78ab229c4fca3796cfeadd5eac9d648c1f765843 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Mon, 14 May 2012 23:00:04 +0300 Subject: [PATCH 5/7] Fix advisories relaton. Minor code cleanup. Write more specs. Refs #444 --- app/models/build_list.rb | 1 - app/models/project.rb | 2 +- .../projects/build_lists_controller_spec.rb | 12 ++++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 1ff328c70..ece4f3120 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -187,7 +187,6 @@ class BuildList < ActiveRecord::Base self.status = BUILD_PENDING if self.status == 0 save end - #handle_asynchronously :place_build def build_package(pkg_hash, package_type) packages.create(pkg_hash) do |p| diff --git a/app/models/project.rb b/app/models/project.rb index c29a0b405..d69eb3368 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -18,7 +18,7 @@ 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, :dependent => :destroy + 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 => /^#{NAME_REGEXP}$/} diff --git a/spec/controllers/projects/build_lists_controller_spec.rb b/spec/controllers/projects/build_lists_controller_spec.rb index 546b93c99..1923d0420 100644 --- a/spec/controllers/projects/build_lists_controller_spec.rb +++ b/spec/controllers/projects/build_lists_controller_spec.rb @@ -375,6 +375,18 @@ describe Projects::BuildListsController do 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 From 06191eb12a53c84c9abb504240e19a5eec2ba2a1 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Tue, 15 May 2012 01:15:48 +0300 Subject: [PATCH 6/7] Quickfix for status_build. Refs #444 --- app/controllers/projects/build_lists_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 330f396b1..d9f85ffba 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -112,7 +112,7 @@ 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 + @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 From c1b4a0639d21ccfb126c11dda3db0941e2d24869 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Tue, 15 May 2012 13:12:07 +0300 Subject: [PATCH 7/7] Fix build list display --- app/views/projects/build_lists/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index cd3fb1c85..46b7b761f 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -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