##// END OF EJS Templates
Make repository identifier accept underscores (#11192)....
Jean-Philippe Lang -
r9692:3b854bee5921
parent child
Show More
@@ -37,8 +37,8 class Repository < ActiveRecord::Base
37 validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
37 validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
38 validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
38 validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
39 validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
39 validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
40 # donwcase letters, digits, dashes but not digits only
40 # donwcase letters, digits, dashes, underscores but not digits only
41 validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :allow_blank => true
41 validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-_]*$/, :allow_blank => true
42 # Checks if the SCM is enabled when creating a repository
42 # Checks if the SCM is enabled when creating a repository
43 validate :repo_create_validation, :on => :create
43 validate :repo_create_validation, :on => :create
44
44
@@ -97,6 +97,15 class RepositoryTest < ActiveSupport::TestCase
97 assert_equal [repository1, repository2], Project.find(3).repositories.sort
97 assert_equal [repository1, repository2], Project.find(3).repositories.sort
98 end
98 end
99
99
100 def test_identifier_should_accept_letters_digits_dashes_and_underscores
101 r = Repository::Subversion.new(
102 :project_id => 3,
103 :identifier => 'svn-123_45',
104 :url => 'file:///svn'
105 )
106 assert r.save
107 end
108
100 def test_destroy
109 def test_destroy
101 repository = Repository.find(10)
110 repository = Repository.find(10)
102 changesets = repository.changesets.count
111 changesets = repository.changesets.count
General Comments 0
You need to be logged in to leave comments. Login now