]> source.dussan.org Git - redmine.git/commitdiff
scm: add unit test of preventing PostgreSQL or Ruby 1.9 errors if paths is invalid...
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sat, 16 Apr 2011 06:45:26 +0000 (06:45 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sat, 16 Apr 2011 06:45:26 +0000 (06:45 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5476 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/changeset_test.rb

index 187bd7ab3bca5de503863ab68aa5d8cef125996b..e6bcb0e3504db35005041e2e1a47b4f0acf6cef1 100644 (file)
@@ -322,6 +322,35 @@ class ChangesetTest < ActiveSupport::TestCase
     assert_equal s4, c.comments
   end
 
+  def test_invalid_utf8_sequences_in_paths_should_be_replaced
+      proj = Project.find(3)
+      str1 = "Texte encod\xe9 en ISO-8859-1"
+      str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e"
+      str1.force_encoding("UTF-8") if str1.respond_to?(:force_encoding)
+      str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding)
+      r = Repository::Bazaar.create!(
+            :project => proj,
+            :url => '/tmp/test/bazaar',
+            :log_encoding => 'UTF-8' )
+      assert r
+      cs = Changeset.new(
+               :repository   => r,
+               :committed_on => Time.now,
+               :revision     => '123',
+               :scmid        => '12345',
+               :comments     => "test")
+      assert( cs.save )
+      ch = Change.new(
+                  :changeset     => cs,
+                  :action        => "A",
+                  :path          => str1,
+                  :from_path     => str2,
+                  :from_revision => "345")
+      assert( ch.save )
+      assert_equal "Texte encod? en ISO-8859-1", ch.path
+      assert_equal "?a?b?c?d?e", ch.from_path
+  end
+
   def test_comments_nil
     proj = Project.find(3)
     r = Repository::Bazaar.create!(