#298: ability for auto publish package into dev platform

This commit is contained in:
Vokhmin Alexey V 2013-09-16 18:14:55 +04:00
parent 01f46b2cf2
commit 24a0307e63
2 changed files with 15 additions and 2 deletions

View File

@ -280,11 +280,19 @@ class BuildList < ActiveRecord::Base
build_started? || build_pending?
end
# Comparison between versions of current and last published build_list
# @return [Number]
# - false if no new packages
# - false if version of packages is less than version of pubished packages.
# - true if version of packages is equal to version of pubished packages (only if platform is not released).
# - true if version of packages is greater than version of pubished packages.
def has_new_packages?
if last_bl = last_published.joins(:source_packages).where(:build_list_packages => {:actual => true}).last
source_packages.each do |nsp|
sp = last_bl.source_packages.find{ |sp| nsp.name == sp.name }
return !sp || nsp.rpmvercmp(sp) == 1
return true unless sp
comparison = nsp.rpmvercmp(sp)
return comparison == 1 || (comparison == 0 && !save_to_platform.released?)
end
else
return true # no published packages

View File

@ -178,10 +178,15 @@ describe BuildList do
:release => 6,
:project => published_build_list.project) }
it 'ensures that return false if version of packages are same' do
it 'ensures that return false if version of packages are same and platform is released' do
build_list.save_to_platform.update_attributes(:released => true)
build_list.has_new_packages?.should be_false
end
it 'ensures that return true if version of packages are same and platform is not released' do
build_list.has_new_packages?.should be_true
end
context 'ensures that return false if version of published package >' do
it 'published: 3.1.13, new: 3.1.12' do