serialize :extra_info
+ before_validation :normalize_identifier
before_save :check_default
# Raw SQL to delete changesets and changes in the database
protected
+ def normalize_identifier
+ self.identifier = identifier.to_s.strip
+ end
+
def check_default
if !is_default? && set_as_default?
self.is_default = true
def test_diff
assert_equal true, @repository.is_default
- assert_nil @repository.identifier
+ assert @repository.identifier.blank?
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
@project.reload
assert !r.save
end
+ def test_2_repositories_with_blank_identifier_and_one_as_default_should_not_be_valid
+ Repository::Subversion.create!(:project_id => 3, :identifier => '', :url => 'file:///foo', :is_default => true)
+ r = Repository::Subversion.new(:project_id => 3, :identifier => '', :url => 'file:///bar')
+ assert !r.save
+ end
+
+ def test_2_repositories_with_blank_and_nil_identifier_should_not_be_valid
+ Repository::Subversion.create!(:project_id => 3, :identifier => nil, :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),