##// END OF EJS Templates
Merged r14142 and r14143 (#19400)....
Jean-Philippe Lang -
r13765:c6c304edf1e3
parent child
Show More
@@ -38,7 +38,7 class Repository < ActiveRecord::Base
38
38
39 validates_length_of :password, :maximum => 255, :allow_nil => true
39 validates_length_of :password, :maximum => 255, :allow_nil => true
40 validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
40 validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
41 validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
41 validates_uniqueness_of :identifier, :scope => :project_id
42 validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision)
42 validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision)
43 # donwcase letters, digits, dashes, underscores but not digits only
43 # donwcase letters, digits, dashes, underscores but not digits only
44 validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true
44 validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true
@@ -209,7 +209,7 class Repository::Git < Repository
209 end
209 end
210 h["heads"] = repo_heads.dup
210 h["heads"] = repo_heads.dup
211 merge_extra_info(h)
211 merge_extra_info(h)
212 self.save
212 save(:validate => false)
213 end
213 end
214 private :save_revisions
214 private :save_revisions
215
215
@@ -251,7 +251,7 class Repository::Git < Repository
251 h = {}
251 h = {}
252 h["extra_report_last_commit"] = v
252 h["extra_report_last_commit"] = v
253 merge_extra_info(h)
253 merge_extra_info(h)
254 self.save
254 save(:validate => false)
255 end
255 end
256 private :clear_extra_info_of_changesets
256 private :clear_extra_info_of_changesets
257 end
257 end
@@ -76,6 +76,24 class RepositoryTest < ActiveSupport::TestCase
76 assert_equal repository, project.repository
76 assert_equal repository, project.repository
77 end
77 end
78
78
79 def test_2_repositories_with_same_identifier_in_different_projects_should_be_valid
80 Repository::Subversion.create!(:project_id => 2, :identifier => 'foo', :url => 'file:///foo')
81 r = Repository::Subversion.new(:project_id => 3, :identifier => 'foo', :url => 'file:///bar')
82 assert r.save
83 end
84
85 def test_2_repositories_with_same_identifier_should_not_be_valid
86 Repository::Subversion.create!(:project_id => 3, :identifier => 'foo', :url => 'file:///foo')
87 r = Repository::Subversion.new(:project_id => 3, :identifier => 'foo', :url => 'file:///bar')
88 assert !r.save
89 end
90
91 def test_2_repositories_with_blank_identifier_should_not_be_valid
92 Repository::Subversion.create!(:project_id => 3, :identifier => '', :url => 'file:///foo')
93 r = Repository::Subversion.new(:project_id => 3, :identifier => '', :url => 'file:///bar')
94 assert !r.save
95 end
96
79 def test_first_repository_should_be_set_as_default
97 def test_first_repository_should_be_set_as_default
80 repository1 = Repository::Subversion.new(
98 repository1 = Repository::Subversion.new(
81 :project => Project.find(3),
99 :project => Project.find(3),
General Comments 0
You need to be logged in to leave comments. Login now