diff test/unit/repository_cvs_test.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42
line wrap: on
line diff
--- a/test/unit/repository_cvs_test.rb	Wed Jun 27 14:54:18 2012 +0100
+++ b/test/unit/repository_cvs_test.rb	Mon Jan 07 12:01:42 2013 +0000
@@ -1,5 +1,5 @@
 # Redmine - project management software
-# Copyright (C) 2006-2011  Jean-Philippe Lang
+# Copyright (C) 2006-2012  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -20,6 +20,8 @@
 class RepositoryCvsTest < ActiveSupport::TestCase
   fixtures :projects
 
+  include Redmine::I18n
+
   REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
   REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
   # CVS module
@@ -35,6 +37,64 @@
     assert @repository
   end
 
+  def test_blank_module_error_message
+    set_language_if_valid 'en'
+    repo = Repository::Cvs.new(
+                          :project      => @project,
+                          :identifier   => 'test',
+                          :log_encoding => 'UTF-8',
+                          :root_url     => REPOSITORY_PATH
+                        )
+    assert !repo.save
+    assert_include "Module can't be blank",
+                   repo.errors.full_messages
+  end
+
+  def test_blank_module_error_message_fr
+    set_language_if_valid 'fr'
+    str = "Module doit \xc3\xaatre renseign\xc3\xa9(e)"
+    str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
+    repo = Repository::Cvs.new(
+                          :project       => @project,
+                          :identifier    => 'test',
+                          :log_encoding  => 'UTF-8',
+                          :path_encoding => '',
+                          :url           => '',
+                          :root_url      => REPOSITORY_PATH
+                        )
+    assert !repo.save
+    assert_include str, repo.errors.full_messages
+  end
+
+  def test_blank_cvsroot_error_message
+    set_language_if_valid 'en'
+    repo = Repository::Cvs.new(
+                          :project      => @project,
+                          :identifier   => 'test',
+                          :log_encoding => 'UTF-8',
+                          :url          => MODULE_NAME
+                        )
+    assert !repo.save
+    assert_include "CVSROOT can't be blank",
+                   repo.errors.full_messages
+  end
+
+  def test_blank_cvsroot_error_message_fr
+    set_language_if_valid 'fr'
+    str = "CVSROOT doit \xc3\xaatre renseign\xc3\xa9(e)"
+    str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
+    repo = Repository::Cvs.new(
+                          :project       => @project,
+                          :identifier    => 'test',
+                          :log_encoding  => 'UTF-8',
+                          :path_encoding => '',
+                          :url           => MODULE_NAME,
+                          :root_url      => ''
+                        )
+    assert !repo.save
+    assert_include str, repo.errors.full_messages
+  end
+
   if File.directory?(REPOSITORY_PATH)
     def test_fetch_changesets_from_scratch
       assert_equal 0, @repository.changesets.count
@@ -42,7 +102,7 @@
       @project.reload
 
       assert_equal CHANGESETS_NUM, @repository.changesets.count
-      assert_equal 16, @repository.changes.count
+      assert_equal 16, @repository.filechanges.count
       assert_not_nil @repository.changesets.find_by_comments('Two files changed')
 
       r2 = @repository.changesets.find_by_revision('2')
@@ -52,11 +112,14 @@
     def test_fetch_changesets_incremental
       assert_equal 0, @repository.changesets.count
       @repository.fetch_changesets
+      @project.reload
+      assert_equal CHANGESETS_NUM, @repository.changesets.count
+
       # Remove changesets with revision > 3
       @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
-      @repository.reload
+      @project.reload
       assert_equal 3, @repository.changesets.count
-      assert_equal %w|3 2 1|, @repository.changesets.collect(&:revision)
+      assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision)
 
       rev3_commit = @repository.changesets.find(:first, :order => 'committed_on DESC')
       assert_equal '3', rev3_commit.revision
@@ -68,10 +131,9 @@
       assert_equal rev3_committed_on, latest_rev.committed_on
 
       @repository.fetch_changesets
-      @repository.reload
+      @project.reload
       assert_equal CHANGESETS_NUM, @repository.changesets.count
-
-      assert_equal %w|7 6 5 4 3 2 1|, @repository.changesets.collect(&:revision)
+      assert_equal %w|7 6 5 4 3 2 1|, @repository.changesets.all.collect(&:revision)
       rev5_commit = @repository.changesets.find_by_revision('5')
       assert_equal 'HEAD-20071213-163001', rev5_commit.scmid
        # 2007-12-14 01:30:01 +0900
@@ -96,6 +158,7 @@
       @project.reload
       assert_equal CHANGESETS_NUM, @repository.changesets.count
       entries = @repository.entries('', '3')
+      assert_kind_of Redmine::Scm::Adapters::Entries, entries
       assert_equal 3, entries.size
       assert_equal entries[2].name, "README"
       assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22)