Make repository identifier accept underscores (#11192).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9875 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
6c6aae07a2
commit
3b854bee59
|
@ -37,8 +37,8 @@ class Repository < ActiveRecord::Base
|
||||||
validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
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_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
|
||||||
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
|
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
|
||||||
# donwcase letters, digits, dashes but not digits only
|
# donwcase letters, digits, dashes, underscores but not digits only
|
||||||
validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :allow_blank => true
|
validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-_]*$/, :allow_blank => true
|
||||||
# Checks if the SCM is enabled when creating a repository
|
# Checks if the SCM is enabled when creating a repository
|
||||||
validate :repo_create_validation, :on => :create
|
validate :repo_create_validation, :on => :create
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,15 @@ class RepositoryTest < ActiveSupport::TestCase
|
||||||
assert_equal [repository1, repository2], Project.find(3).repositories.sort
|
assert_equal [repository1, repository2], Project.find(3).repositories.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_identifier_should_accept_letters_digits_dashes_and_underscores
|
||||||
|
r = Repository::Subversion.new(
|
||||||
|
:project_id => 3,
|
||||||
|
:identifier => 'svn-123_45',
|
||||||
|
:url => 'file:///svn'
|
||||||
|
)
|
||||||
|
assert r.save
|
||||||
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
repository = Repository.find(10)
|
repository = Repository.find(10)
|
||||||
changesets = repository.changesets.count
|
changesets = repository.changesets.count
|
||||||
|
|
Loading…
Reference in New Issue