From 24a0307e63626ab14f9533af3c37e08939c64487 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 16 Sep 2013 18:14:55 +0400 Subject: [PATCH] #298: ability for auto publish package into dev platform --- app/models/build_list.rb | 10 +++++++++- spec/models/build_list_spec.rb | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index dd4ebf109..bfe51b9ac 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -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 diff --git a/spec/models/build_list_spec.rb b/spec/models/build_list_spec.rb index f2b643321..cf093e66d 100644 --- a/spec/models/build_list_spec.rb +++ b/spec/models/build_list_spec.rb @@ -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