[#247] fix model specs

This commit is contained in:
Alexander Machehin 2014-11-25 22:33:54 +05:00
parent ec3f6e6fd3
commit 212eb66a9e
6 changed files with 16 additions and 13 deletions

View File

@ -38,13 +38,13 @@ class BuildList < ActiveRecord::Base
AUTO_PUBLISH_STATUS_TESTING = 'testing'
]
validates :project,
validates :project, :project_id,
:project_version,
:arch,
:arch, :arch_id,
:include_repos,
:build_for_platform,
:save_to_platform,
:save_to_repository,
:build_for_platform, :build_for_platform_id,
:save_to_platform, :save_to_platform_id,
:save_to_repository, :save_to_repository_id,
presence: true
validates_numericality_of :priority, greater_than_or_equal_to: 0
validates :external_nodes, inclusion: { in: EXTERNAL_NODES }, allow_blank: true

View File

@ -9,7 +9,8 @@ class BuildList::Package < ActiveRecord::Base
attr_accessible :fullname, :name, :release, :version, :sha1, :epoch, :dependent_packages
validates :build_list, :project, :platform, :fullname,
validates :build_list, :build_list_id, :project, :project_id,
:platform, :platform_id, :fullname,
:package_type, :name, :release, :version,
presence: true
validates :package_type, inclusion: PACKAGE_TYPES

View File

@ -10,7 +10,8 @@ class BuildScript < ActiveRecord::Base
belongs_to :project
validates :treeish, presence: true
validates :project, presence: true, uniqueness: { scope: :treeish }
validates :project, presence: true
validates :project_id, uniqueness: { scope: :treeish }
scope :by_active, -> { where(status: ACTIVE) }
scope :by_treeish, -> treeish { where(treeish: treeish) }

View File

@ -45,11 +45,12 @@ class ProductBuildList < ActiveRecord::Base
before_validation -> { self.arch_id = Arch.find_by(name: 'x86_64').id }, on: :create
# field "not_delete" can be changed only if build has been completed
before_validation -> { self.not_delete = false unless build_completed?; true }
validates :product,
validates :product, :product_id,
:status,
:project,
:project, :project_id,
:main_script,
:arch, presence: true
:arch, :arch_id,
presence: true
validates :status, inclusion: { in: STATUSES }
validates :main_script, :params, length: { maximum: 255 }

View File

@ -12,7 +12,7 @@ describe BuildScript do
context 'ensures that validations and associations exist' do
it { should belong_to(:project) }
it { should validate_presence_of(:project_id) }
it { should validate_presence_of(:project) }
it { should validate_presence_of(:treeish) }
context 'uniqueness' do

View File

@ -6,8 +6,8 @@ describe ProjectStatistic do
it { should belong_to(:project) }
it { should belong_to(:arch) }
it { should validate_presence_of(:project_id) }
it { should validate_presence_of(:arch_id) }
it { should validate_presence_of(:project) }
it { should validate_presence_of(:arch) }
it { should validate_presence_of(:average_build_time) }
it { should validate_presence_of(:build_count) }