Mercurial > hg > soundsoftware-site
comparison test/unit/repository_cvs_test.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbb26bc654de |
children | 622f24f53b42 |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
19 require 'pp' | 19 require 'pp' |
20 class RepositoryCvsTest < ActiveSupport::TestCase | 20 class RepositoryCvsTest < ActiveSupport::TestCase |
21 fixtures :projects | 21 fixtures :projects |
22 | 22 |
23 include Redmine::I18n | |
24 | |
23 REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s | 25 REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s |
24 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | 26 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
25 # CVS module | 27 # CVS module |
26 MODULE_NAME = 'test' | 28 MODULE_NAME = 'test' |
27 CHANGESETS_NUM = 7 | 29 CHANGESETS_NUM = 7 |
33 :url => MODULE_NAME, | 35 :url => MODULE_NAME, |
34 :log_encoding => 'UTF-8') | 36 :log_encoding => 'UTF-8') |
35 assert @repository | 37 assert @repository |
36 end | 38 end |
37 | 39 |
40 def test_blank_module_error_message | |
41 set_language_if_valid 'en' | |
42 repo = Repository::Cvs.new( | |
43 :project => @project, | |
44 :identifier => 'test', | |
45 :log_encoding => 'UTF-8', | |
46 :root_url => REPOSITORY_PATH | |
47 ) | |
48 assert !repo.save | |
49 assert_include "Module can't be blank", | |
50 repo.errors.full_messages | |
51 end | |
52 | |
53 def test_blank_module_error_message_fr | |
54 set_language_if_valid 'fr' | |
55 str = "Module doit \xc3\xaatre renseign\xc3\xa9(e)" | |
56 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) | |
57 repo = Repository::Cvs.new( | |
58 :project => @project, | |
59 :identifier => 'test', | |
60 :log_encoding => 'UTF-8', | |
61 :path_encoding => '', | |
62 :url => '', | |
63 :root_url => REPOSITORY_PATH | |
64 ) | |
65 assert !repo.save | |
66 assert_include str, repo.errors.full_messages | |
67 end | |
68 | |
69 def test_blank_cvsroot_error_message | |
70 set_language_if_valid 'en' | |
71 repo = Repository::Cvs.new( | |
72 :project => @project, | |
73 :identifier => 'test', | |
74 :log_encoding => 'UTF-8', | |
75 :url => MODULE_NAME | |
76 ) | |
77 assert !repo.save | |
78 assert_include "CVSROOT can't be blank", | |
79 repo.errors.full_messages | |
80 end | |
81 | |
82 def test_blank_cvsroot_error_message_fr | |
83 set_language_if_valid 'fr' | |
84 str = "CVSROOT doit \xc3\xaatre renseign\xc3\xa9(e)" | |
85 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) | |
86 repo = Repository::Cvs.new( | |
87 :project => @project, | |
88 :identifier => 'test', | |
89 :log_encoding => 'UTF-8', | |
90 :path_encoding => '', | |
91 :url => MODULE_NAME, | |
92 :root_url => '' | |
93 ) | |
94 assert !repo.save | |
95 assert_include str, repo.errors.full_messages | |
96 end | |
97 | |
38 if File.directory?(REPOSITORY_PATH) | 98 if File.directory?(REPOSITORY_PATH) |
39 def test_fetch_changesets_from_scratch | 99 def test_fetch_changesets_from_scratch |
40 assert_equal 0, @repository.changesets.count | 100 assert_equal 0, @repository.changesets.count |
41 @repository.fetch_changesets | 101 @repository.fetch_changesets |
42 @project.reload | 102 @project.reload |
43 | 103 |
44 assert_equal CHANGESETS_NUM, @repository.changesets.count | 104 assert_equal CHANGESETS_NUM, @repository.changesets.count |
45 assert_equal 16, @repository.changes.count | 105 assert_equal 16, @repository.filechanges.count |
46 assert_not_nil @repository.changesets.find_by_comments('Two files changed') | 106 assert_not_nil @repository.changesets.find_by_comments('Two files changed') |
47 | 107 |
48 r2 = @repository.changesets.find_by_revision('2') | 108 r2 = @repository.changesets.find_by_revision('2') |
49 assert_equal 'v1-20071213-162510', r2.scmid | 109 assert_equal 'v1-20071213-162510', r2.scmid |
50 end | 110 end |
51 | 111 |
52 def test_fetch_changesets_incremental | 112 def test_fetch_changesets_incremental |
53 assert_equal 0, @repository.changesets.count | 113 assert_equal 0, @repository.changesets.count |
54 @repository.fetch_changesets | 114 @repository.fetch_changesets |
115 @project.reload | |
116 assert_equal CHANGESETS_NUM, @repository.changesets.count | |
117 | |
55 # Remove changesets with revision > 3 | 118 # Remove changesets with revision > 3 |
56 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} | 119 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} |
57 @repository.reload | 120 @project.reload |
58 assert_equal 3, @repository.changesets.count | 121 assert_equal 3, @repository.changesets.count |
59 assert_equal %w|3 2 1|, @repository.changesets.collect(&:revision) | 122 assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision) |
60 | 123 |
61 rev3_commit = @repository.changesets.find(:first, :order => 'committed_on DESC') | 124 rev3_commit = @repository.changesets.find(:first, :order => 'committed_on DESC') |
62 assert_equal '3', rev3_commit.revision | 125 assert_equal '3', rev3_commit.revision |
63 # 2007-12-14 01:27:22 +0900 | 126 # 2007-12-14 01:27:22 +0900 |
64 rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22) | 127 rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22) |
66 assert_equal rev3_committed_on, rev3_commit.committed_on | 129 assert_equal rev3_committed_on, rev3_commit.committed_on |
67 latest_rev = @repository.latest_changeset | 130 latest_rev = @repository.latest_changeset |
68 assert_equal rev3_committed_on, latest_rev.committed_on | 131 assert_equal rev3_committed_on, latest_rev.committed_on |
69 | 132 |
70 @repository.fetch_changesets | 133 @repository.fetch_changesets |
71 @repository.reload | 134 @project.reload |
72 assert_equal CHANGESETS_NUM, @repository.changesets.count | 135 assert_equal CHANGESETS_NUM, @repository.changesets.count |
73 | 136 assert_equal %w|7 6 5 4 3 2 1|, @repository.changesets.all.collect(&:revision) |
74 assert_equal %w|7 6 5 4 3 2 1|, @repository.changesets.collect(&:revision) | |
75 rev5_commit = @repository.changesets.find_by_revision('5') | 137 rev5_commit = @repository.changesets.find_by_revision('5') |
76 assert_equal 'HEAD-20071213-163001', rev5_commit.scmid | 138 assert_equal 'HEAD-20071213-163001', rev5_commit.scmid |
77 # 2007-12-14 01:30:01 +0900 | 139 # 2007-12-14 01:30:01 +0900 |
78 rev5_committed_on = Time.gm(2007, 12, 13, 16, 30, 1) | 140 rev5_committed_on = Time.gm(2007, 12, 13, 16, 30, 1) |
79 assert_equal rev5_committed_on, rev5_commit.committed_on | 141 assert_equal rev5_committed_on, rev5_commit.committed_on |
94 assert_equal 0, @repository.changesets.count | 156 assert_equal 0, @repository.changesets.count |
95 @repository.fetch_changesets | 157 @repository.fetch_changesets |
96 @project.reload | 158 @project.reload |
97 assert_equal CHANGESETS_NUM, @repository.changesets.count | 159 assert_equal CHANGESETS_NUM, @repository.changesets.count |
98 entries = @repository.entries('', '3') | 160 entries = @repository.entries('', '3') |
161 assert_kind_of Redmine::Scm::Adapters::Entries, entries | |
99 assert_equal 3, entries.size | 162 assert_equal 3, entries.size |
100 assert_equal entries[2].name, "README" | 163 assert_equal entries[2].name, "README" |
101 assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22) | 164 assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22) |
102 assert_equal entries[2].lastrev.identifier, '3' | 165 assert_equal entries[2].lastrev.identifier, '3' |
103 assert_equal entries[2].lastrev.revision, '3' | 166 assert_equal entries[2].lastrev.revision, '3' |