From f522fd3cd07d8100faf738d4207270ba35373cf8 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 13 Nov 2012 18:01:06 +0400 Subject: [PATCH] add selecting Arch on create product build --- app/models/product_build_list.rb | 11 ++++++++--- app/views/platforms/product_build_lists/new.html.haml | 4 ++++ .../platforms/product_build_lists/show.html.haml | 2 +- config/locales/models/product_build_list.en.yml | 1 + config/locales/models/product_build_list.ru.yml | 1 + ...6113338_integrate_new_iso_builder_with_products.rb | 2 ++ db/schema.rb | 1 + .../platforms/product_build_lists_controller_spec.rb | 3 ++- spec/factories/product_build_lists.rb | 1 + 9 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 13c3314da..eb54f1c62 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -19,13 +19,15 @@ class ProductBuildList < ActiveRecord::Base belongs_to :product belongs_to :project + belongs_to :arch validates :product_id, :status, :project_id, :main_script, - :time_living, :presence => true + :time_living, + :arch_id, :presence => true validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] } attr_accessor :base_url @@ -37,7 +39,8 @@ class ProductBuildList < ActiveRecord::Base :params, :project_version, :commit_hash, - :time_living + :time_living, + :arch_id attr_readonly :product_id serialize :results, Array @@ -106,7 +109,9 @@ class ProductBuildList < ActiveRecord::Base :srcpath => srcpath, :params => params, :time_living => time_living, - :main_script => main_script + :main_script => main_script, + :arch => arch.name, + :distrib_type => product.platform.distrib_type } Resque.push( 'iso_worker', diff --git a/app/views/platforms/product_build_lists/new.html.haml b/app/views/platforms/product_build_lists/new.html.haml index e11df71c7..38c51e2b7 100644 --- a/app/views/platforms/product_build_lists/new.html.haml +++ b/app/views/platforms/product_build_lists/new.html.haml @@ -12,6 +12,10 @@ .rightlist= f.select :project_version, versions_for_group_select(pbl.project), :selected => params[:product_build_lists].try(:fetch, :project_version) || "latest_" + pbl.project.default_branch .both + .leftlist= f.label :arch, t("activerecord.attributes.product_build_list.arch"), :class => :label + .rightlist= f.select :arch_id, Arch.recent.map{ |a| [a.name, a.id]} + .both + = render 'platforms/products/def_fields', :f => f = f.submit t("layout.projects.build_button") diff --git a/app/views/platforms/product_build_lists/show.html.haml b/app/views/platforms/product_build_lists/show.html.haml index 8bb14a43c..f37cfb9cf 100644 --- a/app/views/platforms/product_build_lists/show.html.haml +++ b/app/views/platforms/product_build_lists/show.html.haml @@ -17,7 +17,7 @@ = render 'show_field', :key => :project_version, :value => build_list_version_link(pbl, true) -- [:main_script, :params, :time_living].each do |el| +- [:arch, :main_script, :params, :time_living].each do |el| = render 'show_field', :key => el, :value => pbl.send(el) = render 'show_field', :key => :notified_at, :value => l(pbl.updated_at, :format => :long) diff --git a/config/locales/models/product_build_list.en.yml b/config/locales/models/product_build_list.en.yml index 39b28b5fd..595419b22 100644 --- a/config/locales/models/product_build_list.en.yml +++ b/config/locales/models/product_build_list.en.yml @@ -42,6 +42,7 @@ en: main_script: Main script params: Params for running script time_living: Max time for building (in minutes) + arch: Arch product_build_list/results: file_name: File name sha1: SHA1 diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index 144ca9dab..24175cc0a 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -42,6 +42,7 @@ ru: main_script: Основной скрипт params: Параметры для запуска скрипта time_living: Максимальное время сборки (в минутах) + arch: Архитектура product_build_list/results: file_name: Имя файла sha1: SHA1 diff --git a/db/migrate/20121106113338_integrate_new_iso_builder_with_products.rb b/db/migrate/20121106113338_integrate_new_iso_builder_with_products.rb index e11a795e5..1a6764282 100644 --- a/db/migrate/20121106113338_integrate_new_iso_builder_with_products.rb +++ b/db/migrate/20121106113338_integrate_new_iso_builder_with_products.rb @@ -24,6 +24,7 @@ class IntegrateNewIsoBuilderWithProducts < ActiveRecord::Migration add_column :products, :main_script, :string add_column :product_build_lists, :results, :text + add_column :product_build_lists, :arch_id, :integer add_column :products, :time_living, :integer add_column :product_build_lists, :time_living, :integer @@ -54,6 +55,7 @@ class IntegrateNewIsoBuilderWithProducts < ActiveRecord::Migration remove_column :products, :main_script remove_column :product_build_lists, :results + remove_column :product_build_lists, :arch_id remove_column :product_build_lists, :time_living remove_column :products, :time_living diff --git a/db/schema.rb b/db/schema.rb index 2a4b0ae80..e0d3376e3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -287,6 +287,7 @@ ActiveRecord::Schema.define(:version => 20121106113338) do t.string "params" t.string "main_script" t.text "results" + t.integer "arch_id" t.integer "time_living" end diff --git a/spec/controllers/platforms/product_build_lists_controller_spec.rb b/spec/controllers/platforms/product_build_lists_controller_spec.rb index 58bf5275d..75b833a93 100644 --- a/spec/controllers/platforms/product_build_lists_controller_spec.rb +++ b/spec/controllers/platforms/product_build_lists_controller_spec.rb @@ -88,11 +88,12 @@ describe Platforms::ProductBuildListsController do before(:each) do @product = FactoryGirl.create(:product) + @arch = FactoryGirl.create(:arch) @pbl = FactoryGirl.create(:product_build_list, :product => @product) end def valid_attributes - {:product_id => @product.id, :platform_id => @product.platform_id, :product_build_list => {:main_script => 'build.sh', :time_living => 60, :project_version => 'latest_master'}} + {:product_id => @product.id, :platform_id => @product.platform_id, :product_build_list => {:main_script => 'build.sh', :time_living => 60, :project_version => 'latest_master', :arch_id => @arch.id}} end def valid_attributes_for_destroy diff --git a/spec/factories/product_build_lists.rb b/spec/factories/product_build_lists.rb index 911265b66..26cdd4f15 100644 --- a/spec/factories/product_build_lists.rb +++ b/spec/factories/product_build_lists.rb @@ -2,6 +2,7 @@ FactoryGirl.define do factory :product_build_list do association :product, :factory => :product + association :arch, :factory => :arch project { |pbl| pbl.product.project } status 0 # BUILD_COMPLETED main_script 'build.sh'