#298: added checking by release

This commit is contained in:
Vokhmin Alexey V 2013-09-10 18:26:49 +04:00
parent 5db6be8d87
commit 46c18a7bbe
2 changed files with 14 additions and 2 deletions

View File

@ -283,13 +283,20 @@ class BuildList < ActiveRecord::Base
def has_new_packages? def has_new_packages?
if last_bl = last_published.joins(:source_packages).where(:build_list_packages => {:actual => true}).last if last_bl = last_published.joins(:source_packages).where(:build_list_packages => {:actual => true}).last
source_packages.each do |nsp| source_packages.each do |nsp|
# priority: EPOCH => VERSION => RELEASE
# TODO: EPOCH
sp = last_bl.source_packages.find{ |sp| nsp.name == sp.name } sp = last_bl.source_packages.find{ |sp| nsp.name == sp.name }
return true unless sp return true unless sp
sp_version = sp.version.split(/\D/).map(&:to_i) sp_version = sp.version.split(/\D/).map(&:to_i)
nsp.version.split(/\D/).map(&:to_i).each_with_index do |nv, index| nsp_version = nsp.version.split(/\D/).map(&:to_i)
if nsp_version == sp_version
return true if nsp.release.to_i > sp.release.to_i
else
nsp_version.each_with_index do |nv, index|
return true if nv > sp_version[index].to_i return true if nv > sp_version[index].to_i
end end
end end
end
else else
return true # no published packages return true # no published packages
end end

View File

@ -188,6 +188,11 @@ describe BuildList do
build_list.can_auto_publish?.should be_true build_list.can_auto_publish?.should be_true
end end
it 'ensures that return true if release of published package <' do
published_build_list_package.update_attributes(:release => 5)
build_list.can_auto_publish?.should be_true
end
end end
end end