diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/build_lists_controller.rb index fc650a4b3..86d2b9064 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/build_lists_controller.rb @@ -80,7 +80,12 @@ class BuildListsController < ApplicationController end def publish_build - @build_list.status = (params[:status].to_i == 0 ? BuildList::BUILD_PUBLISHED : BuildList::FAILED_PUBLISH) + if params[:status].to_i == 0 # ok + @build_list.status = BuildList::BUILD_PUBLISHED + @build_list.package_version = "#{params[:version]}-#{params[:release]}" + else + @build_list.status = BuildList::FAILED_PUBLISH + end @build_list.notified_at = Time.current @build_list.save diff --git a/db/migrate/20120113151305_add_package_version_to_build_lists.rb b/db/migrate/20120113151305_add_package_version_to_build_lists.rb new file mode 100644 index 000000000..d416e3fa5 --- /dev/null +++ b/db/migrate/20120113151305_add_package_version_to_build_lists.rb @@ -0,0 +1,9 @@ +class AddPackageVersionToBuildLists < ActiveRecord::Migration + def self.up + add_column :build_lists, :package_version, :string + end + + def self.down + remove_column :build_lists, :package_version + end +end diff --git a/db/schema.rb b/db/schema.rb index e80b0c134..83b6e610d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111228182425) do +ActiveRecord::Schema.define(:version => 20120113151305) do create_table "arches", :force => true do |t| t.string "name", :null => false @@ -72,6 +72,7 @@ ActiveRecord::Schema.define(:version => 20111228182425) do t.text "include_repos" t.integer "user_id" t.boolean "auto_publish", :default => true + t.string "package_version" end add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id" diff --git a/spec/controllers/build_lists_controller_spec.rb b/spec/controllers/build_lists_controller_spec.rb index a3e088c63..e337c1fd6 100644 --- a/spec/controllers/build_lists_controller_spec.rb +++ b/spec/controllers/build_lists_controller_spec.rb @@ -300,13 +300,15 @@ describe BuildListsController do describe 'publish_build' do def do_get(status) - get :publish_build, :id => build_list.bs_id, :status => status + get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1' build_list.reload end it { do_get(BuildServer::SUCCESS); response.should be_ok } it { 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 { 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 change(build_list, :notified_at) } end