diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 82ff59b1e..7571671f0 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -169,13 +169,13 @@ class BuildList < ActiveRecord::Base HUMAN_STATUSES.each do |code,name| state name, :value => code end + end - def set_version_and_tag - pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first - 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 + def set_version_and_tag + pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first + 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. @@ -193,14 +193,6 @@ class BuildList < ActiveRecord::Base @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 set_version_and_tag - # #pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first - # #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 - # 2 + 1 - #end - def self.human_status(status) I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}") end diff --git a/spec/controllers/projects/build_lists_controller_spec.rb b/spec/controllers/projects/build_lists_controller_spec.rb index 61d92d71c..a8806dfbe 100644 --- a/spec/controllers/projects/build_lists_controller_spec.rb +++ b/spec/controllers/projects/build_lists_controller_spec.rb @@ -3,10 +3,6 @@ require 'spec_helper' describe Projects::BuildListsController do - before(:each) do - any_instance_of(BuildList, :set_version_and_tag => true) - end - shared_examples_for 'show build list' do it 'should be able to perform show action' do get :show, @show_params @@ -321,13 +317,19 @@ describe Projects::BuildListsController do context 'callbacks' do 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 mock(controller).authenticate_build_service! {true} end 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; build_list.update_attribute(:status, BuildList::BUILD_PUBLISH); } + 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) get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1' @@ -340,13 +342,13 @@ describe Projects::BuildListsController do response.should be_ok } # TODO: Remove pending after set_version_and_tag unstub: - pending 'should create correct git tag for correct commit' do + it 'should create correct git tag for correct commit' do do_get(BuildServer::SUCCESS) 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 end - pending { 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, :status).to(BuildList::BUILD_PUBLISHED) } + 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_not change(build_list, :package_version) } it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :updated_at) } diff --git a/spec/factories/build_lists.rb b/spec/factories/build_lists.rb index 88dda9c27..0271f50ea 100644 --- a/spec/factories/build_lists.rb +++ b/spec/factories/build_lists.rb @@ -16,4 +16,15 @@ FactoryGirl.define do factory :build_list_core, :parent => :build_list do bs_id { FactoryGirl.generate(:integer) } 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