annotate .svn/pristine/a5/a5c1742116d103566daddf0042d6bf11b7196800.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

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