From 691e218a75db2924597733c65b941729545dbaac Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Tue, 7 Jan 2014 14:53:49 +0000 Subject: [PATCH] add unit test to have one default repository git-svn-id: http://svn.redmine.org/redmine/trunk@12492 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/repository_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb index 2bf12f1c2..95f0437ae 100644 --- a/test/unit/repository_test.rb +++ b/test/unit/repository_test.rb @@ -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,