#31: update specs and update before_validation for not_delete field

This commit is contained in:
Vokhmin Alexey V 2013-03-27 18:01:54 +04:00
parent 0207e25fb8
commit baf7ceb8f0
3 changed files with 8 additions and 6 deletions

View File

@ -39,7 +39,8 @@ class ProductBuildList < ActiveRecord::Base
# see: Issue #6 # see: Issue #6
before_validation lambda { self.arch_id = Arch.find_by_name('x86_64').id }, :on => :create before_validation lambda { self.arch_id = Arch.find_by_name('x86_64').id }, :on => :create
before_validation lambda { self.not_delete = false unless build_completed? } # field "not_delete" can be changed only if build has been completed
before_validation lambda { self.not_delete = false unless build_completed?; true }
validates :product_id, validates :product_id,
:status, :status,
:project_id, :project_id,

View File

@ -2,8 +2,9 @@
require 'spec_helper' require 'spec_helper'
describe ProductBuildList do describe ProductBuildList do
before(:all) do before do
stub_symlink_methods stub_symlink_methods
FactoryGirl.create(:product_build_list)
end end
it { should belong_to(:product) } it { should belong_to(:product) }
@ -29,9 +30,8 @@ describe ProductBuildList do
# see app/ability.rb # see app/ability.rb
# can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work # can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
it 'should generate correct sql to get product build lists' do it 'should generate correct sql to get product build lists' do
stub_symlink_methods
user = FactoryGirl.create(:user) user = FactoryGirl.create(:user)
ability = Ability.new user ability = Ability.new user
ProductBuildList.accessible_by(ability).count.should == 0 ProductBuildList.accessible_by(ability).count.should == 1
end end
end end

View File

@ -32,8 +32,9 @@ describe Product do
before do before do
stub_symlink_methods stub_symlink_methods
stub_redis stub_redis
product.update_attributes(:autostart_status => Product::ONCE_A_12_HOURS, :main_script => 'text.sh') params = {:main_script => 'text.sh', :project_version => product.project.default_branch}
FactoryGirl.create(:product, :autostart_status => Product::ONCE_A_DAY, :main_script => 'text.sh') product.update_attributes params.merge(:autostart_status => Product::ONCE_A_12_HOURS)
FactoryGirl.create :product, params.merge(:autostart_status => Product::ONCE_A_DAY)
end end
it 'should be created only one product_build_list' do it 'should be created only one product_build_list' do