#298: added extra specs for #has_new_packages?

This commit is contained in:
Vokhmin Alexey V 2013-09-10 20:09:48 +04:00
parent 4ed7543872
commit 99d7a2baa0
2 changed files with 47 additions and 12 deletions

View File

@ -293,7 +293,9 @@ class BuildList < ActiveRecord::Base
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
ov = sp_version[index].to_i
return true if nv > ov
return false if nv < ov
end
end
end

View File

@ -2,6 +2,7 @@
require 'spec_helper'
describe BuildList do
before { stub_symlink_methods }
context 'validates that repository contains project' do
it 'when repository contains project' do
@ -16,7 +17,6 @@ describe BuildList do
end
context "#notify_users" do
before { stub_symlink_methods }
let!(:user) { FactoryGirl.create(:user) }
let!(:build_list) { FactoryGirl.create(:build_list,
:user => user,
@ -155,13 +155,14 @@ describe BuildList do
end # notify_users
context '#can_auto_publish?' do
before { stub_symlink_methods }
context '#has_new_packages?' do
let!(:build_list) { FactoryGirl.create( :build_list,
:status => BuildList::SUCCESS,
:auto_publish => true) }
let!(:build_list_package) { FactoryGirl.create( :build_list_package,
:build_list => build_list,
:version => '3.1.12',
:release => 6,
:platform => build_list.save_to_platform,
:project => build_list.project) }
let!(:published_build_list) { FactoryGirl.create( :build_list,
@ -173,25 +174,57 @@ describe BuildList do
:build_list => published_build_list,
:platform => published_build_list.save_to_platform,
:actual => true,
:version => '3.1.12',
:release => 6,
:project => published_build_list.project) }
it 'ensures that return false if version of packages are same' do
build_list.can_auto_publish?.should be_false
build_list.has_new_packages?.should be_false
end
it 'ensures that return false if version of published package >' do
published_build_list_package.update_attributes(:version => '3.1.13')
build_list.can_auto_publish?.should be_false
context 'ensures that return false if version of published package >' do
it 'published: 3.1.13, new: 3.1.12' do
published_build_list_package.update_attributes(:version => '3.1.13')
build_list.has_new_packages?.should be_false
end
it 'published: 3.1.12, new: 3.0.999' do
build_list_package.update_attributes(:version => '3.0.999')
build_list.has_new_packages?.should be_false
end
it 'published: 3.0.rc1, new: 3.0.0' do
published_build_list_package.update_attributes(:version => '3.0.rc1')
build_list_package.update_attributes(:version => '3.0.0')
build_list.has_new_packages?.should be_false
end
end
it 'ensures that return true if version of published package <' do
published_build_list_package.update_attributes(:version => '3.1.11')
build_list.can_auto_publish?.should be_true
context 'ensures that return true if version of published package <' do
it 'published: 3.1.11, new: 3.1.12' do
published_build_list_package.update_attributes(:version => '3.1.11')
build_list.has_new_packages?.should be_true
end
it 'published: 3.0.999, new: 3.1.12' do
published_build_list_package.update_attributes(:version => '3.0.999')
build_list.has_new_packages?.should be_true
end
it 'published: 3.0.0, new: 3.0.rc1' do
published_build_list_package.update_attributes(:version => '3.0.0')
build_list_package.update_attributes(:version => '3.0.rc1')
build_list.has_new_packages?.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
build_list.has_new_packages?.should be_true
end
end