@@ -1,306 +1,307 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class RepositoryBazaarTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects |
|
22 | 22 | |
|
23 | 23 | include Redmine::I18n |
|
24 | 24 | |
|
25 | 25 | REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s |
|
26 | 26 | REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk") |
|
27 | 27 | NUM_REV = 4 |
|
28 | 28 | |
|
29 | 29 | REPOSITORY_PATH_NON_ASCII = Rails.root.join(REPOSITORY_PATH + '/' + 'non_ascii').to_s |
|
30 | 30 | |
|
31 | 31 | # Bazaar core does not support xml output such as Subversion and Mercurial. |
|
32 | 32 | # "bzr" command output and command line parameter depend on locale. |
|
33 | 33 | # So, non ASCII path tests cannot run independent locale. |
|
34 | 34 | # |
|
35 | 35 | # If you want to run Bazaar non ASCII path tests on Linux *Ruby 1.9*, |
|
36 | 36 | # you need to set locale character set "ISO-8859-1". |
|
37 | 37 | # E.g. "LANG=en_US.ISO-8859-1". |
|
38 | 38 | # On Linux other platforms (e.g. Ruby 1.8, JRuby), |
|
39 | 39 | # you need to set "RUN_LATIN1_OUTPUT_TEST = true" manually. |
|
40 | 40 | # |
|
41 | 41 | # On Windows, because it is too hard to change system locale, |
|
42 | 42 | # you cannot run Bazaar non ASCII path tests. |
|
43 | 43 | # |
|
44 | 44 | RUN_LATIN1_OUTPUT_TEST = (RUBY_PLATFORM != 'java' && |
|
45 | 45 | REPOSITORY_PATH.respond_to?(:force_encoding) && |
|
46 | 46 | Encoding.locale_charmap == "ISO-8859-1") |
|
47 | 47 | |
|
48 | 48 | CHAR_1_UTF8_HEX = "\xc3\x9c" |
|
49 | 49 | CHAR_1_LATIN1_HEX = "\xdc" |
|
50 | 50 | |
|
51 | 51 | def setup |
|
52 | 52 | @project = Project.find(3) |
|
53 | 53 | @repository = Repository::Bazaar.create( |
|
54 | 54 | :project => @project, :url => REPOSITORY_PATH_TRUNK, |
|
55 | 55 | :log_encoding => 'UTF-8') |
|
56 | 56 | assert @repository |
|
57 | 57 | @char_1_utf8 = CHAR_1_UTF8_HEX.dup |
|
58 | 58 | @char_1_ascii8bit = CHAR_1_LATIN1_HEX.dup |
|
59 | 59 | if @char_1_utf8.respond_to?(:force_encoding) |
|
60 | 60 | @char_1_utf8.force_encoding('UTF-8') |
|
61 | 61 | @char_1_ascii8bit.force_encoding('ASCII-8BIT') |
|
62 | 62 | end |
|
63 | 63 | end |
|
64 | 64 | |
|
65 | 65 | def test_blank_path_to_repository_error_message |
|
66 | 66 | set_language_if_valid 'en' |
|
67 | 67 | repo = Repository::Bazaar.new( |
|
68 | 68 | :project => @project, |
|
69 | 69 | :identifier => 'test', |
|
70 | 70 | :log_encoding => 'UTF-8' |
|
71 | 71 | ) |
|
72 | 72 | assert !repo.save |
|
73 | 73 | assert_include "Path to repository can't be blank", |
|
74 | 74 | repo.errors.full_messages |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | def test_blank_path_to_repository_error_message_fr |
|
78 | 78 | set_language_if_valid 'fr' |
|
79 | 79 | str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)" |
|
80 | 80 | str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) |
|
81 | 81 | repo = Repository::Bazaar.new( |
|
82 | 82 | :project => @project, |
|
83 | 83 | :url => "", |
|
84 | 84 | :identifier => 'test', |
|
85 | 85 | :log_encoding => 'UTF-8' |
|
86 | 86 | ) |
|
87 | 87 | assert !repo.save |
|
88 | 88 | assert_include str, repo.errors.full_messages |
|
89 | 89 | end |
|
90 | 90 | |
|
91 | 91 | if File.directory?(REPOSITORY_PATH_TRUNK) |
|
92 | 92 | def test_fetch_changesets_from_scratch |
|
93 | 93 | assert_equal 0, @repository.changesets.count |
|
94 | 94 | @repository.fetch_changesets |
|
95 | 95 | @project.reload |
|
96 | 96 | |
|
97 | 97 | assert_equal NUM_REV, @repository.changesets.count |
|
98 | 98 | assert_equal 9, @repository.filechanges.count |
|
99 | 99 | assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def test_fetch_changesets_incremental |
|
103 | 103 | assert_equal 0, @repository.changesets.count |
|
104 | 104 | @repository.fetch_changesets |
|
105 | 105 | @project.reload |
|
106 | 106 | assert_equal NUM_REV, @repository.changesets.count |
|
107 | 107 | # Remove changesets with revision > 5 |
|
108 | 108 | @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 2} |
|
109 | 109 | @project.reload |
|
110 | @repository.reload | |
|
110 | 111 | assert_equal 2, @repository.changesets.count |
|
111 | 112 | |
|
112 | 113 | @repository.fetch_changesets |
|
113 | 114 | @project.reload |
|
114 | 115 | assert_equal NUM_REV, @repository.changesets.count |
|
115 | 116 | end |
|
116 | 117 | |
|
117 | 118 | def test_entries |
|
118 | 119 | entries = @repository.entries |
|
119 | 120 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
120 | 121 | assert_equal 2, entries.size |
|
121 | 122 | |
|
122 | 123 | assert_equal 'dir', entries[0].kind |
|
123 | 124 | assert_equal 'directory', entries[0].name |
|
124 | 125 | assert_equal 'directory', entries[0].path |
|
125 | 126 | |
|
126 | 127 | assert_equal 'file', entries[1].kind |
|
127 | 128 | assert_equal 'doc-mkdir.txt', entries[1].name |
|
128 | 129 | assert_equal 'doc-mkdir.txt', entries[1].path |
|
129 | 130 | end |
|
130 | 131 | |
|
131 | 132 | def test_entries_in_subdirectory |
|
132 | 133 | entries = @repository.entries('directory') |
|
133 | 134 | assert_equal 3, entries.size |
|
134 | 135 | |
|
135 | 136 | assert_equal 'file', entries.last.kind |
|
136 | 137 | assert_equal 'edit.png', entries.last.name |
|
137 | 138 | assert_equal 'directory/edit.png', entries.last.path |
|
138 | 139 | end |
|
139 | 140 | |
|
140 | 141 | def test_previous |
|
141 | 142 | assert_equal 0, @repository.changesets.count |
|
142 | 143 | @repository.fetch_changesets |
|
143 | 144 | @project.reload |
|
144 | 145 | assert_equal NUM_REV, @repository.changesets.count |
|
145 | 146 | changeset = @repository.find_changeset_by_name('3') |
|
146 | 147 | assert_equal @repository.find_changeset_by_name('2'), changeset.previous |
|
147 | 148 | end |
|
148 | 149 | |
|
149 | 150 | def test_previous_nil |
|
150 | 151 | assert_equal 0, @repository.changesets.count |
|
151 | 152 | @repository.fetch_changesets |
|
152 | 153 | @project.reload |
|
153 | 154 | assert_equal NUM_REV, @repository.changesets.count |
|
154 | 155 | changeset = @repository.find_changeset_by_name('1') |
|
155 | 156 | assert_nil changeset.previous |
|
156 | 157 | end |
|
157 | 158 | |
|
158 | 159 | def test_next |
|
159 | 160 | assert_equal 0, @repository.changesets.count |
|
160 | 161 | @repository.fetch_changesets |
|
161 | 162 | @project.reload |
|
162 | 163 | assert_equal NUM_REV, @repository.changesets.count |
|
163 | 164 | changeset = @repository.find_changeset_by_name('2') |
|
164 | 165 | assert_equal @repository.find_changeset_by_name('3'), changeset.next |
|
165 | 166 | end |
|
166 | 167 | |
|
167 | 168 | def test_next_nil |
|
168 | 169 | assert_equal 0, @repository.changesets.count |
|
169 | 170 | @repository.fetch_changesets |
|
170 | 171 | @project.reload |
|
171 | 172 | assert_equal NUM_REV, @repository.changesets.count |
|
172 | 173 | changeset = @repository.find_changeset_by_name('4') |
|
173 | 174 | assert_nil changeset.next |
|
174 | 175 | end |
|
175 | 176 | |
|
176 | 177 | if File.directory?(REPOSITORY_PATH_NON_ASCII) && RUN_LATIN1_OUTPUT_TEST |
|
177 | 178 | def test_cat_latin1_path |
|
178 | 179 | latin1_repo = create_latin1_repo |
|
179 | 180 | buf = latin1_repo.cat( |
|
180 | 181 | "test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-2.txt", 2) |
|
181 | 182 | assert buf |
|
182 | 183 | lines = buf.split("\n") |
|
183 | 184 | assert_equal 2, lines.length |
|
184 | 185 | assert_equal 'It is written in Python.', lines[1] |
|
185 | 186 | |
|
186 | 187 | buf = latin1_repo.cat( |
|
187 | 188 | "test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-1.txt", 2) |
|
188 | 189 | assert buf |
|
189 | 190 | lines = buf.split("\n") |
|
190 | 191 | assert_equal 1, lines.length |
|
191 | 192 | assert_equal "test-#{@char_1_ascii8bit}.txt", lines[0] |
|
192 | 193 | end |
|
193 | 194 | |
|
194 | 195 | def test_annotate_latin1_path |
|
195 | 196 | latin1_repo = create_latin1_repo |
|
196 | 197 | ann1 = latin1_repo.annotate( |
|
197 | 198 | "test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-2.txt", 2) |
|
198 | 199 | assert_equal 2, ann1.lines.size |
|
199 | 200 | assert_equal '2', ann1.revisions[0].identifier |
|
200 | 201 | assert_equal 'test00@', ann1.revisions[0].author |
|
201 | 202 | assert_equal 'It is written in Python.', ann1.lines[1] |
|
202 | 203 | ann2 = latin1_repo.annotate( |
|
203 | 204 | "test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-1.txt", 2) |
|
204 | 205 | assert_equal 1, ann2.lines.size |
|
205 | 206 | assert_equal '2', ann2.revisions[0].identifier |
|
206 | 207 | assert_equal 'test00@', ann2.revisions[0].author |
|
207 | 208 | assert_equal "test-#{@char_1_ascii8bit}.txt", ann2.lines[0] |
|
208 | 209 | end |
|
209 | 210 | |
|
210 | 211 | def test_diff_latin1_path |
|
211 | 212 | latin1_repo = create_latin1_repo |
|
212 | 213 | diff1 = latin1_repo.diff( |
|
213 | 214 | "test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-1.txt", 2, 1) |
|
214 | 215 | assert_equal 7, diff1.size |
|
215 | 216 | buf = diff1[5].gsub(/\r\n|\r|\n/, "") |
|
216 | 217 | assert_equal "+test-#{@char_1_ascii8bit}.txt", buf |
|
217 | 218 | end |
|
218 | 219 | |
|
219 | 220 | def test_entries_latin1_path |
|
220 | 221 | latin1_repo = create_latin1_repo |
|
221 | 222 | entries = latin1_repo.entries("test-#{@char_1_utf8}-dir", 2) |
|
222 | 223 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
223 | 224 | assert_equal 3, entries.size |
|
224 | 225 | assert_equal 'file', entries[1].kind |
|
225 | 226 | assert_equal "test-#{@char_1_utf8}-1.txt", entries[0].name |
|
226 | 227 | assert_equal "test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-1.txt", entries[0].path |
|
227 | 228 | end |
|
228 | 229 | |
|
229 | 230 | def test_entry_latin1_path |
|
230 | 231 | latin1_repo = create_latin1_repo |
|
231 | 232 | ["test-#{@char_1_utf8}-dir", |
|
232 | 233 | "/test-#{@char_1_utf8}-dir", |
|
233 | 234 | "/test-#{@char_1_utf8}-dir/" |
|
234 | 235 | ].each do |path| |
|
235 | 236 | entry = latin1_repo.entry(path, 2) |
|
236 | 237 | assert_equal "test-#{@char_1_utf8}-dir", entry.path |
|
237 | 238 | assert_equal "dir", entry.kind |
|
238 | 239 | end |
|
239 | 240 | ["test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-1.txt", |
|
240 | 241 | "/test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-1.txt" |
|
241 | 242 | ].each do |path| |
|
242 | 243 | entry = latin1_repo.entry(path, 2) |
|
243 | 244 | assert_equal "test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-1.txt", |
|
244 | 245 | entry.path |
|
245 | 246 | assert_equal "file", entry.kind |
|
246 | 247 | end |
|
247 | 248 | end |
|
248 | 249 | |
|
249 | 250 | def test_changeset_latin1_path |
|
250 | 251 | latin1_repo = create_latin1_repo |
|
251 | 252 | assert_equal 0, latin1_repo.changesets.count |
|
252 | 253 | latin1_repo.fetch_changesets |
|
253 | 254 | @project.reload |
|
254 | 255 | assert_equal 3, latin1_repo.changesets.count |
|
255 | 256 | |
|
256 | 257 | cs2 = latin1_repo.changesets.find_by_revision('2') |
|
257 | 258 | assert_not_nil cs2 |
|
258 | 259 | assert_equal "test-#{@char_1_utf8}", cs2.comments |
|
259 | 260 | c2 = cs2.filechanges.sort_by(&:path) |
|
260 | 261 | assert_equal 4, c2.size |
|
261 | 262 | assert_equal 'A', c2[0].action |
|
262 | 263 | assert_equal "/test-#{@char_1_utf8}-dir/", c2[0].path |
|
263 | 264 | assert_equal 'A', c2[1].action |
|
264 | 265 | assert_equal "/test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-1.txt", c2[1].path |
|
265 | 266 | assert_equal 'A', c2[2].action |
|
266 | 267 | assert_equal "/test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-2.txt", c2[2].path |
|
267 | 268 | assert_equal 'A', c2[3].action |
|
268 | 269 | assert_equal "/test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}.txt", c2[3].path |
|
269 | 270 | |
|
270 | 271 | cs3 = latin1_repo.changesets.find_by_revision('3') |
|
271 | 272 | assert_not_nil cs3 |
|
272 | 273 | assert_equal "modify, move and delete #{@char_1_utf8} files", cs3.comments |
|
273 | 274 | c3 = cs3.filechanges.sort_by(&:path) |
|
274 | 275 | assert_equal 3, c3.size |
|
275 | 276 | assert_equal 'M', c3[0].action |
|
276 | 277 | assert_equal "/test-#{@char_1_utf8}-1.txt", c3[0].path |
|
277 | 278 | assert_equal 'D', c3[1].action |
|
278 | 279 | assert_equal "/test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}-2.txt", c3[1].path |
|
279 | 280 | assert_equal 'M', c3[2].action |
|
280 | 281 | assert_equal "/test-#{@char_1_utf8}-dir/test-#{@char_1_utf8}.txt", c3[2].path |
|
281 | 282 | end |
|
282 | 283 | else |
|
283 | 284 | msg = "Bazaar non ASCII output test cannot run this environment." + "\n" |
|
284 | 285 | if msg.respond_to?(:force_encoding) |
|
285 | 286 | msg += "Encoding.locale_charmap: " + Encoding.locale_charmap + "\n" |
|
286 | 287 | end |
|
287 | 288 | puts msg |
|
288 | 289 | end |
|
289 | 290 | |
|
290 | 291 | private |
|
291 | 292 | |
|
292 | 293 | def create_latin1_repo |
|
293 | 294 | repo = Repository::Bazaar.create( |
|
294 | 295 | :project => @project, |
|
295 | 296 | :identifier => 'latin1', |
|
296 | 297 | :url => REPOSITORY_PATH_NON_ASCII, |
|
297 | 298 | :log_encoding => 'ISO-8859-1' |
|
298 | 299 | ) |
|
299 | 300 | assert repo |
|
300 | 301 | repo |
|
301 | 302 | end |
|
302 | 303 | else |
|
303 | 304 | puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!" |
|
304 | 305 | def test_fake; assert true end |
|
305 | 306 | end |
|
306 | 307 | end |
@@ -1,241 +1,242 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | require 'pp' |
|
20 | 20 | class RepositoryCvsTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects |
|
22 | 22 | |
|
23 | 23 | include Redmine::I18n |
|
24 | 24 | |
|
25 | 25 | REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s |
|
26 | 26 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
27 | 27 | # CVS module |
|
28 | 28 | MODULE_NAME = 'test' |
|
29 | 29 | CHANGESETS_NUM = 7 |
|
30 | 30 | |
|
31 | 31 | def setup |
|
32 | 32 | @project = Project.find(3) |
|
33 | 33 | @repository = Repository::Cvs.create(:project => @project, |
|
34 | 34 | :root_url => REPOSITORY_PATH, |
|
35 | 35 | :url => MODULE_NAME, |
|
36 | 36 | :log_encoding => 'UTF-8') |
|
37 | 37 | assert @repository |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | 40 | def test_blank_module_error_message |
|
41 | 41 | set_language_if_valid 'en' |
|
42 | 42 | repo = Repository::Cvs.new( |
|
43 | 43 | :project => @project, |
|
44 | 44 | :identifier => 'test', |
|
45 | 45 | :log_encoding => 'UTF-8', |
|
46 | 46 | :root_url => REPOSITORY_PATH |
|
47 | 47 | ) |
|
48 | 48 | assert !repo.save |
|
49 | 49 | assert_include "Module can't be blank", |
|
50 | 50 | repo.errors.full_messages |
|
51 | 51 | end |
|
52 | 52 | |
|
53 | 53 | def test_blank_module_error_message_fr |
|
54 | 54 | set_language_if_valid 'fr' |
|
55 | 55 | str = "Module doit \xc3\xaatre renseign\xc3\xa9(e)" |
|
56 | 56 | str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) |
|
57 | 57 | repo = Repository::Cvs.new( |
|
58 | 58 | :project => @project, |
|
59 | 59 | :identifier => 'test', |
|
60 | 60 | :log_encoding => 'UTF-8', |
|
61 | 61 | :path_encoding => '', |
|
62 | 62 | :url => '', |
|
63 | 63 | :root_url => REPOSITORY_PATH |
|
64 | 64 | ) |
|
65 | 65 | assert !repo.save |
|
66 | 66 | assert_include str, repo.errors.full_messages |
|
67 | 67 | end |
|
68 | 68 | |
|
69 | 69 | def test_blank_cvsroot_error_message |
|
70 | 70 | set_language_if_valid 'en' |
|
71 | 71 | repo = Repository::Cvs.new( |
|
72 | 72 | :project => @project, |
|
73 | 73 | :identifier => 'test', |
|
74 | 74 | :log_encoding => 'UTF-8', |
|
75 | 75 | :url => MODULE_NAME |
|
76 | 76 | ) |
|
77 | 77 | assert !repo.save |
|
78 | 78 | assert_include "CVSROOT can't be blank", |
|
79 | 79 | repo.errors.full_messages |
|
80 | 80 | end |
|
81 | 81 | |
|
82 | 82 | def test_blank_cvsroot_error_message_fr |
|
83 | 83 | set_language_if_valid 'fr' |
|
84 | 84 | str = "CVSROOT doit \xc3\xaatre renseign\xc3\xa9(e)" |
|
85 | 85 | str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) |
|
86 | 86 | repo = Repository::Cvs.new( |
|
87 | 87 | :project => @project, |
|
88 | 88 | :identifier => 'test', |
|
89 | 89 | :log_encoding => 'UTF-8', |
|
90 | 90 | :path_encoding => '', |
|
91 | 91 | :url => MODULE_NAME, |
|
92 | 92 | :root_url => '' |
|
93 | 93 | ) |
|
94 | 94 | assert !repo.save |
|
95 | 95 | assert_include str, repo.errors.full_messages |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | if File.directory?(REPOSITORY_PATH) |
|
99 | 99 | def test_fetch_changesets_from_scratch |
|
100 | 100 | assert_equal 0, @repository.changesets.count |
|
101 | 101 | @repository.fetch_changesets |
|
102 | 102 | @project.reload |
|
103 | 103 | |
|
104 | 104 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
105 | 105 | assert_equal 16, @repository.filechanges.count |
|
106 | 106 | assert_not_nil @repository.changesets.find_by_comments('Two files changed') |
|
107 | 107 | |
|
108 | 108 | r2 = @repository.changesets.find_by_revision('2') |
|
109 | 109 | assert_equal 'v1-20071213-162510', r2.scmid |
|
110 | 110 | end |
|
111 | 111 | |
|
112 | 112 | def test_fetch_changesets_incremental |
|
113 | 113 | assert_equal 0, @repository.changesets.count |
|
114 | 114 | @repository.fetch_changesets |
|
115 | 115 | @project.reload |
|
116 | 116 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
117 | 117 | |
|
118 | 118 | # Remove changesets with revision > 3 |
|
119 | 119 | @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 3} |
|
120 | 120 | @project.reload |
|
121 | @repository.reload | |
|
121 | 122 | assert_equal 3, @repository.changesets.count |
|
122 | 123 | assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision) |
|
123 | 124 | |
|
124 | 125 | rev3_commit = @repository.changesets.reorder('committed_on DESC').first |
|
125 | 126 | assert_equal '3', rev3_commit.revision |
|
126 | 127 | # 2007-12-14 01:27:22 +0900 |
|
127 | 128 | rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22) |
|
128 | 129 | assert_equal 'HEAD-20071213-162722', rev3_commit.scmid |
|
129 | 130 | assert_equal rev3_committed_on, rev3_commit.committed_on |
|
130 | 131 | latest_rev = @repository.latest_changeset |
|
131 | 132 | assert_equal rev3_committed_on, latest_rev.committed_on |
|
132 | 133 | |
|
133 | 134 | @repository.fetch_changesets |
|
134 | 135 | @project.reload |
|
135 | 136 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
136 | 137 | assert_equal %w|7 6 5 4 3 2 1|, @repository.changesets.all.collect(&:revision) |
|
137 | 138 | rev5_commit = @repository.changesets.find_by_revision('5') |
|
138 | 139 | assert_equal 'HEAD-20071213-163001', rev5_commit.scmid |
|
139 | 140 | # 2007-12-14 01:30:01 +0900 |
|
140 | 141 | rev5_committed_on = Time.gm(2007, 12, 13, 16, 30, 1) |
|
141 | 142 | assert_equal rev5_committed_on, rev5_commit.committed_on |
|
142 | 143 | end |
|
143 | 144 | |
|
144 | 145 | def test_deleted_files_should_not_be_listed |
|
145 | 146 | assert_equal 0, @repository.changesets.count |
|
146 | 147 | @repository.fetch_changesets |
|
147 | 148 | @project.reload |
|
148 | 149 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
149 | 150 | |
|
150 | 151 | entries = @repository.entries('sources') |
|
151 | 152 | assert entries.detect {|e| e.name == 'watchers_controller.rb'} |
|
152 | 153 | assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} |
|
153 | 154 | end |
|
154 | 155 | |
|
155 | 156 | def test_entries_rev3 |
|
156 | 157 | assert_equal 0, @repository.changesets.count |
|
157 | 158 | @repository.fetch_changesets |
|
158 | 159 | @project.reload |
|
159 | 160 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
160 | 161 | entries = @repository.entries('', '3') |
|
161 | 162 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
162 | 163 | assert_equal 3, entries.size |
|
163 | 164 | assert_equal entries[2].name, "README" |
|
164 | 165 | assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22) |
|
165 | 166 | assert_equal entries[2].lastrev.identifier, '3' |
|
166 | 167 | assert_equal entries[2].lastrev.revision, '3' |
|
167 | 168 | assert_equal entries[2].lastrev.author, 'LANG' |
|
168 | 169 | end |
|
169 | 170 | |
|
170 | 171 | def test_entries_invalid_path |
|
171 | 172 | assert_equal 0, @repository.changesets.count |
|
172 | 173 | @repository.fetch_changesets |
|
173 | 174 | @project.reload |
|
174 | 175 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
175 | 176 | assert_nil @repository.entries('missing') |
|
176 | 177 | assert_nil @repository.entries('missing', '3') |
|
177 | 178 | end |
|
178 | 179 | |
|
179 | 180 | def test_entries_invalid_revision |
|
180 | 181 | assert_equal 0, @repository.changesets.count |
|
181 | 182 | @repository.fetch_changesets |
|
182 | 183 | @project.reload |
|
183 | 184 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
184 | 185 | assert_nil @repository.entries('', '123') |
|
185 | 186 | end |
|
186 | 187 | |
|
187 | 188 | def test_cat |
|
188 | 189 | assert_equal 0, @repository.changesets.count |
|
189 | 190 | @repository.fetch_changesets |
|
190 | 191 | @project.reload |
|
191 | 192 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
192 | 193 | buf = @repository.cat('README') |
|
193 | 194 | assert buf |
|
194 | 195 | lines = buf.split("\n") |
|
195 | 196 | assert_equal 3, lines.length |
|
196 | 197 | buf = lines[1].gsub(/\r$/, "") |
|
197 | 198 | assert_equal 'with one change', buf |
|
198 | 199 | buf = @repository.cat('README', '1') |
|
199 | 200 | assert buf |
|
200 | 201 | lines = buf.split("\n") |
|
201 | 202 | assert_equal 1, lines.length |
|
202 | 203 | buf = lines[0].gsub(/\r$/, "") |
|
203 | 204 | assert_equal 'CVS test repository', buf |
|
204 | 205 | assert_nil @repository.cat('missing.rb') |
|
205 | 206 | |
|
206 | 207 | # sources/welcome_controller.rb is removed at revision 5. |
|
207 | 208 | assert @repository.cat('sources/welcome_controller.rb', '4') |
|
208 | 209 | assert @repository.cat('sources/welcome_controller.rb', '5').blank? |
|
209 | 210 | |
|
210 | 211 | # invalid revision |
|
211 | 212 | assert @repository.cat('README', '123').blank? |
|
212 | 213 | end |
|
213 | 214 | |
|
214 | 215 | def test_annotate |
|
215 | 216 | assert_equal 0, @repository.changesets.count |
|
216 | 217 | @repository.fetch_changesets |
|
217 | 218 | @project.reload |
|
218 | 219 | assert_equal CHANGESETS_NUM, @repository.changesets.count |
|
219 | 220 | ann = @repository.annotate('README') |
|
220 | 221 | assert ann |
|
221 | 222 | assert_equal 3, ann.revisions.length |
|
222 | 223 | assert_equal '1.2', ann.revisions[1].revision |
|
223 | 224 | assert_equal 'LANG', ann.revisions[1].author |
|
224 | 225 | assert_equal 'with one change', ann.lines[1] |
|
225 | 226 | |
|
226 | 227 | ann = @repository.annotate('README', '1') |
|
227 | 228 | assert ann |
|
228 | 229 | assert_equal 1, ann.revisions.length |
|
229 | 230 | assert_equal '1.1', ann.revisions[0].revision |
|
230 | 231 | assert_equal 'LANG', ann.revisions[0].author |
|
231 | 232 | assert_equal 'CVS test repository', ann.lines[0] |
|
232 | 233 | |
|
233 | 234 | # invalid revision |
|
234 | 235 | assert_nil @repository.annotate('README', '123') |
|
235 | 236 | end |
|
236 | 237 | |
|
237 | 238 | else |
|
238 | 239 | puts "CVS test repository NOT FOUND. Skipping unit tests !!!" |
|
239 | 240 | def test_fake; assert true end |
|
240 | 241 | end |
|
241 | 242 | end |
@@ -1,129 +1,130 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class RepositoryDarcsTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects |
|
22 | 22 | |
|
23 | 23 | include Redmine::I18n |
|
24 | 24 | |
|
25 | 25 | REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s |
|
26 | 26 | NUM_REV = 6 |
|
27 | 27 | |
|
28 | 28 | def setup |
|
29 | 29 | @project = Project.find(3) |
|
30 | 30 | @repository = Repository::Darcs.create( |
|
31 | 31 | :project => @project, |
|
32 | 32 | :url => REPOSITORY_PATH, |
|
33 | 33 | :log_encoding => 'UTF-8' |
|
34 | 34 | ) |
|
35 | 35 | assert @repository |
|
36 | 36 | end |
|
37 | 37 | |
|
38 | 38 | def test_blank_path_to_repository_error_message |
|
39 | 39 | set_language_if_valid 'en' |
|
40 | 40 | repo = Repository::Darcs.new( |
|
41 | 41 | :project => @project, |
|
42 | 42 | :identifier => 'test', |
|
43 | 43 | :log_encoding => 'UTF-8' |
|
44 | 44 | ) |
|
45 | 45 | assert !repo.save |
|
46 | 46 | assert_include "Path to repository can't be blank", |
|
47 | 47 | repo.errors.full_messages |
|
48 | 48 | end |
|
49 | 49 | |
|
50 | 50 | def test_blank_path_to_repository_error_message_fr |
|
51 | 51 | set_language_if_valid 'fr' |
|
52 | 52 | str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)" |
|
53 | 53 | str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) |
|
54 | 54 | repo = Repository::Darcs.new( |
|
55 | 55 | :project => @project, |
|
56 | 56 | :url => "", |
|
57 | 57 | :identifier => 'test', |
|
58 | 58 | :log_encoding => 'UTF-8' |
|
59 | 59 | ) |
|
60 | 60 | assert !repo.save |
|
61 | 61 | assert_include str, repo.errors.full_messages |
|
62 | 62 | end |
|
63 | 63 | |
|
64 | 64 | if File.directory?(REPOSITORY_PATH) |
|
65 | 65 | def test_fetch_changesets_from_scratch |
|
66 | 66 | assert_equal 0, @repository.changesets.count |
|
67 | 67 | @repository.fetch_changesets |
|
68 | 68 | @project.reload |
|
69 | 69 | |
|
70 | 70 | assert_equal NUM_REV, @repository.changesets.count |
|
71 | 71 | assert_equal 13, @repository.filechanges.count |
|
72 | 72 | assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | 75 | def test_fetch_changesets_incremental |
|
76 | 76 | assert_equal 0, @repository.changesets.count |
|
77 | 77 | @repository.fetch_changesets |
|
78 | 78 | @project.reload |
|
79 | 79 | assert_equal NUM_REV, @repository.changesets.count |
|
80 | 80 | |
|
81 | 81 | # Remove changesets with revision > 3 |
|
82 | 82 | @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 3} |
|
83 | 83 | @project.reload |
|
84 | @repository.reload | |
|
84 | 85 | assert_equal 3, @repository.changesets.count |
|
85 | 86 | |
|
86 | 87 | @repository.fetch_changesets |
|
87 | 88 | @project.reload |
|
88 | 89 | assert_equal NUM_REV, @repository.changesets.count |
|
89 | 90 | end |
|
90 | 91 | |
|
91 | 92 | def test_entries |
|
92 | 93 | entries = @repository.entries |
|
93 | 94 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
94 | 95 | end |
|
95 | 96 | |
|
96 | 97 | def test_entries_invalid_revision |
|
97 | 98 | assert_equal 0, @repository.changesets.count |
|
98 | 99 | @repository.fetch_changesets |
|
99 | 100 | @project.reload |
|
100 | 101 | assert_equal NUM_REV, @repository.changesets.count |
|
101 | 102 | assert_nil @repository.entries('', '123') |
|
102 | 103 | end |
|
103 | 104 | |
|
104 | 105 | def test_deleted_files_should_not_be_listed |
|
105 | 106 | assert_equal 0, @repository.changesets.count |
|
106 | 107 | @repository.fetch_changesets |
|
107 | 108 | @project.reload |
|
108 | 109 | assert_equal NUM_REV, @repository.changesets.count |
|
109 | 110 | entries = @repository.entries('sources') |
|
110 | 111 | assert entries.detect {|e| e.name == 'watchers_controller.rb'} |
|
111 | 112 | assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} |
|
112 | 113 | end |
|
113 | 114 | |
|
114 | 115 | def test_cat |
|
115 | 116 | if @repository.scm.supports_cat? |
|
116 | 117 | assert_equal 0, @repository.changesets.count |
|
117 | 118 | @repository.fetch_changesets |
|
118 | 119 | @project.reload |
|
119 | 120 | assert_equal NUM_REV, @repository.changesets.count |
|
120 | 121 | cat = @repository.cat("sources/welcome_controller.rb", 2) |
|
121 | 122 | assert_not_nil cat |
|
122 | 123 | assert cat.include?('class WelcomeController < ApplicationController') |
|
123 | 124 | end |
|
124 | 125 | end |
|
125 | 126 | else |
|
126 | 127 | puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" |
|
127 | 128 | def test_fake; assert true end |
|
128 | 129 | end |
|
129 | 130 | end |
@@ -1,377 +1,378 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class RepositoryMercurialTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects |
|
22 | 22 | |
|
23 | 23 | include Redmine::I18n |
|
24 | 24 | |
|
25 | 25 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s |
|
26 | 26 | NUM_REV = 32 |
|
27 | 27 | CHAR_1_HEX = "\xc3\x9c" |
|
28 | 28 | |
|
29 | 29 | def setup |
|
30 | 30 | @project = Project.find(3) |
|
31 | 31 | @repository = Repository::Mercurial.create( |
|
32 | 32 | :project => @project, |
|
33 | 33 | :url => REPOSITORY_PATH, |
|
34 | 34 | :path_encoding => 'ISO-8859-1' |
|
35 | 35 | ) |
|
36 | 36 | assert @repository |
|
37 | 37 | @char_1 = CHAR_1_HEX.dup |
|
38 | 38 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00" |
|
39 | 39 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00" |
|
40 | 40 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01" |
|
41 | 41 | if @char_1.respond_to?(:force_encoding) |
|
42 | 42 | @char_1.force_encoding('UTF-8') |
|
43 | 43 | @tag_char_1.force_encoding('UTF-8') |
|
44 | 44 | @branch_char_0.force_encoding('UTF-8') |
|
45 | 45 | @branch_char_1.force_encoding('UTF-8') |
|
46 | 46 | end |
|
47 | 47 | end |
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | def test_blank_path_to_repository_error_message |
|
51 | 51 | set_language_if_valid 'en' |
|
52 | 52 | repo = Repository::Mercurial.new( |
|
53 | 53 | :project => @project, |
|
54 | 54 | :identifier => 'test' |
|
55 | 55 | ) |
|
56 | 56 | assert !repo.save |
|
57 | 57 | assert_include "Path to repository can't be blank", |
|
58 | 58 | repo.errors.full_messages |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | def test_blank_path_to_repository_error_message_fr |
|
62 | 62 | set_language_if_valid 'fr' |
|
63 | 63 | str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)" |
|
64 | 64 | str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) |
|
65 | 65 | repo = Repository::Mercurial.new( |
|
66 | 66 | :project => @project, |
|
67 | 67 | :url => "", |
|
68 | 68 | :identifier => 'test', |
|
69 | 69 | :path_encoding => '' |
|
70 | 70 | ) |
|
71 | 71 | assert !repo.save |
|
72 | 72 | assert_include str, repo.errors.full_messages |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | 75 | if File.directory?(REPOSITORY_PATH) |
|
76 | 76 | def test_scm_available |
|
77 | 77 | klass = Repository::Mercurial |
|
78 | 78 | assert_equal "Mercurial", klass.scm_name |
|
79 | 79 | assert klass.scm_adapter_class |
|
80 | 80 | assert_not_equal "", klass.scm_command |
|
81 | 81 | assert_equal true, klass.scm_available |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | def test_entries |
|
85 | 85 | entries = @repository.entries |
|
86 | 86 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
87 | 87 | end |
|
88 | 88 | |
|
89 | 89 | def test_fetch_changesets_from_scratch |
|
90 | 90 | assert_equal 0, @repository.changesets.count |
|
91 | 91 | @repository.fetch_changesets |
|
92 | 92 | @project.reload |
|
93 | 93 | assert_equal NUM_REV, @repository.changesets.count |
|
94 | 94 | assert_equal 46, @repository.filechanges.count |
|
95 | 95 | assert_equal "Initial import.\nThe repository contains 3 files.", |
|
96 | 96 | @repository.changesets.find_by_revision('0').comments |
|
97 | 97 | end |
|
98 | 98 | |
|
99 | 99 | def test_fetch_changesets_incremental |
|
100 | 100 | assert_equal 0, @repository.changesets.count |
|
101 | 101 | @repository.fetch_changesets |
|
102 | 102 | @project.reload |
|
103 | 103 | assert_equal NUM_REV, @repository.changesets.count |
|
104 | 104 | # Remove changesets with revision > 2 |
|
105 | 105 | @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 2} |
|
106 | 106 | @project.reload |
|
107 | @repository.reload | |
|
107 | 108 | assert_equal 3, @repository.changesets.count |
|
108 | 109 | |
|
109 | 110 | @repository.fetch_changesets |
|
110 | 111 | @project.reload |
|
111 | 112 | assert_equal NUM_REV, @repository.changesets.count |
|
112 | 113 | end |
|
113 | 114 | |
|
114 | 115 | def test_isodatesec |
|
115 | 116 | # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher |
|
116 | 117 | if @repository.scm.class.client_version_above?([1, 0]) |
|
117 | 118 | assert_equal 0, @repository.changesets.count |
|
118 | 119 | @repository.fetch_changesets |
|
119 | 120 | @project.reload |
|
120 | 121 | assert_equal NUM_REV, @repository.changesets.count |
|
121 | 122 | rev0_committed_on = Time.gm(2007, 12, 14, 9, 22, 52) |
|
122 | 123 | assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on |
|
123 | 124 | end |
|
124 | 125 | end |
|
125 | 126 | |
|
126 | 127 | def test_changeset_order_by_revision |
|
127 | 128 | assert_equal 0, @repository.changesets.count |
|
128 | 129 | @repository.fetch_changesets |
|
129 | 130 | @project.reload |
|
130 | 131 | assert_equal NUM_REV, @repository.changesets.count |
|
131 | 132 | |
|
132 | 133 | c0 = @repository.latest_changeset |
|
133 | 134 | c1 = @repository.changesets.find_by_revision('0') |
|
134 | 135 | # sorted by revision (id), not by date |
|
135 | 136 | assert c0.revision.to_i > c1.revision.to_i |
|
136 | 137 | assert c0.committed_on < c1.committed_on |
|
137 | 138 | end |
|
138 | 139 | |
|
139 | 140 | def test_latest_changesets |
|
140 | 141 | assert_equal 0, @repository.changesets.count |
|
141 | 142 | @repository.fetch_changesets |
|
142 | 143 | @project.reload |
|
143 | 144 | assert_equal NUM_REV, @repository.changesets.count |
|
144 | 145 | |
|
145 | 146 | # with_limit |
|
146 | 147 | changesets = @repository.latest_changesets('', nil, 2) |
|
147 | 148 | assert_equal %w|31 30|, changesets.collect(&:revision) |
|
148 | 149 | |
|
149 | 150 | # with_filepath |
|
150 | 151 | changesets = @repository.latest_changesets( |
|
151 | 152 | '/sql_escape/percent%dir/percent%file1.txt', nil) |
|
152 | 153 | assert_equal %w|30 11 10 9|, changesets.collect(&:revision) |
|
153 | 154 | |
|
154 | 155 | changesets = @repository.latest_changesets( |
|
155 | 156 | '/sql_escape/underscore_dir/understrike_file.txt', nil) |
|
156 | 157 | assert_equal %w|30 12 9|, changesets.collect(&:revision) |
|
157 | 158 | |
|
158 | 159 | changesets = @repository.latest_changesets('README', nil) |
|
159 | 160 | assert_equal %w|31 30 28 17 8 6 1 0|, changesets.collect(&:revision) |
|
160 | 161 | |
|
161 | 162 | changesets = @repository.latest_changesets('README','8') |
|
162 | 163 | assert_equal %w|8 6 1 0|, changesets.collect(&:revision) |
|
163 | 164 | |
|
164 | 165 | changesets = @repository.latest_changesets('README','8', 2) |
|
165 | 166 | assert_equal %w|8 6|, changesets.collect(&:revision) |
|
166 | 167 | |
|
167 | 168 | # with_dirpath |
|
168 | 169 | changesets = @repository.latest_changesets('images', nil) |
|
169 | 170 | assert_equal %w|1 0|, changesets.collect(&:revision) |
|
170 | 171 | |
|
171 | 172 | path = 'sql_escape/percent%dir' |
|
172 | 173 | changesets = @repository.latest_changesets(path, nil) |
|
173 | 174 | assert_equal %w|30 13 11 10 9|, changesets.collect(&:revision) |
|
174 | 175 | |
|
175 | 176 | changesets = @repository.latest_changesets(path, '11') |
|
176 | 177 | assert_equal %w|11 10 9|, changesets.collect(&:revision) |
|
177 | 178 | |
|
178 | 179 | changesets = @repository.latest_changesets(path, '11', 2) |
|
179 | 180 | assert_equal %w|11 10|, changesets.collect(&:revision) |
|
180 | 181 | |
|
181 | 182 | path = 'sql_escape/underscore_dir' |
|
182 | 183 | changesets = @repository.latest_changesets(path, nil) |
|
183 | 184 | assert_equal %w|30 13 12 9|, changesets.collect(&:revision) |
|
184 | 185 | |
|
185 | 186 | changesets = @repository.latest_changesets(path, '12') |
|
186 | 187 | assert_equal %w|12 9|, changesets.collect(&:revision) |
|
187 | 188 | |
|
188 | 189 | changesets = @repository.latest_changesets(path, '12', 1) |
|
189 | 190 | assert_equal %w|12|, changesets.collect(&:revision) |
|
190 | 191 | |
|
191 | 192 | # tag |
|
192 | 193 | changesets = @repository.latest_changesets('', 'tag_test.00') |
|
193 | 194 | assert_equal %w|5 4 3 2 1 0|, changesets.collect(&:revision) |
|
194 | 195 | |
|
195 | 196 | changesets = @repository.latest_changesets('', 'tag_test.00', 2) |
|
196 | 197 | assert_equal %w|5 4|, changesets.collect(&:revision) |
|
197 | 198 | |
|
198 | 199 | changesets = @repository.latest_changesets('sources', 'tag_test.00') |
|
199 | 200 | assert_equal %w|4 3 2 1 0|, changesets.collect(&:revision) |
|
200 | 201 | |
|
201 | 202 | changesets = @repository.latest_changesets('sources', 'tag_test.00', 2) |
|
202 | 203 | assert_equal %w|4 3|, changesets.collect(&:revision) |
|
203 | 204 | |
|
204 | 205 | # named branch |
|
205 | 206 | if @repository.scm.class.client_version_above?([1, 6]) |
|
206 | 207 | changesets = @repository.latest_changesets('', @branch_char_1) |
|
207 | 208 | assert_equal %w|27 26|, changesets.collect(&:revision) |
|
208 | 209 | end |
|
209 | 210 | |
|
210 | 211 | changesets = @repository.latest_changesets("latin-1-dir/test-#{@char_1}-subdir", @branch_char_1) |
|
211 | 212 | assert_equal %w|27|, changesets.collect(&:revision) |
|
212 | 213 | end |
|
213 | 214 | |
|
214 | 215 | def test_copied_files |
|
215 | 216 | assert_equal 0, @repository.changesets.count |
|
216 | 217 | @repository.fetch_changesets |
|
217 | 218 | @project.reload |
|
218 | 219 | assert_equal NUM_REV, @repository.changesets.count |
|
219 | 220 | |
|
220 | 221 | cs1 = @repository.changesets.find_by_revision('13') |
|
221 | 222 | assert_not_nil cs1 |
|
222 | 223 | c1 = cs1.filechanges.sort_by(&:path) |
|
223 | 224 | assert_equal 2, c1.size |
|
224 | 225 | |
|
225 | 226 | assert_equal 'A', c1[0].action |
|
226 | 227 | assert_equal '/sql_escape/percent%dir/percentfile1.txt', c1[0].path |
|
227 | 228 | assert_equal '/sql_escape/percent%dir/percent%file1.txt', c1[0].from_path |
|
228 | 229 | assert_equal '3a330eb32958', c1[0].from_revision |
|
229 | 230 | |
|
230 | 231 | assert_equal 'A', c1[1].action |
|
231 | 232 | assert_equal '/sql_escape/underscore_dir/understrike-file.txt', c1[1].path |
|
232 | 233 | assert_equal '/sql_escape/underscore_dir/understrike_file.txt', c1[1].from_path |
|
233 | 234 | |
|
234 | 235 | cs2 = @repository.changesets.find_by_revision('15') |
|
235 | 236 | c2 = cs2.filechanges |
|
236 | 237 | assert_equal 1, c2.size |
|
237 | 238 | |
|
238 | 239 | assert_equal 'A', c2[0].action |
|
239 | 240 | assert_equal '/README (1)[2]&,%.-3_4', c2[0].path |
|
240 | 241 | assert_equal '/README', c2[0].from_path |
|
241 | 242 | assert_equal '933ca60293d7', c2[0].from_revision |
|
242 | 243 | |
|
243 | 244 | cs3 = @repository.changesets.find_by_revision('19') |
|
244 | 245 | c3 = cs3.filechanges |
|
245 | 246 | assert_equal 1, c3.size |
|
246 | 247 | assert_equal 'A', c3[0].action |
|
247 | 248 | assert_equal "/latin-1-dir/test-#{@char_1}-1.txt", c3[0].path |
|
248 | 249 | assert_equal "/latin-1-dir/test-#{@char_1}.txt", c3[0].from_path |
|
249 | 250 | assert_equal '5d9891a1b425', c3[0].from_revision |
|
250 | 251 | end |
|
251 | 252 | |
|
252 | 253 | def test_find_changeset_by_name |
|
253 | 254 | assert_equal 0, @repository.changesets.count |
|
254 | 255 | @repository.fetch_changesets |
|
255 | 256 | @project.reload |
|
256 | 257 | assert_equal NUM_REV, @repository.changesets.count |
|
257 | 258 | %w|2 400bb8672109 400|.each do |r| |
|
258 | 259 | assert_equal '2', @repository.find_changeset_by_name(r).revision |
|
259 | 260 | end |
|
260 | 261 | end |
|
261 | 262 | |
|
262 | 263 | def test_find_changeset_by_invalid_name |
|
263 | 264 | assert_equal 0, @repository.changesets.count |
|
264 | 265 | @repository.fetch_changesets |
|
265 | 266 | @project.reload |
|
266 | 267 | assert_equal NUM_REV, @repository.changesets.count |
|
267 | 268 | assert_nil @repository.find_changeset_by_name('100000') |
|
268 | 269 | end |
|
269 | 270 | |
|
270 | 271 | def test_identifier |
|
271 | 272 | assert_equal 0, @repository.changesets.count |
|
272 | 273 | @repository.fetch_changesets |
|
273 | 274 | @project.reload |
|
274 | 275 | assert_equal NUM_REV, @repository.changesets.count |
|
275 | 276 | c = @repository.changesets.find_by_revision('2') |
|
276 | 277 | assert_equal c.scmid, c.identifier |
|
277 | 278 | end |
|
278 | 279 | |
|
279 | 280 | def test_format_identifier |
|
280 | 281 | assert_equal 0, @repository.changesets.count |
|
281 | 282 | @repository.fetch_changesets |
|
282 | 283 | @project.reload |
|
283 | 284 | assert_equal NUM_REV, @repository.changesets.count |
|
284 | 285 | c = @repository.changesets.find_by_revision('2') |
|
285 | 286 | assert_equal '2:400bb8672109', c.format_identifier |
|
286 | 287 | end |
|
287 | 288 | |
|
288 | 289 | def test_find_changeset_by_empty_name |
|
289 | 290 | assert_equal 0, @repository.changesets.count |
|
290 | 291 | @repository.fetch_changesets |
|
291 | 292 | @project.reload |
|
292 | 293 | assert_equal NUM_REV, @repository.changesets.count |
|
293 | 294 | ['', ' ', nil].each do |r| |
|
294 | 295 | assert_nil @repository.find_changeset_by_name(r) |
|
295 | 296 | end |
|
296 | 297 | end |
|
297 | 298 | |
|
298 | 299 | def test_parents |
|
299 | 300 | assert_equal 0, @repository.changesets.count |
|
300 | 301 | @repository.fetch_changesets |
|
301 | 302 | @project.reload |
|
302 | 303 | assert_equal NUM_REV, @repository.changesets.count |
|
303 | 304 | r1 = @repository.changesets.find_by_revision('0') |
|
304 | 305 | assert_equal [], r1.parents |
|
305 | 306 | r2 = @repository.changesets.find_by_revision('1') |
|
306 | 307 | assert_equal 1, r2.parents.length |
|
307 | 308 | assert_equal "0885933ad4f6", |
|
308 | 309 | r2.parents[0].identifier |
|
309 | 310 | r3 = @repository.changesets.find_by_revision('30') |
|
310 | 311 | assert_equal 2, r3.parents.length |
|
311 | 312 | r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort |
|
312 | 313 | assert_equal "3a330eb32958", r4[0] |
|
313 | 314 | assert_equal "a94b0528f24f", r4[1] |
|
314 | 315 | end |
|
315 | 316 | |
|
316 | 317 | def test_activities |
|
317 | 318 | c = Changeset.new(:repository => @repository, |
|
318 | 319 | :committed_on => Time.now, |
|
319 | 320 | :revision => '123', |
|
320 | 321 | :scmid => 'abc400bb8672', |
|
321 | 322 | :comments => 'test') |
|
322 | 323 | assert c.event_title.include?('123:abc400bb8672:') |
|
323 | 324 | assert_equal 'abc400bb8672', c.event_url[:rev] |
|
324 | 325 | end |
|
325 | 326 | |
|
326 | 327 | def test_previous |
|
327 | 328 | assert_equal 0, @repository.changesets.count |
|
328 | 329 | @repository.fetch_changesets |
|
329 | 330 | @project.reload |
|
330 | 331 | assert_equal NUM_REV, @repository.changesets.count |
|
331 | 332 | %w|28 3ae45e2d177d 3ae45|.each do |r1| |
|
332 | 333 | changeset = @repository.find_changeset_by_name(r1) |
|
333 | 334 | %w|27 7bbf4c738e71 7bbf|.each do |r2| |
|
334 | 335 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous |
|
335 | 336 | end |
|
336 | 337 | end |
|
337 | 338 | end |
|
338 | 339 | |
|
339 | 340 | def test_previous_nil |
|
340 | 341 | assert_equal 0, @repository.changesets.count |
|
341 | 342 | @repository.fetch_changesets |
|
342 | 343 | @project.reload |
|
343 | 344 | assert_equal NUM_REV, @repository.changesets.count |
|
344 | 345 | %w|0 0885933ad4f6 0885|.each do |r1| |
|
345 | 346 | changeset = @repository.find_changeset_by_name(r1) |
|
346 | 347 | assert_nil changeset.previous |
|
347 | 348 | end |
|
348 | 349 | end |
|
349 | 350 | |
|
350 | 351 | def test_next |
|
351 | 352 | assert_equal 0, @repository.changesets.count |
|
352 | 353 | @repository.fetch_changesets |
|
353 | 354 | @project.reload |
|
354 | 355 | assert_equal NUM_REV, @repository.changesets.count |
|
355 | 356 | %w|27 7bbf4c738e71 7bbf|.each do |r2| |
|
356 | 357 | changeset = @repository.find_changeset_by_name(r2) |
|
357 | 358 | %w|28 3ae45e2d177d 3ae45|.each do |r1| |
|
358 | 359 | assert_equal @repository.find_changeset_by_name(r1), changeset.next |
|
359 | 360 | end |
|
360 | 361 | end |
|
361 | 362 | end |
|
362 | 363 | |
|
363 | 364 | def test_next_nil |
|
364 | 365 | assert_equal 0, @repository.changesets.count |
|
365 | 366 | @repository.fetch_changesets |
|
366 | 367 | @project.reload |
|
367 | 368 | assert_equal NUM_REV, @repository.changesets.count |
|
368 | 369 | %w|31 31eeee7395c8 31eee|.each do |r1| |
|
369 | 370 | changeset = @repository.find_changeset_by_name(r1) |
|
370 | 371 | assert_nil changeset.next |
|
371 | 372 | end |
|
372 | 373 | end |
|
373 | 374 | else |
|
374 | 375 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" |
|
375 | 376 | def test_fake; assert true end |
|
376 | 377 | end |
|
377 | 378 | end |
@@ -1,259 +1,260 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class RepositorySubversionTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects, :repositories, :enabled_modules, :users, :roles |
|
22 | 22 | |
|
23 | 23 | include Redmine::I18n |
|
24 | 24 | |
|
25 | 25 | NUM_REV = 11 |
|
26 | 26 | |
|
27 | 27 | def setup |
|
28 | 28 | @project = Project.find(3) |
|
29 | 29 | @repository = Repository::Subversion.create(:project => @project, |
|
30 | 30 | :url => self.class.subversion_repository_url) |
|
31 | 31 | assert @repository |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def test_invalid_url |
|
35 | 35 | set_language_if_valid 'en' |
|
36 | 36 | ['invalid', 'http://', 'svn://', 'svn+ssh://', 'file://'].each do |url| |
|
37 | 37 | repo = Repository::Subversion.new( |
|
38 | 38 | :project => @project, |
|
39 | 39 | :identifier => 'test', |
|
40 | 40 | :url => url |
|
41 | 41 | ) |
|
42 | 42 | assert !repo.save |
|
43 | 43 | assert_equal ["is invalid"], repo.errors[:url] |
|
44 | 44 | end |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def test_valid_url |
|
48 | 48 | ['http://valid', 'svn://valid', 'svn+ssh://valid', 'file://valid'].each do |url| |
|
49 | 49 | repo = Repository::Subversion.new( |
|
50 | 50 | :project => @project, |
|
51 | 51 | :identifier => 'test', |
|
52 | 52 | :url => url |
|
53 | 53 | ) |
|
54 | 54 | assert repo.save |
|
55 | 55 | assert_equal [], repo.errors[:url] |
|
56 | 56 | assert repo.destroy |
|
57 | 57 | end |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | if repository_configured?('subversion') |
|
61 | 61 | def test_fetch_changesets_from_scratch |
|
62 | 62 | assert_equal 0, @repository.changesets.count |
|
63 | 63 | @repository.fetch_changesets |
|
64 | 64 | @project.reload |
|
65 | 65 | |
|
66 | 66 | assert_equal NUM_REV, @repository.changesets.count |
|
67 | 67 | assert_equal 20, @repository.filechanges.count |
|
68 | 68 | assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments |
|
69 | 69 | end |
|
70 | 70 | |
|
71 | 71 | def test_fetch_changesets_incremental |
|
72 | 72 | assert_equal 0, @repository.changesets.count |
|
73 | 73 | @repository.fetch_changesets |
|
74 | 74 | @project.reload |
|
75 | 75 | assert_equal NUM_REV, @repository.changesets.count |
|
76 | 76 | |
|
77 | 77 | # Remove changesets with revision > 5 |
|
78 | 78 | @repository.changesets.all.each {|c| c.destroy if c.revision.to_i > 5} |
|
79 | 79 | @project.reload |
|
80 | @repository.reload | |
|
80 | 81 | assert_equal 5, @repository.changesets.count |
|
81 | 82 | |
|
82 | 83 | @repository.fetch_changesets |
|
83 | 84 | @project.reload |
|
84 | 85 | assert_equal NUM_REV, @repository.changesets.count |
|
85 | 86 | end |
|
86 | 87 | |
|
87 | 88 | def test_entries |
|
88 | 89 | entries = @repository.entries |
|
89 | 90 | assert_kind_of Redmine::Scm::Adapters::Entries, entries |
|
90 | 91 | end |
|
91 | 92 | |
|
92 | 93 | def test_entries_for_invalid_path_should_return_nil |
|
93 | 94 | entries = @repository.entries('invalid_path') |
|
94 | 95 | assert_nil entries |
|
95 | 96 | end |
|
96 | 97 | |
|
97 | 98 | def test_latest_changesets |
|
98 | 99 | assert_equal 0, @repository.changesets.count |
|
99 | 100 | @repository.fetch_changesets |
|
100 | 101 | @project.reload |
|
101 | 102 | assert_equal NUM_REV, @repository.changesets.count |
|
102 | 103 | |
|
103 | 104 | # with limit |
|
104 | 105 | changesets = @repository.latest_changesets('', nil, 2) |
|
105 | 106 | assert_equal 2, changesets.size |
|
106 | 107 | assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets |
|
107 | 108 | |
|
108 | 109 | # with path |
|
109 | 110 | changesets = @repository.latest_changesets('subversion_test/folder', nil) |
|
110 | 111 | assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision) |
|
111 | 112 | |
|
112 | 113 | # with path and revision |
|
113 | 114 | changesets = @repository.latest_changesets('subversion_test/folder', 8) |
|
114 | 115 | assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision) |
|
115 | 116 | end |
|
116 | 117 | |
|
117 | 118 | def test_directory_listing_with_square_brackets_in_path |
|
118 | 119 | assert_equal 0, @repository.changesets.count |
|
119 | 120 | @repository.fetch_changesets |
|
120 | 121 | @project.reload |
|
121 | 122 | assert_equal NUM_REV, @repository.changesets.count |
|
122 | 123 | |
|
123 | 124 | entries = @repository.entries('subversion_test/[folder_with_brackets]') |
|
124 | 125 | assert_not_nil entries, 'Expect to find entries in folder_with_brackets' |
|
125 | 126 | assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets' |
|
126 | 127 | assert_equal 'README.txt', entries.first.name |
|
127 | 128 | end |
|
128 | 129 | |
|
129 | 130 | def test_directory_listing_with_square_brackets_in_base |
|
130 | 131 | @project = Project.find(3) |
|
131 | 132 | @repository = Repository::Subversion.create( |
|
132 | 133 | :project => @project, |
|
133 | 134 | :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]") |
|
134 | 135 | |
|
135 | 136 | assert_equal 0, @repository.changesets.count |
|
136 | 137 | @repository.fetch_changesets |
|
137 | 138 | @project.reload |
|
138 | 139 | |
|
139 | 140 | assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision' |
|
140 | 141 | assert_equal 2, @repository.filechanges.count, 'Expected to see 2 changes, dir add and file add' |
|
141 | 142 | |
|
142 | 143 | entries = @repository.entries('') |
|
143 | 144 | assert_not_nil entries, 'Expect to find entries' |
|
144 | 145 | assert_equal 1, entries.size, 'Expect a single entry' |
|
145 | 146 | assert_equal 'README.txt', entries.first.name |
|
146 | 147 | end |
|
147 | 148 | |
|
148 | 149 | def test_identifier |
|
149 | 150 | assert_equal 0, @repository.changesets.count |
|
150 | 151 | @repository.fetch_changesets |
|
151 | 152 | @project.reload |
|
152 | 153 | assert_equal NUM_REV, @repository.changesets.count |
|
153 | 154 | c = @repository.changesets.find_by_revision('1') |
|
154 | 155 | assert_equal c.revision, c.identifier |
|
155 | 156 | end |
|
156 | 157 | |
|
157 | 158 | def test_find_changeset_by_empty_name |
|
158 | 159 | assert_equal 0, @repository.changesets.count |
|
159 | 160 | @repository.fetch_changesets |
|
160 | 161 | @project.reload |
|
161 | 162 | assert_equal NUM_REV, @repository.changesets.count |
|
162 | 163 | ['', ' ', nil].each do |r| |
|
163 | 164 | assert_nil @repository.find_changeset_by_name(r) |
|
164 | 165 | end |
|
165 | 166 | end |
|
166 | 167 | |
|
167 | 168 | def test_identifier_nine_digit |
|
168 | 169 | c = Changeset.new(:repository => @repository, :committed_on => Time.now, |
|
169 | 170 | :revision => '123456789', :comments => 'test') |
|
170 | 171 | assert_equal c.identifier, c.revision |
|
171 | 172 | end |
|
172 | 173 | |
|
173 | 174 | def test_format_identifier |
|
174 | 175 | assert_equal 0, @repository.changesets.count |
|
175 | 176 | @repository.fetch_changesets |
|
176 | 177 | @project.reload |
|
177 | 178 | assert_equal NUM_REV, @repository.changesets.count |
|
178 | 179 | c = @repository.changesets.find_by_revision('1') |
|
179 | 180 | assert_equal c.format_identifier, c.revision |
|
180 | 181 | end |
|
181 | 182 | |
|
182 | 183 | def test_format_identifier_nine_digit |
|
183 | 184 | c = Changeset.new(:repository => @repository, :committed_on => Time.now, |
|
184 | 185 | :revision => '123456789', :comments => 'test') |
|
185 | 186 | assert_equal c.format_identifier, c.revision |
|
186 | 187 | end |
|
187 | 188 | |
|
188 | 189 | def test_activities |
|
189 | 190 | c = Changeset.new(:repository => @repository, :committed_on => Time.now, |
|
190 | 191 | :revision => '1', :comments => 'test') |
|
191 | 192 | assert c.event_title.include?('1:') |
|
192 | 193 | assert_equal '1', c.event_url[:rev] |
|
193 | 194 | end |
|
194 | 195 | |
|
195 | 196 | def test_activities_nine_digit |
|
196 | 197 | c = Changeset.new(:repository => @repository, :committed_on => Time.now, |
|
197 | 198 | :revision => '123456789', :comments => 'test') |
|
198 | 199 | assert c.event_title.include?('123456789:') |
|
199 | 200 | assert_equal '123456789', c.event_url[:rev] |
|
200 | 201 | end |
|
201 | 202 | |
|
202 | 203 | def test_log_encoding_ignore_setting |
|
203 | 204 | with_settings :commit_logs_encoding => 'windows-1252' do |
|
204 | 205 | s1 = "\xC2\x80" |
|
205 | 206 | s2 = "\xc3\x82\xc2\x80" |
|
206 | 207 | if s1.respond_to?(:force_encoding) |
|
207 | 208 | s1.force_encoding('ISO-8859-1') |
|
208 | 209 | s2.force_encoding('UTF-8') |
|
209 | 210 | assert_equal s1.encode('UTF-8'), s2 |
|
210 | 211 | end |
|
211 | 212 | c = Changeset.new(:repository => @repository, |
|
212 | 213 | :comments => s2, |
|
213 | 214 | :revision => '123', |
|
214 | 215 | :committed_on => Time.now) |
|
215 | 216 | assert c.save |
|
216 | 217 | assert_equal s2, c.comments |
|
217 | 218 | end |
|
218 | 219 | end |
|
219 | 220 | |
|
220 | 221 | def test_previous |
|
221 | 222 | assert_equal 0, @repository.changesets.count |
|
222 | 223 | @repository.fetch_changesets |
|
223 | 224 | @project.reload |
|
224 | 225 | assert_equal NUM_REV, @repository.changesets.count |
|
225 | 226 | changeset = @repository.find_changeset_by_name('3') |
|
226 | 227 | assert_equal @repository.find_changeset_by_name('2'), changeset.previous |
|
227 | 228 | end |
|
228 | 229 | |
|
229 | 230 | def test_previous_nil |
|
230 | 231 | assert_equal 0, @repository.changesets.count |
|
231 | 232 | @repository.fetch_changesets |
|
232 | 233 | @project.reload |
|
233 | 234 | assert_equal NUM_REV, @repository.changesets.count |
|
234 | 235 | changeset = @repository.find_changeset_by_name('1') |
|
235 | 236 | assert_nil changeset.previous |
|
236 | 237 | end |
|
237 | 238 | |
|
238 | 239 | def test_next |
|
239 | 240 | assert_equal 0, @repository.changesets.count |
|
240 | 241 | @repository.fetch_changesets |
|
241 | 242 | @project.reload |
|
242 | 243 | assert_equal NUM_REV, @repository.changesets.count |
|
243 | 244 | changeset = @repository.find_changeset_by_name('2') |
|
244 | 245 | assert_equal @repository.find_changeset_by_name('3'), changeset.next |
|
245 | 246 | end |
|
246 | 247 | |
|
247 | 248 | def test_next_nil |
|
248 | 249 | assert_equal 0, @repository.changesets.count |
|
249 | 250 | @repository.fetch_changesets |
|
250 | 251 | @project.reload |
|
251 | 252 | assert_equal NUM_REV, @repository.changesets.count |
|
252 | 253 | changeset = @repository.find_changeset_by_name('11') |
|
253 | 254 | assert_nil changeset.next |
|
254 | 255 | end |
|
255 | 256 | else |
|
256 | 257 | puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" |
|
257 | 258 | def test_fake; assert true end |
|
258 | 259 | end |
|
259 | 260 | end |
General Comments 0
You need to be logged in to leave comments.
Login now