annotate .svn/pristine/bc/bc982db69a13b04b1b1a64088ae5e941fe3eac9c.svn-base @ 1327:287f201c2802 redmine-2.2-integration

Add italic
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 19 Jun 2013 20:56:22 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@909 3 #
Chris@909 4 # This program is free software; you can redistribute it and/or
Chris@909 5 # modify it under the terms of the GNU General Public License
Chris@909 6 # as published by the Free Software Foundation; either version 2
Chris@909 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@909 9 # This program is distributed in the hope that it will be useful,
Chris@909 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@909 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@909 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@909 14 # You should have received a copy of the GNU General Public License
Chris@909 15 # along with this program; if not, write to the Free Software
Chris@909 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@909 17
Chris@909 18 require File.expand_path('../../test_helper', __FILE__)
Chris@909 19
Chris@909 20 class RepositoryGitTest < ActiveSupport::TestCase
Chris@909 21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
Chris@909 22
Chris@909 23 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
Chris@909 24 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
Chris@909 25
Chris@909 26 NUM_REV = 21
Chris@909 27
Chris@909 28 FELIX_HEX = "Felix Sch\xC3\xA4fer"
Chris@909 29 CHAR_1_HEX = "\xc3\x9c"
Chris@909 30
Chris@909 31 ## Ruby uses ANSI api to fork a process on Windows.
Chris@909 32 ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem
Chris@909 33 ## and these are incompatible with ASCII.
Chris@909 34 # WINDOWS_PASS = Redmine::Platform.mswin?
Chris@909 35 WINDOWS_PASS = false
Chris@909 36
Chris@909 37 ## Git, Mercurial and CVS path encodings are binary.
Chris@909 38 ## Subversion supports URL encoding for path.
Chris@909 39 ## Redmine Mercurial adapter and extension use URL encoding.
Chris@909 40 ## Git accepts only binary path in command line parameter.
Chris@909 41 ## So, there is no way to use binary command line parameter in JRuby.
Chris@909 42 JRUBY_SKIP = (RUBY_PLATFORM == 'java')
Chris@909 43 JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
Chris@909 44
Chris@909 45 if File.directory?(REPOSITORY_PATH)
Chris@909 46 def setup
Chris@909 47 klass = Repository::Git
Chris@909 48 assert_equal "Git", klass.scm_name
Chris@909 49 assert klass.scm_adapter_class
Chris@909 50 assert_not_equal "", klass.scm_command
Chris@909 51 assert_equal true, klass.scm_available
Chris@909 52
Chris@909 53 @project = Project.find(3)
Chris@909 54 @repository = Repository::Git.create(
Chris@909 55 :project => @project,
Chris@909 56 :url => REPOSITORY_PATH,
Chris@909 57 :path_encoding => 'ISO-8859-1'
Chris@909 58 )
Chris@909 59 assert @repository
Chris@909 60 @char_1 = CHAR_1_HEX.dup
Chris@909 61 if @char_1.respond_to?(:force_encoding)
Chris@909 62 @char_1.force_encoding('UTF-8')
Chris@909 63 end
Chris@909 64 end
Chris@909 65
Chris@909 66 def test_fetch_changesets_from_scratch
Chris@909 67 assert_nil @repository.extra_info
Chris@909 68
Chris@909 69 assert_equal 0, @repository.changesets.count
Chris@909 70 @repository.fetch_changesets
Chris@909 71 @project.reload
Chris@909 72
Chris@909 73 assert_equal NUM_REV, @repository.changesets.count
Chris@909 74 assert_equal 33, @repository.changes.count
Chris@909 75
Chris@909 76 commit = @repository.changesets.find(:first, :order => 'committed_on ASC')
Chris@909 77 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
Chris@909 78 assert_equal "jsmith <jsmith@foo.bar>", commit.committer
Chris@909 79 assert_equal User.find_by_login('jsmith'), commit.user
Chris@909 80 # TODO: add a commit with commit time <> author time to the test repository
Chris@909 81 assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
Chris@909 82 assert_equal "2007-12-14".to_date, commit.commit_date
Chris@909 83 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision
Chris@909 84 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid
Chris@909 85 assert_equal 3, commit.changes.count
Chris@909 86 change = commit.changes.sort_by(&:path).first
Chris@909 87 assert_equal "README", change.path
Chris@909 88 assert_equal "A", change.action
Chris@909 89
Chris@909 90 assert_equal 4, @repository.extra_info["branches"].size
Chris@909 91 end
Chris@909 92
Chris@909 93 def test_fetch_changesets_incremental
Chris@909 94 assert_equal 0, @repository.changesets.count
Chris@909 95 @repository.fetch_changesets
Chris@909 96 @project.reload
Chris@909 97 assert_equal NUM_REV, @repository.changesets.count
Chris@909 98 assert_equal 33, @repository.changes.count
Chris@909 99 extra_info_db = @repository.extra_info["branches"]
Chris@909 100 assert_equal 4, extra_info_db.size
Chris@909 101 assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127",
Chris@909 102 extra_info_db["latin-1-path-encoding"]["last_scmid"]
Chris@909 103 assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
Chris@909 104 extra_info_db["master"]["last_scmid"]
Chris@909 105
Chris@909 106 del_revs = [
Chris@909 107 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
Chris@909 108 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
Chris@909 109 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
Chris@909 110 "deff712f05a90d96edbd70facc47d944be5897e3",
Chris@909 111 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
Chris@909 112 "7e61ac704deecde634b51e59daa8110435dcb3da",
Chris@909 113 ]
Chris@909 114 @repository.changesets.each do |rev|
Chris@909 115 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
Chris@909 116 end
Chris@909 117 @project.reload
Chris@909 118 cs1 = @repository.changesets
Chris@909 119 assert_equal 15, cs1.count
Chris@909 120 h = @repository.extra_info.dup
Chris@909 121 h["branches"]["master"]["last_scmid"] =
Chris@909 122 "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
Chris@909 123 @repository.merge_extra_info(h)
Chris@909 124 @repository.save
Chris@909 125 @project.reload
Chris@909 126 extra_info_db_1 = @repository.extra_info["branches"]
Chris@909 127 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8",
Chris@909 128 extra_info_db_1["master"]["last_scmid"]
Chris@909 129
Chris@909 130 @repository.fetch_changesets
Chris@909 131 @project.reload
Chris@909 132 assert_equal NUM_REV, @repository.changesets.count
Chris@909 133 end
Chris@909 134
Chris@909 135 def test_fetch_changesets_invalid_rev
Chris@909 136 assert_equal 0, @repository.changesets.count
Chris@909 137 @repository.fetch_changesets
Chris@909 138 @project.reload
Chris@909 139 assert_equal NUM_REV, @repository.changesets.count
Chris@909 140 extra_info_db = @repository.extra_info["branches"]
Chris@909 141 assert_equal 4, extra_info_db.size
Chris@909 142 assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127",
Chris@909 143 extra_info_db["latin-1-path-encoding"]["last_scmid"]
Chris@909 144 assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
Chris@909 145 extra_info_db["master"]["last_scmid"]
Chris@909 146
Chris@909 147 del_revs = [
Chris@909 148 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
Chris@909 149 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
Chris@909 150 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
Chris@909 151 "deff712f05a90d96edbd70facc47d944be5897e3",
Chris@909 152 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
Chris@909 153 "7e61ac704deecde634b51e59daa8110435dcb3da",
Chris@909 154 ]
Chris@909 155 @repository.changesets.each do |rev|
Chris@909 156 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
Chris@909 157 end
Chris@909 158 @project.reload
Chris@909 159 cs1 = @repository.changesets
Chris@909 160 assert_equal 15, cs1.count
Chris@909 161 h = @repository.extra_info.dup
Chris@909 162 h["branches"]["master"]["last_scmid"] =
Chris@909 163 "abcd1234efgh"
Chris@909 164 @repository.merge_extra_info(h)
Chris@909 165 @repository.save
Chris@909 166 @project.reload
Chris@909 167 extra_info_db_1 = @repository.extra_info["branches"]
Chris@909 168 assert_equal "abcd1234efgh",
Chris@909 169 extra_info_db_1["master"]["last_scmid"]
Chris@909 170
Chris@909 171 @repository.fetch_changesets
Chris@909 172 @project.reload
Chris@909 173 assert_equal 15, @repository.changesets.count
Chris@909 174 end
Chris@909 175
Chris@909 176 def test_parents
Chris@909 177 assert_equal 0, @repository.changesets.count
Chris@909 178 @repository.fetch_changesets
Chris@909 179 @project.reload
Chris@909 180 assert_equal NUM_REV, @repository.changesets.count
Chris@909 181 r1 = @repository.find_changeset_by_name("7234cb2750b63")
Chris@909 182 assert_equal [], r1.parents
Chris@909 183 r2 = @repository.find_changeset_by_name("899a15dba03a3")
Chris@909 184 assert_equal 1, r2.parents.length
Chris@909 185 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518",
Chris@909 186 r2.parents[0].identifier
Chris@909 187 r3 = @repository.find_changeset_by_name("32ae898b720c2")
Chris@909 188 assert_equal 2, r3.parents.length
Chris@909 189 r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort
Chris@909 190 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", r4[0]
Chris@909 191 assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", r4[1]
Chris@909 192 end
Chris@909 193
Chris@909 194 def test_db_consistent_ordering_init
Chris@909 195 assert_nil @repository.extra_info
Chris@909 196 assert_equal 0, @repository.changesets.count
Chris@909 197 @repository.fetch_changesets
Chris@909 198 @project.reload
Chris@909 199 assert_equal 1, @repository.extra_info["db_consistent"]["ordering"]
Chris@909 200 end
Chris@909 201
Chris@909 202 def test_db_consistent_ordering_before_1_2
Chris@909 203 assert_nil @repository.extra_info
Chris@909 204 assert_equal 0, @repository.changesets.count
Chris@909 205 @repository.fetch_changesets
Chris@909 206 @project.reload
Chris@909 207 assert_equal NUM_REV, @repository.changesets.count
Chris@909 208 assert_not_nil @repository.extra_info
Chris@909 209 @repository.write_attribute(:extra_info, nil)
Chris@909 210 @repository.save
Chris@909 211 assert_nil @repository.extra_info
Chris@909 212 assert_equal NUM_REV, @repository.changesets.count
Chris@909 213 @repository.fetch_changesets
Chris@909 214 @project.reload
Chris@909 215 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
Chris@909 216
Chris@909 217 del_revs = [
Chris@909 218 "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c",
Chris@909 219 "ed5bb786bbda2dee66a2d50faf51429dbc043a7b",
Chris@909 220 "4f26664364207fa8b1af9f8722647ab2d4ac5d43",
Chris@909 221 "deff712f05a90d96edbd70facc47d944be5897e3",
Chris@909 222 "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf",
Chris@909 223 "7e61ac704deecde634b51e59daa8110435dcb3da",
Chris@909 224 ]
Chris@909 225 @repository.changesets.each do |rev|
Chris@909 226 rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s }
Chris@909 227 end
Chris@909 228 @project.reload
Chris@909 229 cs1 = @repository.changesets
Chris@909 230 assert_equal 15, cs1.count
Chris@909 231 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
Chris@909 232 h = @repository.extra_info.dup
Chris@909 233 h["branches"]["master"]["last_scmid"] =
Chris@909 234 "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8"
Chris@909 235 @repository.merge_extra_info(h)
Chris@909 236 @repository.save
Chris@909 237 @project.reload
Chris@909 238 extra_info_db_1 = @repository.extra_info["branches"]
Chris@909 239 assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8",
Chris@909 240 extra_info_db_1["master"]["last_scmid"]
Chris@909 241
Chris@909 242 @repository.fetch_changesets
Chris@909 243 assert_equal NUM_REV, @repository.changesets.count
Chris@909 244 assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
Chris@909 245 end
Chris@909 246
Chris@909 247 def test_latest_changesets
Chris@909 248 assert_equal 0, @repository.changesets.count
Chris@909 249 @repository.fetch_changesets
Chris@909 250 @project.reload
Chris@909 251 assert_equal NUM_REV, @repository.changesets.count
Chris@909 252 # with limit
Chris@909 253 changesets = @repository.latest_changesets('', nil, 2)
Chris@909 254 assert_equal 2, changesets.size
Chris@909 255
Chris@909 256 # with path
Chris@909 257 changesets = @repository.latest_changesets('images', nil)
Chris@909 258 assert_equal [
Chris@909 259 'deff712f05a90d96edbd70facc47d944be5897e3',
Chris@909 260 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 261 '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 262 ], changesets.collect(&:revision)
Chris@909 263
Chris@909 264 changesets = @repository.latest_changesets('README', nil)
Chris@909 265 assert_equal [
Chris@909 266 '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf',
Chris@909 267 '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8',
Chris@909 268 '713f4944648826f558cf548222f813dabe7cbb04',
Chris@909 269 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
Chris@909 270 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 271 '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 272 ], changesets.collect(&:revision)
Chris@909 273
Chris@909 274 # with path, revision and limit
Chris@909 275 changesets = @repository.latest_changesets('images', '899a15dba')
Chris@909 276 assert_equal [
Chris@909 277 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 278 '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 279 ], changesets.collect(&:revision)
Chris@909 280
Chris@909 281 changesets = @repository.latest_changesets('images', '899a15dba', 1)
Chris@909 282 assert_equal [
Chris@909 283 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 284 ], changesets.collect(&:revision)
Chris@909 285
Chris@909 286 changesets = @repository.latest_changesets('README', '899a15dba')
Chris@909 287 assert_equal [
Chris@909 288 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 289 '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 290 ], changesets.collect(&:revision)
Chris@909 291
Chris@909 292 changesets = @repository.latest_changesets('README', '899a15dba', 1)
Chris@909 293 assert_equal [
Chris@909 294 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 295 ], changesets.collect(&:revision)
Chris@909 296
Chris@909 297 # with path, tag and limit
Chris@909 298 changesets = @repository.latest_changesets('images', 'tag01.annotated')
Chris@909 299 assert_equal [
Chris@909 300 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 301 '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 302 ], changesets.collect(&:revision)
Chris@909 303
Chris@909 304 changesets = @repository.latest_changesets('images', 'tag01.annotated', 1)
Chris@909 305 assert_equal [
Chris@909 306 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 307 ], changesets.collect(&:revision)
Chris@909 308
Chris@909 309 changesets = @repository.latest_changesets('README', 'tag01.annotated')
Chris@909 310 assert_equal [
Chris@909 311 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 312 '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 313 ], changesets.collect(&:revision)
Chris@909 314
Chris@909 315 changesets = @repository.latest_changesets('README', 'tag01.annotated', 1)
Chris@909 316 assert_equal [
Chris@909 317 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 318 ], changesets.collect(&:revision)
Chris@909 319
Chris@909 320 # with path, branch and limit
Chris@909 321 changesets = @repository.latest_changesets('images', 'test_branch')
Chris@909 322 assert_equal [
Chris@909 323 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 324 '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 325 ], changesets.collect(&:revision)
Chris@909 326
Chris@909 327 changesets = @repository.latest_changesets('images', 'test_branch', 1)
Chris@909 328 assert_equal [
Chris@909 329 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 330 ], changesets.collect(&:revision)
Chris@909 331
Chris@909 332 changesets = @repository.latest_changesets('README', 'test_branch')
Chris@909 333 assert_equal [
Chris@909 334 '713f4944648826f558cf548222f813dabe7cbb04',
Chris@909 335 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
Chris@909 336 '899a15dba03a3b350b89c3f537e4bbe02a03cdc9',
Chris@909 337 '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 338 ], changesets.collect(&:revision)
Chris@909 339
Chris@909 340 changesets = @repository.latest_changesets('README', 'test_branch', 2)
Chris@909 341 assert_equal [
Chris@909 342 '713f4944648826f558cf548222f813dabe7cbb04',
Chris@909 343 '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
Chris@909 344 ], changesets.collect(&:revision)
Chris@909 345
Chris@909 346 if JRUBY_SKIP
Chris@909 347 puts JRUBY_SKIP_STR
Chris@909 348 else
Chris@909 349 # latin-1 encoding path
Chris@909 350 changesets = @repository.latest_changesets(
Chris@909 351 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89')
Chris@909 352 assert_equal [
Chris@909 353 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
Chris@909 354 '4fc55c43bf3d3dc2efb66145365ddc17639ce81e',
Chris@909 355 ], changesets.collect(&:revision)
Chris@909 356
Chris@909 357 changesets = @repository.latest_changesets(
Chris@909 358 "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1)
Chris@909 359 assert_equal [
Chris@909 360 '64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
Chris@909 361 ], changesets.collect(&:revision)
Chris@909 362 end
Chris@909 363 end
Chris@909 364
Chris@909 365 def test_latest_changesets_latin_1_dir
Chris@909 366 if WINDOWS_PASS
Chris@909 367 #
Chris@909 368 elsif JRUBY_SKIP
Chris@909 369 puts JRUBY_SKIP_STR
Chris@909 370 else
Chris@909 371 assert_equal 0, @repository.changesets.count
Chris@909 372 @repository.fetch_changesets
Chris@909 373 @project.reload
Chris@909 374 assert_equal NUM_REV, @repository.changesets.count
Chris@909 375 changesets = @repository.latest_changesets(
Chris@909 376 "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed')
Chris@909 377 assert_equal [
Chris@909 378 '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127',
Chris@909 379 ], changesets.collect(&:revision)
Chris@909 380 end
Chris@909 381 end
Chris@909 382
Chris@909 383 def test_find_changeset_by_name
Chris@909 384 assert_equal 0, @repository.changesets.count
Chris@909 385 @repository.fetch_changesets
Chris@909 386 @project.reload
Chris@909 387 assert_equal NUM_REV, @repository.changesets.count
Chris@909 388 ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r|
Chris@909 389 assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@909 390 @repository.find_changeset_by_name(r).revision
Chris@909 391 end
Chris@909 392 end
Chris@909 393
Chris@909 394 def test_find_changeset_by_empty_name
Chris@909 395 assert_equal 0, @repository.changesets.count
Chris@909 396 @repository.fetch_changesets
Chris@909 397 @project.reload
Chris@909 398 assert_equal NUM_REV, @repository.changesets.count
Chris@909 399 ['', ' ', nil].each do |r|
Chris@909 400 assert_nil @repository.find_changeset_by_name(r)
Chris@909 401 end
Chris@909 402 end
Chris@909 403
Chris@909 404 def test_identifier
Chris@909 405 assert_equal 0, @repository.changesets.count
Chris@909 406 @repository.fetch_changesets
Chris@909 407 @project.reload
Chris@909 408 assert_equal NUM_REV, @repository.changesets.count
Chris@909 409 c = @repository.changesets.find_by_revision(
Chris@909 410 '7234cb2750b63f47bff735edc50a1c0a433c2518')
Chris@909 411 assert_equal c.scmid, c.identifier
Chris@909 412 end
Chris@909 413
Chris@909 414 def test_format_identifier
Chris@909 415 assert_equal 0, @repository.changesets.count
Chris@909 416 @repository.fetch_changesets
Chris@909 417 @project.reload
Chris@909 418 assert_equal NUM_REV, @repository.changesets.count
Chris@909 419 c = @repository.changesets.find_by_revision(
Chris@909 420 '7234cb2750b63f47bff735edc50a1c0a433c2518')
Chris@909 421 assert_equal '7234cb27', c.format_identifier
Chris@909 422 end
Chris@909 423
Chris@909 424 def test_activities
Chris@909 425 c = Changeset.new(:repository => @repository,
Chris@909 426 :committed_on => Time.now,
Chris@909 427 :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
Chris@909 428 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
Chris@909 429 :comments => 'test')
Chris@909 430 assert c.event_title.include?('abc7234c:')
Chris@909 431 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev]
Chris@909 432 end
Chris@909 433
Chris@909 434 def test_log_utf8
Chris@909 435 assert_equal 0, @repository.changesets.count
Chris@909 436 @repository.fetch_changesets
Chris@909 437 @project.reload
Chris@909 438 assert_equal NUM_REV, @repository.changesets.count
Chris@909 439 str_felix_hex = FELIX_HEX.dup
Chris@909 440 if str_felix_hex.respond_to?(:force_encoding)
Chris@909 441 str_felix_hex.force_encoding('UTF-8')
Chris@909 442 end
Chris@909 443 c = @repository.changesets.find_by_revision(
Chris@909 444 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b')
Chris@909 445 assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer
Chris@909 446 end
Chris@909 447
Chris@909 448 def test_previous
Chris@909 449 assert_equal 0, @repository.changesets.count
Chris@909 450 @repository.fetch_changesets
Chris@909 451 @project.reload
Chris@909 452 assert_equal NUM_REV, @repository.changesets.count
Chris@909 453 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
Chris@909 454 changeset = @repository.find_changeset_by_name(r1)
Chris@909 455 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
Chris@909 456 assert_equal @repository.find_changeset_by_name(r2), changeset.previous
Chris@909 457 end
Chris@909 458 end
Chris@909 459 end
Chris@909 460
Chris@909 461 def test_previous_nil
Chris@909 462 assert_equal 0, @repository.changesets.count
Chris@909 463 @repository.fetch_changesets
Chris@909 464 @project.reload
Chris@909 465 assert_equal NUM_REV, @repository.changesets.count
Chris@909 466 %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb2|.each do |r1|
Chris@909 467 changeset = @repository.find_changeset_by_name(r1)
Chris@909 468 assert_nil changeset.previous
Chris@909 469 end
Chris@909 470 end
Chris@909 471
Chris@909 472 def test_next
Chris@909 473 assert_equal 0, @repository.changesets.count
Chris@909 474 @repository.fetch_changesets
Chris@909 475 @project.reload
Chris@909 476 assert_equal NUM_REV, @repository.changesets.count
Chris@909 477 %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2|
Chris@909 478 changeset = @repository.find_changeset_by_name(r2)
Chris@909 479 %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1|
Chris@909 480 assert_equal @repository.find_changeset_by_name(r1), changeset.next
Chris@909 481 end
Chris@909 482 end
Chris@909 483 end
Chris@909 484
Chris@909 485 def test_next_nil
Chris@909 486 assert_equal 0, @repository.changesets.count
Chris@909 487 @repository.fetch_changesets
Chris@909 488 @project.reload
Chris@909 489 assert_equal NUM_REV, @repository.changesets.count
Chris@909 490 %w|67e7792ce20ccae2e4bb73eed09bb397819c8834 67e7792ce20cca|.each do |r1|
Chris@909 491 changeset = @repository.find_changeset_by_name(r1)
Chris@909 492 assert_nil changeset.next
Chris@909 493 end
Chris@909 494 end
Chris@909 495 else
Chris@909 496 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
Chris@909 497 def test_fake; assert true end
Chris@909 498 end
Chris@909 499 end