[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|
|
HUMAN_STATUSES.each do |code,name|
|
||||||
state name, :value => code
|
state name, :value => code
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def set_version_and_tag
|
def set_version_and_tag
|
||||||
pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first
|
pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first
|
||||||
self.package_version = "#{pkg.platform.name}-#{pkg.version}-#{pkg.release}"
|
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
|
system("cd #{self.project.git_repository.path} && git tag #{self.package_version} #{self.commit_hash}") # TODO REDO through grit
|
||||||
save
|
save
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO: Share this checking on product owner.
|
#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
|
@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
|
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)
|
def self.human_status(status)
|
||||||
I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}")
|
I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,6 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Projects::BuildListsController do
|
describe Projects::BuildListsController do
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
any_instance_of(BuildList, :set_version_and_tag => true)
|
|
||||||
end
|
|
||||||
|
|
||||||
shared_examples_for 'show build list' do
|
shared_examples_for 'show build list' do
|
||||||
it 'should be able to perform show action' do
|
it 'should be able to perform show action' do
|
||||||
get :show, @show_params
|
get :show, @show_params
|
||||||
|
@ -321,13 +317,19 @@ describe Projects::BuildListsController do
|
||||||
|
|
||||||
context 'callbacks' do
|
context 'callbacks' do
|
||||||
let(:build_list) { FactoryGirl.create(:build_list_core) }
|
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
|
before(:each) do
|
||||||
mock(controller).authenticate_build_service! {true}
|
mock(controller).authenticate_build_service! {true}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'publish_build' do
|
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)
|
def do_get(status)
|
||||||
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
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
|
response.should be_ok
|
||||||
}
|
}
|
||||||
# TODO: Remove pending after set_version_and_tag unstub:
|
# 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)
|
do_get(BuildServer::SUCCESS)
|
||||||
build_list.project.git_repository.tags.last.name.should == build_list.package_version
|
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
|
build_list.project.git_repository.commits(build_list.package_version).last.id.should == build_list.commit_hash
|
||||||
end
|
end
|
||||||
pending { 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, :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, :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 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_not change(build_list, :package_version) }
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :updated_at) }
|
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
|
factory :build_list_core, :parent => :build_list do
|
||||||
bs_id { FactoryGirl.generate(:integer) }
|
bs_id { FactoryGirl.generate(:integer) }
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue