@@ -1,34 +1,34 | |||
|
1 | 1 | <% content_for :header_tags do %> |
|
2 | 2 | <%= javascript_include_tag 'repository_navigation' %> |
|
3 | 3 | <% end %> |
|
4 | 4 | |
|
5 | 5 | <%= link_to l(:label_statistics), |
|
6 | 6 | {:action => 'stats', :id => @project, :repository_id => @repository.identifier_param}, |
|
7 | 7 | :class => 'icon icon-stats' if @repository.supports_all_revisions? %> |
|
8 | 8 | |
|
9 | 9 | <% form_tag({:action => controller.action_name, |
|
10 | 10 | :id => @project, |
|
11 | 11 | :repository_id => @repository.identifier_param, |
|
12 | 12 | :path => to_path_param(@path), |
|
13 |
:rev => |
|
|
13 | :rev => nil}, | |
|
14 | 14 | {:method => :get, :id => 'revision_selector'}) do -%> |
|
15 | 15 | <!-- Branches Dropdown --> |
|
16 | 16 | <% if !@repository.branches.nil? && @repository.branches.length > 0 -%> |
|
17 | 17 | | <%= l(:label_branch) %>: |
|
18 | 18 | <%= select_tag :branch, |
|
19 | 19 | options_for_select([''] + @repository.branches, @rev), |
|
20 | 20 | :id => 'branch' %> |
|
21 | 21 | <% end -%> |
|
22 | 22 | |
|
23 | 23 | <% if !@repository.tags.nil? && @repository.tags.length > 0 -%> |
|
24 | 24 | | <%= l(:label_tag) %>: |
|
25 | 25 | <%= select_tag :tag, |
|
26 | 26 | options_for_select([''] + @repository.tags, @rev), |
|
27 | 27 | :id => 'tag' %> |
|
28 | 28 | <% end -%> |
|
29 | 29 | |
|
30 | 30 | <% if @repository.supports_all_revisions? %> |
|
31 | 31 | | <%= l(:label_revision) %>: |
|
32 | 32 | <%= text_field_tag 'rev', @rev, :size => 8 %> |
|
33 | 33 | <% end %> |
|
34 | 34 | <% end -%> |
@@ -1,503 +1,513 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 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 RepositoriesMercurialControllerTest < ActionController::TestCase |
|
21 | 21 | tests RepositoriesController |
|
22 | 22 | |
|
23 | 23 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
24 | 24 | :repositories, :enabled_modules |
|
25 | 25 | |
|
26 | 26 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s |
|
27 | 27 | CHAR_1_HEX = "\xc3\x9c" |
|
28 | 28 | PRJ_ID = 3 |
|
29 | 29 | NUM_REV = 32 |
|
30 | 30 | |
|
31 | 31 | ruby19_non_utf8_pass = |
|
32 | 32 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') |
|
33 | 33 | |
|
34 | 34 | def setup |
|
35 | 35 | User.current = nil |
|
36 | 36 | @project = Project.find(PRJ_ID) |
|
37 | 37 | @repository = Repository::Mercurial.create( |
|
38 | 38 | :project => @project, |
|
39 | 39 | :url => REPOSITORY_PATH, |
|
40 | 40 | :path_encoding => 'ISO-8859-1' |
|
41 | 41 | ) |
|
42 | 42 | assert @repository |
|
43 | 43 | @diff_c_support = true |
|
44 | 44 | @char_1 = CHAR_1_HEX.dup |
|
45 | 45 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00" |
|
46 | 46 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00" |
|
47 | 47 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01" |
|
48 | 48 | if @char_1.respond_to?(:force_encoding) |
|
49 | 49 | @char_1.force_encoding('UTF-8') |
|
50 | 50 | @tag_char_1.force_encoding('UTF-8') |
|
51 | 51 | @branch_char_0.force_encoding('UTF-8') |
|
52 | 52 | @branch_char_1.force_encoding('UTF-8') |
|
53 | 53 | end |
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | if ruby19_non_utf8_pass |
|
57 | 57 | puts "TODO: Mercurial functional test fails in Ruby 1.9 " + |
|
58 | 58 | "and Encoding.default_external is not UTF-8. " + |
|
59 | 59 | "Current value is '#{Encoding.default_external.to_s}'" |
|
60 | 60 | def test_fake; assert true end |
|
61 | 61 | elsif File.directory?(REPOSITORY_PATH) |
|
62 | 62 | |
|
63 | 63 | def test_get_new |
|
64 | 64 | @request.session[:user_id] = 1 |
|
65 | 65 | @project.repository.destroy |
|
66 | 66 | get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial' |
|
67 | 67 | assert_response :success |
|
68 | 68 | assert_template 'new' |
|
69 | 69 | assert_kind_of Repository::Mercurial, assigns(:repository) |
|
70 | 70 | assert assigns(:repository).new_record? |
|
71 | 71 | end |
|
72 | 72 | |
|
73 | 73 | def test_show_root |
|
74 | 74 | assert_equal 0, @repository.changesets.count |
|
75 | 75 | @repository.fetch_changesets |
|
76 | 76 | @project.reload |
|
77 | 77 | assert_equal NUM_REV, @repository.changesets.count |
|
78 | 78 | get :show, :id => PRJ_ID |
|
79 | 79 | assert_response :success |
|
80 | 80 | assert_template 'show' |
|
81 | 81 | assert_not_nil assigns(:entries) |
|
82 | 82 | assert_equal 4, assigns(:entries).size |
|
83 | 83 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
84 | 84 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
85 | 85 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
86 | 86 | assert_not_nil assigns(:changesets) |
|
87 | 87 | assert assigns(:changesets).size > 0 |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | def test_show_directory |
|
91 | 91 | assert_equal 0, @repository.changesets.count |
|
92 | 92 | @repository.fetch_changesets |
|
93 | 93 | @project.reload |
|
94 | 94 | assert_equal NUM_REV, @repository.changesets.count |
|
95 | 95 | get :show, :id => PRJ_ID, :path => ['images'] |
|
96 | 96 | assert_response :success |
|
97 | 97 | assert_template 'show' |
|
98 | 98 | assert_not_nil assigns(:entries) |
|
99 | 99 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
|
100 | 100 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
101 | 101 | assert_not_nil entry |
|
102 | 102 | assert_equal 'file', entry.kind |
|
103 | 103 | assert_equal 'images/edit.png', entry.path |
|
104 | 104 | assert_not_nil assigns(:changesets) |
|
105 | 105 | assert assigns(:changesets).size > 0 |
|
106 | 106 | end |
|
107 | 107 | |
|
108 | 108 | def test_show_at_given_revision |
|
109 | 109 | assert_equal 0, @repository.changesets.count |
|
110 | 110 | @repository.fetch_changesets |
|
111 | 111 | @project.reload |
|
112 | 112 | assert_equal NUM_REV, @repository.changesets.count |
|
113 | 113 | [0, '0', '0885933ad4f6'].each do |r1| |
|
114 | 114 | get :show, :id => PRJ_ID, :path => ['images'], :rev => r1 |
|
115 | 115 | assert_response :success |
|
116 | 116 | assert_template 'show' |
|
117 | 117 | assert_not_nil assigns(:entries) |
|
118 | 118 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
119 | 119 | assert_not_nil assigns(:changesets) |
|
120 | 120 | assert assigns(:changesets).size > 0 |
|
121 | 121 | end |
|
122 | 122 | end |
|
123 | 123 | |
|
124 | 124 | def test_show_directory_sql_escape_percent |
|
125 | 125 | assert_equal 0, @repository.changesets.count |
|
126 | 126 | @repository.fetch_changesets |
|
127 | 127 | @project.reload |
|
128 | 128 | assert_equal NUM_REV, @repository.changesets.count |
|
129 | 129 | [13, '13', '3a330eb32958'].each do |r1| |
|
130 | 130 | get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'], |
|
131 | 131 | :rev => r1 |
|
132 | 132 | assert_response :success |
|
133 | 133 | assert_template 'show' |
|
134 | 134 | |
|
135 | 135 | assert_not_nil assigns(:entries) |
|
136 | 136 | assert_equal ['percent%file1.txt', 'percentfile1.txt'], |
|
137 | 137 | assigns(:entries).collect(&:name) |
|
138 | 138 | changesets = assigns(:changesets) |
|
139 | 139 | assert_not_nil changesets |
|
140 | 140 | assert assigns(:changesets).size > 0 |
|
141 | 141 | assert_equal %w(13 11 10 9), changesets.collect(&:revision) |
|
142 | 142 | end |
|
143 | 143 | end |
|
144 | 144 | |
|
145 | 145 | def test_show_directory_latin_1_path |
|
146 | 146 | assert_equal 0, @repository.changesets.count |
|
147 | 147 | @repository.fetch_changesets |
|
148 | 148 | @project.reload |
|
149 | 149 | assert_equal NUM_REV, @repository.changesets.count |
|
150 | 150 | [21, '21', 'adf805632193'].each do |r1| |
|
151 | 151 | get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1 |
|
152 | 152 | assert_response :success |
|
153 | 153 | assert_template 'show' |
|
154 | 154 | |
|
155 | 155 | assert_not_nil assigns(:entries) |
|
156 | 156 | assert_equal ["make-latin-1-file.rb", |
|
157 | 157 | "test-#{@char_1}-1.txt", |
|
158 | 158 | "test-#{@char_1}-2.txt", |
|
159 | 159 | "test-#{@char_1}.txt"], assigns(:entries).collect(&:name) |
|
160 | 160 | changesets = assigns(:changesets) |
|
161 | 161 | assert_not_nil changesets |
|
162 | 162 | assert_equal %w(21 20 19 18 17), changesets.collect(&:revision) |
|
163 | 163 | end |
|
164 | 164 | end |
|
165 | 165 | |
|
166 | def show_should_show_branch_selection_form | |
|
167 | @repository.fetch_changesets | |
|
168 | @project.reload | |
|
169 | get :show, :id => PRJ_ID | |
|
170 | assert_tag 'form', :attributes => {:id => 'revision_selector', :action => '/projects/subproject1/repository/show'} | |
|
171 | assert_tag 'select', :attributes => {:name => 'branch'}, | |
|
172 | :child => {:tag => 'option', :attributes => {:value => 'test-branch-01'}}, | |
|
173 | :parent => {:tag => 'form', :attributes => {:id => 'revision_selector'}} | |
|
174 | end | |
|
175 | ||
|
166 | 176 | def test_show_branch |
|
167 | 177 | assert_equal 0, @repository.changesets.count |
|
168 | 178 | @repository.fetch_changesets |
|
169 | 179 | @project.reload |
|
170 | 180 | assert_equal NUM_REV, @repository.changesets.count |
|
171 | 181 | [ |
|
172 | 182 | 'default', |
|
173 | 183 | @branch_char_1, |
|
174 | 184 | 'branch (1)[2]&,%.-3_4', |
|
175 | 185 | @branch_char_0, |
|
176 | 186 | 'test_branch.latin-1', |
|
177 | 187 | 'test-branch-00', |
|
178 | 188 | ].each do |bra| |
|
179 | 189 | get :show, :id => PRJ_ID, :rev => bra |
|
180 | 190 | assert_response :success |
|
181 | 191 | assert_template 'show' |
|
182 | 192 | assert_not_nil assigns(:entries) |
|
183 | 193 | assert assigns(:entries).size > 0 |
|
184 | 194 | assert_not_nil assigns(:changesets) |
|
185 | 195 | assert assigns(:changesets).size > 0 |
|
186 | 196 | end |
|
187 | 197 | end |
|
188 | 198 | |
|
189 | 199 | def test_show_tag |
|
190 | 200 | assert_equal 0, @repository.changesets.count |
|
191 | 201 | @repository.fetch_changesets |
|
192 | 202 | @project.reload |
|
193 | 203 | assert_equal NUM_REV, @repository.changesets.count |
|
194 | 204 | [ |
|
195 | 205 | @tag_char_1, |
|
196 | 206 | 'tag_test.00', |
|
197 | 207 | 'tag-init-revision' |
|
198 | 208 | ].each do |tag| |
|
199 | 209 | get :show, :id => PRJ_ID, :rev => tag |
|
200 | 210 | assert_response :success |
|
201 | 211 | assert_template 'show' |
|
202 | 212 | assert_not_nil assigns(:entries) |
|
203 | 213 | assert assigns(:entries).size > 0 |
|
204 | 214 | assert_not_nil assigns(:changesets) |
|
205 | 215 | assert assigns(:changesets).size > 0 |
|
206 | 216 | end |
|
207 | 217 | end |
|
208 | 218 | |
|
209 | 219 | def test_changes |
|
210 | 220 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] |
|
211 | 221 | assert_response :success |
|
212 | 222 | assert_template 'changes' |
|
213 | 223 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
214 | 224 | end |
|
215 | 225 | |
|
216 | 226 | def test_entry_show |
|
217 | 227 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
218 | 228 | assert_response :success |
|
219 | 229 | assert_template 'entry' |
|
220 | 230 | # Line 10 |
|
221 | 231 | assert_tag :tag => 'th', |
|
222 | 232 | :content => '10', |
|
223 | 233 | :attributes => { :class => 'line-num' }, |
|
224 | 234 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
225 | 235 | end |
|
226 | 236 | |
|
227 | 237 | def test_entry_show_latin_1_path |
|
228 | 238 | [21, '21', 'adf805632193'].each do |r1| |
|
229 | 239 | get :entry, :id => PRJ_ID, |
|
230 | 240 | :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1 |
|
231 | 241 | assert_response :success |
|
232 | 242 | assert_template 'entry' |
|
233 | 243 | assert_tag :tag => 'th', |
|
234 | 244 | :content => '1', |
|
235 | 245 | :attributes => { :class => 'line-num' }, |
|
236 | 246 | :sibling => { :tag => 'td', |
|
237 | 247 | :content => /Mercurial is a distributed version control system/ } |
|
238 | 248 | end |
|
239 | 249 | end |
|
240 | 250 | |
|
241 | 251 | def test_entry_show_latin_1_contents |
|
242 | 252 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
243 | 253 | [27, '27', '7bbf4c738e71'].each do |r1| |
|
244 | 254 | get :entry, :id => PRJ_ID, |
|
245 | 255 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
246 | 256 | assert_response :success |
|
247 | 257 | assert_template 'entry' |
|
248 | 258 | assert_tag :tag => 'th', |
|
249 | 259 | :content => '1', |
|
250 | 260 | :attributes => { :class => 'line-num' }, |
|
251 | 261 | :sibling => { :tag => 'td', |
|
252 | 262 | :content => /test-#{@char_1}.txt/ } |
|
253 | 263 | end |
|
254 | 264 | end |
|
255 | 265 | end |
|
256 | 266 | |
|
257 | 267 | def test_entry_download |
|
258 | 268 | get :entry, :id => PRJ_ID, |
|
259 | 269 | :path => ['sources', 'watchers_controller.rb'], :format => 'raw' |
|
260 | 270 | assert_response :success |
|
261 | 271 | # File content |
|
262 | 272 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
263 | 273 | end |
|
264 | 274 | |
|
265 | 275 | def test_entry_binary_force_download |
|
266 | 276 | get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png'] |
|
267 | 277 | assert_response :success |
|
268 | 278 | assert_equal 'image/png', @response.content_type |
|
269 | 279 | end |
|
270 | 280 | |
|
271 | 281 | def test_directory_entry |
|
272 | 282 | get :entry, :id => PRJ_ID, :path => ['sources'] |
|
273 | 283 | assert_response :success |
|
274 | 284 | assert_template 'show' |
|
275 | 285 | assert_not_nil assigns(:entry) |
|
276 | 286 | assert_equal 'sources', assigns(:entry).name |
|
277 | 287 | end |
|
278 | 288 | |
|
279 | 289 | def test_diff |
|
280 | 290 | assert_equal 0, @repository.changesets.count |
|
281 | 291 | @repository.fetch_changesets |
|
282 | 292 | @project.reload |
|
283 | 293 | assert_equal NUM_REV, @repository.changesets.count |
|
284 | 294 | [4, '4', 'def6d2f1254a'].each do |r1| |
|
285 | 295 | # Full diff of changeset 4 |
|
286 | 296 | ['inline', 'sbs'].each do |dt| |
|
287 | 297 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
288 | 298 | assert_response :success |
|
289 | 299 | assert_template 'diff' |
|
290 | 300 | if @diff_c_support |
|
291 | 301 | # Line 22 removed |
|
292 | 302 | assert_tag :tag => 'th', |
|
293 | 303 | :content => '22', |
|
294 | 304 | :sibling => { :tag => 'td', |
|
295 | 305 | :attributes => { :class => /diff_out/ }, |
|
296 | 306 | :content => /def remove/ } |
|
297 | 307 | assert_tag :tag => 'h2', :content => /4:def6d2f1254a/ |
|
298 | 308 | end |
|
299 | 309 | end |
|
300 | 310 | end |
|
301 | 311 | end |
|
302 | 312 | |
|
303 | 313 | def test_diff_two_revs |
|
304 | 314 | assert_equal 0, @repository.changesets.count |
|
305 | 315 | @repository.fetch_changesets |
|
306 | 316 | @project.reload |
|
307 | 317 | assert_equal NUM_REV, @repository.changesets.count |
|
308 | 318 | [2, '400bb8672109', '400', 400].each do |r1| |
|
309 | 319 | [4, 'def6d2f1254a'].each do |r2| |
|
310 | 320 | ['inline', 'sbs'].each do |dt| |
|
311 | 321 | get :diff, |
|
312 | 322 | :id => PRJ_ID, |
|
313 | 323 | :rev => r1, |
|
314 | 324 | :rev_to => r2, |
|
315 | 325 | :type => dt |
|
316 | 326 | assert_response :success |
|
317 | 327 | assert_template 'diff' |
|
318 | 328 | diff = assigns(:diff) |
|
319 | 329 | assert_not_nil diff |
|
320 | 330 | assert_tag :tag => 'h2', |
|
321 | 331 | :content => /4:def6d2f1254a 2:400bb8672109/ |
|
322 | 332 | end |
|
323 | 333 | end |
|
324 | 334 | end |
|
325 | 335 | end |
|
326 | 336 | |
|
327 | 337 | def test_diff_latin_1_path |
|
328 | 338 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
329 | 339 | [21, 'adf805632193'].each do |r1| |
|
330 | 340 | ['inline', 'sbs'].each do |dt| |
|
331 | 341 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
332 | 342 | assert_response :success |
|
333 | 343 | assert_template 'diff' |
|
334 | 344 | assert_tag :tag => 'thead', |
|
335 | 345 | :descendant => { |
|
336 | 346 | :tag => 'th', |
|
337 | 347 | :attributes => { :class => 'filename' } , |
|
338 | 348 | :content => /latin-1-dir\/test-#{@char_1}-2.txt/ , |
|
339 | 349 | }, |
|
340 | 350 | :sibling => { |
|
341 | 351 | :tag => 'tbody', |
|
342 | 352 | :descendant => { |
|
343 | 353 | :tag => 'td', |
|
344 | 354 | :attributes => { :class => /diff_in/ }, |
|
345 | 355 | :content => /It is written in Python/ |
|
346 | 356 | } |
|
347 | 357 | } |
|
348 | 358 | end |
|
349 | 359 | end |
|
350 | 360 | end |
|
351 | 361 | end |
|
352 | 362 | |
|
353 | 363 | def test_annotate |
|
354 | 364 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
355 | 365 | assert_response :success |
|
356 | 366 | assert_template 'annotate' |
|
357 | 367 | # Line 23, revision 4:def6d2f1254a |
|
358 | 368 | assert_tag :tag => 'th', |
|
359 | 369 | :content => '23', |
|
360 | 370 | :attributes => { :class => 'line-num' }, |
|
361 | 371 | :sibling => |
|
362 | 372 | { |
|
363 | 373 | :tag => 'td', |
|
364 | 374 | :attributes => { :class => 'revision' }, |
|
365 | 375 | :child => { :tag => 'a', :content => '4:def6d2f1254a' } |
|
366 | 376 | } |
|
367 | 377 | assert_tag :tag => 'th', |
|
368 | 378 | :content => '23', |
|
369 | 379 | :attributes => { :class => 'line-num' }, |
|
370 | 380 | :sibling => |
|
371 | 381 | { |
|
372 | 382 | :tag => 'td' , |
|
373 | 383 | :content => 'jsmith' , |
|
374 | 384 | :attributes => { :class => 'author' }, |
|
375 | 385 | } |
|
376 | 386 | assert_tag :tag => 'th', |
|
377 | 387 | :content => '23', |
|
378 | 388 | :attributes => { :class => 'line-num' }, |
|
379 | 389 | :sibling => { :tag => 'td', :content => /watcher =/ } |
|
380 | 390 | end |
|
381 | 391 | |
|
382 | 392 | def test_annotate_not_in_tip |
|
383 | 393 | assert_equal 0, @repository.changesets.count |
|
384 | 394 | @repository.fetch_changesets |
|
385 | 395 | @project.reload |
|
386 | 396 | assert_equal NUM_REV, @repository.changesets.count |
|
387 | 397 | |
|
388 | 398 | get :annotate, :id => PRJ_ID, |
|
389 | 399 | :path => ['sources', 'welcome_controller.rb'] |
|
390 | 400 | assert_response 404 |
|
391 | 401 | assert_error_tag :content => /was not found/ |
|
392 | 402 | end |
|
393 | 403 | |
|
394 | 404 | def test_annotate_at_given_revision |
|
395 | 405 | assert_equal 0, @repository.changesets.count |
|
396 | 406 | @repository.fetch_changesets |
|
397 | 407 | @project.reload |
|
398 | 408 | assert_equal NUM_REV, @repository.changesets.count |
|
399 | 409 | [2, '400bb8672109', '400', 400].each do |r1| |
|
400 | 410 | get :annotate, :id => PRJ_ID, :rev => r1, |
|
401 | 411 | :path => ['sources', 'watchers_controller.rb'] |
|
402 | 412 | assert_response :success |
|
403 | 413 | assert_template 'annotate' |
|
404 | 414 | assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/ |
|
405 | 415 | end |
|
406 | 416 | end |
|
407 | 417 | |
|
408 | 418 | def test_annotate_latin_1_path |
|
409 | 419 | [21, '21', 'adf805632193'].each do |r1| |
|
410 | 420 | get :annotate, :id => PRJ_ID, |
|
411 | 421 | :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1 |
|
412 | 422 | assert_response :success |
|
413 | 423 | assert_template 'annotate' |
|
414 | 424 | assert_tag :tag => 'th', |
|
415 | 425 | :content => '1', |
|
416 | 426 | :attributes => { :class => 'line-num' }, |
|
417 | 427 | :sibling => |
|
418 | 428 | { |
|
419 | 429 | :tag => 'td', |
|
420 | 430 | :attributes => { :class => 'revision' }, |
|
421 | 431 | :child => { :tag => 'a', :content => '20:709858aafd1b' } |
|
422 | 432 | } |
|
423 | 433 | assert_tag :tag => 'th', |
|
424 | 434 | :content => '1', |
|
425 | 435 | :attributes => { :class => 'line-num' }, |
|
426 | 436 | :sibling => |
|
427 | 437 | { |
|
428 | 438 | :tag => 'td' , |
|
429 | 439 | :content => 'jsmith' , |
|
430 | 440 | :attributes => { :class => 'author' }, |
|
431 | 441 | } |
|
432 | 442 | assert_tag :tag => 'th', |
|
433 | 443 | :content => '1', |
|
434 | 444 | :attributes => { :class => 'line-num' }, |
|
435 | 445 | :sibling => { :tag => 'td', |
|
436 | 446 | :content => /Mercurial is a distributed version control system/ } |
|
437 | 447 | |
|
438 | 448 | end |
|
439 | 449 | end |
|
440 | 450 | |
|
441 | 451 | def test_annotate_latin_1_contents |
|
442 | 452 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
443 | 453 | [27, '7bbf4c738e71'].each do |r1| |
|
444 | 454 | get :annotate, :id => PRJ_ID, |
|
445 | 455 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
446 | 456 | assert_tag :tag => 'th', |
|
447 | 457 | :content => '1', |
|
448 | 458 | :attributes => { :class => 'line-num' }, |
|
449 | 459 | :sibling => { :tag => 'td', |
|
450 | 460 | :content => /test-#{@char_1}.txt/ } |
|
451 | 461 | end |
|
452 | 462 | end |
|
453 | 463 | end |
|
454 | 464 | |
|
455 | 465 | def test_empty_revision |
|
456 | 466 | assert_equal 0, @repository.changesets.count |
|
457 | 467 | @repository.fetch_changesets |
|
458 | 468 | @project.reload |
|
459 | 469 | assert_equal NUM_REV, @repository.changesets.count |
|
460 | 470 | ['', ' ', nil].each do |r| |
|
461 | 471 | get :revision, :id => PRJ_ID, :rev => r |
|
462 | 472 | assert_response 404 |
|
463 | 473 | assert_error_tag :content => /was not found/ |
|
464 | 474 | end |
|
465 | 475 | end |
|
466 | 476 | |
|
467 | 477 | def test_destroy_valid_repository |
|
468 | 478 | @request.session[:user_id] = 1 # admin |
|
469 | 479 | assert_equal 0, @repository.changesets.count |
|
470 | 480 | @repository.fetch_changesets |
|
471 | 481 | assert_equal NUM_REV, @repository.changesets.count |
|
472 | 482 | |
|
473 | 483 | assert_difference 'Repository.count', -1 do |
|
474 | 484 | delete :destroy, :id => @repository.id |
|
475 | 485 | end |
|
476 | 486 | assert_response 302 |
|
477 | 487 | @project.reload |
|
478 | 488 | assert_nil @project.repository |
|
479 | 489 | end |
|
480 | 490 | |
|
481 | 491 | def test_destroy_invalid_repository |
|
482 | 492 | @request.session[:user_id] = 1 # admin |
|
483 | 493 | @project.repository.destroy |
|
484 | 494 | @repository = Repository::Mercurial.create!( |
|
485 | 495 | :project => Project.find(PRJ_ID), |
|
486 | 496 | :url => "/invalid", |
|
487 | 497 | :path_encoding => 'ISO-8859-1' |
|
488 | 498 | ) |
|
489 | 499 | @repository.fetch_changesets |
|
490 | 500 | assert_equal 0, @repository.changesets.count |
|
491 | 501 | |
|
492 | 502 | assert_difference 'Repository.count', -1 do |
|
493 | 503 | delete :destroy, :id => @repository.id |
|
494 | 504 | end |
|
495 | 505 | assert_response 302 |
|
496 | 506 | @project.reload |
|
497 | 507 | assert_nil @project.repository |
|
498 | 508 | end |
|
499 | 509 | else |
|
500 | 510 | puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!" |
|
501 | 511 | def test_fake; assert true end |
|
502 | 512 | end |
|
503 | 513 | end |
General Comments 0
You need to be logged in to leave comments.
Login now