]> source.dussan.org Git - redmine.git/commitdiff
add unit test to have one default repository
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 7 Jan 2014 14:53:49 +0000 (14:53 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 7 Jan 2014 14:53:49 +0000 (14:53 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12492 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/repository_test.rb

index 2bf12f1c20cc8ab262fb525ae27ae35c73cdde06..95f0437aefc6884a3bcbe68ffc2de83dde6feb61 100644 (file)
@@ -97,6 +97,31 @@ class RepositoryTest < ActiveSupport::TestCase
     assert_equal [repository1, repository2], Project.find(3).repositories.sort
   end
 
+  def test_default_repository_should_be_one
+    assert_equal 0, Project.find(3).repositories.count
+    repository1 = Repository::Subversion.new(
+                      :project => Project.find(3),
+                      :identifier => 'svn1',
+                      :url => 'file:///svn1'
+                    )
+    assert repository1.save
+    assert repository1.is_default?
+
+    repository2 = Repository::Subversion.new(
+                      :project => Project.find(3),
+                      :identifier => 'svn2',
+                      :url => 'file:///svn2',
+                      :is_default => true
+                    )
+    assert repository2.save
+    assert repository2.is_default?
+    repository1.reload
+    assert !repository1.is_default?
+
+    assert_equal repository2, Project.find(3).repository
+    assert_equal [repository2, repository1], Project.find(3).repositories.sort
+  end
+
   def test_identifier_should_accept_letters_digits_dashes_and_underscores
     r = Repository::Subversion.new(
       :project_id => 3,