diff --git a/app/models/project.rb b/app/models/project.rb index ecc30a4f0..95063fc5b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/config/locales/models/project.en.yml b/config/locales/models/project.en.yml index 19f76d2ae..3a617ba6b 100644 --- a/config/locales/models/project.en.yml +++ b/config/locales/models/project.en.yml @@ -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 diff --git a/config/locales/models/project.ru.yml b/config/locales/models/project.ru.yml index 0a38bafb1..916052de3 100644 --- a/config/locales/models/project.ru.yml +++ b/config/locales/models/project.ru.yml @@ -99,3 +99,4 @@ ru: errors: project: uname: В имени можно использовать только строчные символы латинского алфавита (a-z), цифры (0-9) и символ нижнего подчеркивания (_) + default_branch: Указана несуществующая ветка