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