[refs #758] add default branch validation

This commit is contained in:
Alexander Machehin 2012-12-06 13:18:16 +06:00
parent 4b5a45bb1a
commit bdc2cd78fb
3 changed files with 3 additions and 0 deletions

View File

@ -30,6 +30,7 @@ class Project < ActiveRecord::Base
validates :maintainer_id, :presence => true, :unless => :new_record?
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
validate { errors.add(:default_branch, I18n.t('activerecord.errors.project.default_branch')) unless self.repo.branches.map(&:name).include?(self.default_branch) }
attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki, :maintainer_id
attr_readonly :name, :owner_id, :owner_type

View File

@ -99,3 +99,4 @@ en:
errors:
project:
uname: The name can only use lower case Latin letters (a-z), numbers (0-9) and underscore (_)
default_branch: Wrong branch

View File

@ -99,3 +99,4 @@ ru:
errors:
project:
uname: В имени можно использовать только строчные символы латинского алфавита (a-z), цифры (0-9) и символ нижнего подчеркивания (_)
default_branch: Указана несуществующая ветка