]> source.dussan.org Git - redmine.git/commitdiff
Merged r14050 (#19260).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Mar 2015 09:42:51 +0000 (09:42 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Mar 2015 09:42:51 +0000 (09:42 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@14059 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/repository.rb
test/unit/repository_git_test.rb

index ff06f08a102d55e519c743205cd596d7919067b5..36ed06b7f489f38145378d47ccc007f6e4377dd0 100644 (file)
@@ -38,7 +38,6 @@ class Repository < ActiveRecord::Base
 
   validates_length_of :password, :maximum => 255, :allow_nil => true
   validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
-  validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
   validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
   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
index abd123ae787d7b2acfb78bef85059ba0b5931058..a7388d0f10f0304ca74193ca76fac865b0dd4106 100644 (file)
@@ -53,6 +53,35 @@ class RepositoryGitTest < ActiveSupport::TestCase
     end
   end
 
+  def test_nondefault_repo_with_blank_identifier_destruction
+    repo1 = Repository::Git.new(
+                          :project    => @project,
+                          :url        => REPOSITORY_PATH,
+                          :identifier => '',
+                          :is_default => true
+                        )
+    assert repo1.save
+    repo1.fetch_changesets
+
+    repo2 = Repository::Git.new(
+                          :project    => @project,
+                          :url        => REPOSITORY_PATH,
+                          :identifier => 'repo2',
+                          :is_default => true
+                    )
+    assert repo2.save
+    repo2.fetch_changesets
+
+    repo1.reload
+    repo2.reload
+    assert !repo1.is_default?
+    assert  repo2.is_default?
+
+    assert_difference 'Repository.count', -1 do
+      repo1.destroy
+    end
+  end
+
   def test_blank_path_to_repository_error_message
     set_language_if_valid 'en'
     repo = Repository::Git.new(