]> source.dussan.org Git - redmine.git/commitdiff
scm: git: add unit model test that revisions ordering is inconsistent in existing...
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 19 May 2011 02:17:19 +0000 (02:17 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 19 May 2011 02:17:19 +0000 (02:17 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5855 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/repository_git_test.rb

index e31205d6df6fcda3ea0d159cf486dbe1ffd6ae70..3df02311dba4f2f287a5793d61284627eb092409 100644 (file)
@@ -167,6 +167,50 @@ class RepositoryGitTest < ActiveSupport::TestCase
       assert_equal 1, @repository.extra_info["db_consistent"]["ordering"]
     end
 
+    def test_db_consistent_ordering_before_1_2
+      assert_nil @repository.extra_info
+      @repository.fetch_changesets
+      @repository.reload
+      assert_equal 21, @repository.changesets.count
+      assert_not_nil @repository.extra_info
+      @repository.write_attribute(:extra_info, nil)
+      @repository.save
+      assert_nil @repository.extra_info
+      assert_equal 21, @repository.changesets.count
+      @repository.fetch_changesets
+      @repository.reload
+      assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
+
+      del_revs = [
+          "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
+          "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
+          "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
+          "deff712f05a90d96edbd70facc47d944be5897e3",
+          "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
+          "7e61ac704deecde634b51e59daa8110435dcb3da",
+         ]
+      @repository.changesets.each do |rev|
+        rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
+      end
+      @repository.reload
+      cs1 = @repository.changesets
+      assert_equal 15, cs1.count
+      assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
+      h = @repository.extra_info.dup
+      h["branches"]["master"]["last_scmid"] =
+            "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
+      @repository.merge_extra_info(h)
+      @repository.save
+      @repository.reload
+      extra_info_db_1 = @repository.extra_info["branches"]
+      assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8",
+                    extra_info_db_1["master"]["last_scmid"]
+
+      @repository.fetch_changesets
+      assert_equal 21, @repository.changesets.count
+      assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
+    end
+
     def test_latest_changesets
       @repository.fetch_changesets
       @repository.reload