]> source.dussan.org Git - redmine.git/commitdiff
scm: git: add latest changesets test in unit model test (#5357).
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 8 Mar 2011 06:50:05 +0000 (06:50 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 8 Mar 2011 06:50:05 +0000 (06:50 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5052 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/repository_git_test.rb

index 4c9a244774cc31f5e7cb398ddcc4bb12a8e158eb..054f676a89cd76714f7f07e4892d14e6156117e0 100644 (file)
@@ -81,6 +81,45 @@ class RepositoryGitTest < ActiveSupport::TestCase
       assert_equal 20, @repository.changesets.count
     end
 
+    def test_latest_changesets
+      @repository.fetch_changesets
+      @repository.reload
+      # with limit
+      changesets = @repository.latest_changesets('', nil, 2)
+      assert_equal 2, changesets.size
+
+      # with path
+      changesets = @repository.latest_changesets('images', nil)
+      assert_equal [
+              'deff712f05a90d96edbd70facc47d944be5897e3',
+              '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
+              '7234cb2750b63f47bff735edc50a1c0a433c2518',
+          ], changesets.collect(&:revision)
+
+      changesets = @repository.latest_changesets('README', nil)
+      assert_equal [
+              '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf',
+              '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8',
+              '713f4944648826f558cf548222f813dabe7cbb04',
+              '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
+              '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
+              '7234cb2750b63f47bff735edc50a1c0a433c2518',
+          ], changesets.collect(&:revision)
+
+      # with path and revision
+      changesets = @repository.latest_changesets('images', '899a15dba')
+      assert_equal [
+              '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
+              '7234cb2750b63f47bff735edc50a1c0a433c2518',
+          ], changesets.collect(&:revision)
+
+      changesets = @repository.latest_changesets('README', '899a15dba')
+      assert_equal [
+              '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
+              '7234cb2750b63f47bff735edc50a1c0a433c2518',
+          ], changesets.collect(&:revision)
+    end
+
     def test_find_changeset_by_name
       @repository.fetch_changesets
       @repository.reload