]> source.dussan.org Git - redmine.git/commitdiff
scm: mercurial: add some tests at unit and functional test.
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 5 Jan 2011 15:03:16 +0000 (15:03 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 5 Jan 2011 15:03:16 +0000 (15:03 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4635 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/functional/repositories_mercurial_controller_test.rb
test/unit/repository_mercurial_test.rb

index 492c6558edbcae5a2df5607f1a24b7f400a69f5f..b577da87e427343b02ff43d09b0272b53c3a38c6 100644 (file)
@@ -74,7 +74,21 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
       assert_not_nil assigns(:entries)
       assert_equal ['delete.png'], assigns(:entries).collect(&:name)
     end
-    
+
+    def test_show_directory_sql_escape_percent
+      get :show, :id => 3, :path => ['sql_escape', 'percent%dir'], :rev => 13
+      assert_response :success
+      assert_template 'show'
+
+      assert_not_nil assigns(:entries)
+      assert_equal ['percent%file1.txt', 'percentfile1.txt'], assigns(:entries).collect(&:name)
+      changesets = assigns(:changesets)
+
+      ## This is not yet implemented.
+      # assert_not_nil changesets
+      # assert_equal %w(13 11 10 9), changesets.collect(&:revision)
+    end
+
     def test_changes
       get :changes, :id => 3, :path => ['images', 'edit.png']
       assert_response :success
index 741b455e51ddbcf1494691c397588f08ba101213..481a223b827a02eac14648a8a1cc171d09e8f332 100644 (file)
@@ -80,6 +80,22 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
       assert c0.revision.to_i > c1.revision.to_i
       assert c0.committed_on  < c1.committed_on
     end
+
+    def test_latest_changesets
+      @repository.fetch_changesets
+      @repository.reload
+
+      # with_limit
+      changesets = @repository.latest_changesets('', nil, 2)
+      assert_equal @repository.latest_changesets('', nil)[0, 2], changesets
+
+      # with_filepath
+      changesets = @repository.latest_changesets('/sql_escape/percent%dir/percent%file1.txt', nil)
+      assert_equal %w|11 10 9|, changesets.collect(&:revision)
+
+      changesets = @repository.latest_changesets('/sql_escape/underscore_dir/understrike_file.txt', nil)
+      assert_equal %w|12 9|, changesets.collect(&:revision)
+    end
   else
     puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!"
     def test_fake; assert true end