[refs #505] Fix state machine tests
This commit is contained in:
parent
ac7a3980cd
commit
8ce6c26cc4
|
@ -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
|
||||
|
|
|
@ -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) }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue