validates_length_of :password, :maximum => 255, :allow_nil => true
validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
- validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
+ validates_uniqueness_of :identifier, :scope => :project_id
validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision)
# donwcase letters, digits, dashes, underscores but not digits only
validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true
assert_equal repository, project.repository
end
+ def test_2_repositories_with_same_identifier_in_different_projects_should_be_valid
+ Repository::Subversion.create!(:project_id => 2, :identifier => 'foo', :url => 'file:///foo')
+ r = Repository::Subversion.new(:project_id => 3, :identifier => 'foo', :url => 'file:///bar')
+ assert r.save
+ end
+
+ def test_2_repositories_with_same_identifier_should_not_be_valid
+ Repository::Subversion.create!(:project_id => 3, :identifier => 'foo', :url => 'file:///foo')
+ r = Repository::Subversion.new(:project_id => 3, :identifier => 'foo', :url => 'file:///bar')
+ assert !r.save
+ end
+
+ def test_2_repositories_with_blank_identifier_should_not_be_valid
+ Repository::Subversion.create!(:project_id => 3, :identifier => '', :url => 'file:///foo')
+ r = Repository::Subversion.new(:project_id => 3, :identifier => '', :url => 'file:///bar')
+ assert !r.save
+ end
+
def test_first_repository_should_be_set_as_default
repository1 = Repository::Subversion.new(
:project => Project.find(3),