diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-07-26 17:41:47 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-07-26 17:41:47 +0000 |
commit | 87f284dcb6c54047948f39cf5ce58444eae73c1e (patch) | |
tree | ae8088be75660a852b08baaf50de4cf2d3b553a0 /app/models/repository.rb | |
parent | 04f9a321b1205d6017c86030eebd6f8b3b93774a (diff) | |
download | redmine-87f284dcb6c54047948f39cf5ce58444eae73c1e.tar.gz redmine-87f284dcb6c54047948f39cf5ce58444eae73c1e.zip |
Repository Identifier should be frozen (#11109).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10081 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index c81979a26..9a6891a90 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -20,6 +20,9 @@ class ScmFetchError < Exception; end class Repository < ActiveRecord::Base include Redmine::Ciphering include Redmine::SafeAttributes + + # Maximum length for repository identifiers + IDENTIFIER_MAX_LENGTH = 255 belongs_to :project has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC" @@ -34,7 +37,7 @@ class Repository < ActiveRecord::Base before_destroy :clear_changesets validates_length_of :password, :maximum => 255, :allow_nil => true - validates_length_of :identifier, :maximum => 255, :allow_blank => true + validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? } validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) @@ -114,6 +117,14 @@ class Repository < ActiveRecord::Base end end + def identifier=(identifier) + super unless identifier_frozen? + end + + def identifier_frozen? + errors[:identifier].blank? && !(new_record? || identifier.blank?) + end + def identifier_param if is_default? nil |