@@ -30,6 +30,7 class Repository < ActiveRecord::Base | |||
|
30 | 30 | |
|
31 | 31 | serialize :extra_info |
|
32 | 32 | |
|
33 | before_validation :normalize_identifier | |
|
33 | 34 | before_save :check_default |
|
34 | 35 | |
|
35 | 36 | # Raw SQL to delete changesets and changes in the database |
@@ -455,6 +456,10 class Repository < ActiveRecord::Base | |||
|
455 | 456 | |
|
456 | 457 | protected |
|
457 | 458 | |
|
459 | def normalize_identifier | |
|
460 | self.identifier = identifier.to_s.strip | |
|
461 | end | |
|
462 | ||
|
458 | 463 | def check_default |
|
459 | 464 | if !is_default? && set_as_default? |
|
460 | 465 | self.is_default = true |
@@ -265,7 +265,7 class RepositoriesGitControllerTest < ActionController::TestCase | |||
|
265 | 265 | |
|
266 | 266 | def test_diff |
|
267 | 267 | assert_equal true, @repository.is_default |
|
268 |
assert |
|
|
268 | assert @repository.identifier.blank? | |
|
269 | 269 | assert_equal 0, @repository.changesets.count |
|
270 | 270 | @repository.fetch_changesets |
|
271 | 271 | @project.reload |
@@ -54,6 +54,8 class RepositoryGitTest < ActiveSupport::TestCase | |||
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | def test_nondefault_repo_with_blank_identifier_destruction |
|
57 | Repository.delete_all | |
|
58 | ||
|
57 | 59 | repo1 = Repository::Git.new( |
|
58 | 60 | :project => @project, |
|
59 | 61 | :url => REPOSITORY_PATH, |
@@ -94,6 +94,18 class RepositoryTest < ActiveSupport::TestCase | |||
|
94 | 94 | assert !r.save |
|
95 | 95 | end |
|
96 | 96 | |
|
97 | def test_2_repositories_with_blank_identifier_and_one_as_default_should_not_be_valid | |
|
98 | Repository::Subversion.create!(:project_id => 3, :identifier => '', :url => 'file:///foo', :is_default => true) | |
|
99 | r = Repository::Subversion.new(:project_id => 3, :identifier => '', :url => 'file:///bar') | |
|
100 | assert !r.save | |
|
101 | end | |
|
102 | ||
|
103 | def test_2_repositories_with_blank_and_nil_identifier_should_not_be_valid | |
|
104 | Repository::Subversion.create!(:project_id => 3, :identifier => nil, :url => 'file:///foo') | |
|
105 | r = Repository::Subversion.new(:project_id => 3, :identifier => '', :url => 'file:///bar') | |
|
106 | assert !r.save | |
|
107 | end | |
|
108 | ||
|
97 | 109 | def test_first_repository_should_be_set_as_default |
|
98 | 110 | repository1 = Repository::Subversion.new( |
|
99 | 111 | :project => Project.find(3), |
General Comments 0
You need to be logged in to leave comments.
Login now