Source

redmine-mq-issue4455 / repo-hg-test-setup.diff

Full commit
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1292770312 -32400
# Node ID a3d84e4946bcbfcfcaa62cdc3ba25c6ca67cba95
# Parent  fbc3f1d06b69dcab58d53b37aecb7767b15485b7
Move setup code of RepositoryMercurialTest to #setup

diff --git a/test/unit/repository_mercurial_test.rb b/test/unit/repository_mercurial_test.rb
--- a/test/unit/repository_mercurial_test.rb
+++ b/test/unit/repository_mercurial_test.rb
@@ -23,16 +23,15 @@ class RepositoryMercurialTest < ActiveSu
   # No '..' in the repository path
   REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
   
-  def setup
-    @project = Project.find(1)
-    assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH)
-  end
-  
   if File.directory?(REPOSITORY_PATH)  
-    def test_fetch_changesets_from_scratch
+    def setup
+      @project = Project.find(1)
+      assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH)
       @repository.fetch_changesets
       @repository.reload
-      
+    end
+
+    def test_fetch_changesets_from_scratch
       assert_equal 17, @repository.changesets.count
       assert_equal 25, @repository.changes.count
       assert_equal "Initial import.\nThe repository contains 3 files.",
@@ -40,7 +39,6 @@ class RepositoryMercurialTest < ActiveSu
     end
     
     def test_fetch_changesets_incremental
-      @repository.fetch_changesets
       # Remove changesets with revision > 2
       @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
       @repository.reload
@@ -66,17 +64,12 @@ class RepositoryMercurialTest < ActiveSu
     def test_isodatesec
       # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher
       if @repository.scm.class.client_version_above?([1, 0])
-        @repository.fetch_changesets
-        @repository.reload
         rev0_committed_on = Time.gm(2007, 12, 14, 9, 22, 52)
         assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on
       end
     end
 
     def test_changeset_order_by_revision
-      @repository.fetch_changesets
-      @repository.reload
-
       c0 = @repository.latest_changeset
       c1 = @repository.changesets.find_by_revision('0')
       # sorted by revision (id), not by date