##// END OF EJS Templates
Rails3: test: scm: subversion: use "repository_path_hash" for path param...
Toshi MARUYAMA -
r8810:5033a155b3e5
parent child
Show More
@@ -1,383 +1,397
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 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.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class RepositoriesSubversionControllerTest < ActionController::TestCase
20 class RepositoriesSubversionControllerTest < ActionController::TestCase
21 tests RepositoriesController
21 tests RepositoriesController
22
22
23 fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules,
23 fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules,
24 :repositories, :issues, :issue_statuses, :changesets, :changes,
24 :repositories, :issues, :issue_statuses, :changesets, :changes,
25 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
25 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
26
26
27 PRJ_ID = 3
27 PRJ_ID = 3
28 NUM_REV = 11
28 NUM_REV = 11
29
29
30 def setup
30 def setup
31 Setting.default_language = 'en'
31 Setting.default_language = 'en'
32 User.current = nil
32 User.current = nil
33
33
34 @project = Project.find(PRJ_ID)
34 @project = Project.find(PRJ_ID)
35 @repository = Repository::Subversion.create(:project => @project,
35 @repository = Repository::Subversion.create(:project => @project,
36 :url => self.class.subversion_repository_url)
36 :url => self.class.subversion_repository_url)
37 assert @repository
37 assert @repository
38 end
38 end
39
39
40 if repository_configured?('subversion')
40 if repository_configured?('subversion')
41 def test_new
41 def test_new
42 @request.session[:user_id] = 1
42 @request.session[:user_id] = 1
43 @project.repository.destroy
43 @project.repository.destroy
44 get :new, :project_id => 'subproject1', :repository_scm => 'Subversion'
44 get :new, :project_id => 'subproject1', :repository_scm => 'Subversion'
45 assert_response :success
45 assert_response :success
46 assert_template 'new'
46 assert_template 'new'
47 assert_kind_of Repository::Subversion, assigns(:repository)
47 assert_kind_of Repository::Subversion, assigns(:repository)
48 assert assigns(:repository).new_record?
48 assert assigns(:repository).new_record?
49 end
49 end
50
50
51 def test_show
51 def test_show
52 assert_equal 0, @repository.changesets.count
52 assert_equal 0, @repository.changesets.count
53 @repository.fetch_changesets
53 @repository.fetch_changesets
54 @project.reload
54 @project.reload
55 assert_equal NUM_REV, @repository.changesets.count
55 assert_equal NUM_REV, @repository.changesets.count
56 get :show, :id => PRJ_ID
56 get :show, :id => PRJ_ID
57 assert_response :success
57 assert_response :success
58 assert_template 'show'
58 assert_template 'show'
59 assert_not_nil assigns(:entries)
59 assert_not_nil assigns(:entries)
60 assert_not_nil assigns(:changesets)
60 assert_not_nil assigns(:changesets)
61
61
62 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
62 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
63 assert_not_nil entry
63 assert_not_nil entry
64 assert_equal 'dir', entry.kind
64 assert_equal 'dir', entry.kind
65
65
66 assert_tag 'input', :attributes => {:name => 'rev'}
66 assert_tag 'input', :attributes => {:name => 'rev'}
67 assert_tag 'a', :content => 'Statistics'
67 assert_tag 'a', :content => 'Statistics'
68 assert_tag 'a', :content => 'Atom'
68 assert_tag 'a', :content => 'Atom'
69 end
69 end
70
70
71 def test_browse_directory
71 def test_browse_directory
72 assert_equal 0, @repository.changesets.count
72 assert_equal 0, @repository.changesets.count
73 @repository.fetch_changesets
73 @repository.fetch_changesets
74 @project.reload
74 @project.reload
75 assert_equal NUM_REV, @repository.changesets.count
75 assert_equal NUM_REV, @repository.changesets.count
76 get :show, :id => PRJ_ID, :path => ['subversion_test']
76 get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param]
77 assert_response :success
77 assert_response :success
78 assert_template 'show'
78 assert_template 'show'
79 assert_not_nil assigns(:entries)
79 assert_not_nil assigns(:entries)
80 assert_equal [
80 assert_equal [
81 '[folder_with_brackets]', 'folder', '.project',
81 '[folder_with_brackets]', 'folder', '.project',
82 'helloworld.c', 'textfile.txt'
82 'helloworld.c', 'textfile.txt'
83 ],
83 ],
84 assigns(:entries).collect(&:name)
84 assigns(:entries).collect(&:name)
85 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
85 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
86 assert_equal 'file', entry.kind
86 assert_equal 'file', entry.kind
87 assert_equal 'subversion_test/helloworld.c', entry.path
87 assert_equal 'subversion_test/helloworld.c', entry.path
88 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ }
88 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ }
89 end
89 end
90
90
91 def test_browse_at_given_revision
91 def test_browse_at_given_revision
92 assert_equal 0, @repository.changesets.count
92 assert_equal 0, @repository.changesets.count
93 @repository.fetch_changesets
93 @repository.fetch_changesets
94 @project.reload
94 @project.reload
95 assert_equal NUM_REV, @repository.changesets.count
95 assert_equal NUM_REV, @repository.changesets.count
96 get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4
96 get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param],
97 :rev => 4
97 assert_response :success
98 assert_response :success
98 assert_template 'show'
99 assert_template 'show'
99 assert_not_nil assigns(:entries)
100 assert_not_nil assigns(:entries)
100 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'],
101 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'],
101 assigns(:entries).collect(&:name)
102 assigns(:entries).collect(&:name)
102 end
103 end
103
104
104 def test_file_changes
105 def test_file_changes
105 assert_equal 0, @repository.changesets.count
106 assert_equal 0, @repository.changesets.count
106 @repository.fetch_changesets
107 @repository.fetch_changesets
107 @project.reload
108 @project.reload
108 assert_equal NUM_REV, @repository.changesets.count
109 assert_equal NUM_REV, @repository.changesets.count
109 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
110 get :changes, :id => PRJ_ID,
111 :path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param]
110 assert_response :success
112 assert_response :success
111 assert_template 'changes'
113 assert_template 'changes'
112
114
113 changesets = assigns(:changesets)
115 changesets = assigns(:changesets)
114 assert_not_nil changesets
116 assert_not_nil changesets
115 assert_equal %w(6 3 2), changesets.collect(&:revision)
117 assert_equal %w(6 3 2), changesets.collect(&:revision)
116
118
117 # svn properties displayed with svn >= 1.5 only
119 # svn properties displayed with svn >= 1.5 only
118 if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
120 if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
119 assert_not_nil assigns(:properties)
121 assert_not_nil assigns(:properties)
120 assert_equal 'native', assigns(:properties)['svn:eol-style']
122 assert_equal 'native', assigns(:properties)['svn:eol-style']
121 assert_tag :ul,
123 assert_tag :ul,
122 :child => { :tag => 'li',
124 :child => { :tag => 'li',
123 :child => { :tag => 'b', :content => 'svn:eol-style' },
125 :child => { :tag => 'b', :content => 'svn:eol-style' },
124 :child => { :tag => 'span', :content => 'native' } }
126 :child => { :tag => 'span', :content => 'native' } }
125 end
127 end
126 end
128 end
127
129
128 def test_directory_changes
130 def test_directory_changes
129 assert_equal 0, @repository.changesets.count
131 assert_equal 0, @repository.changesets.count
130 @repository.fetch_changesets
132 @repository.fetch_changesets
131 @project.reload
133 @project.reload
132 assert_equal NUM_REV, @repository.changesets.count
134 assert_equal NUM_REV, @repository.changesets.count
133 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ]
135 get :changes, :id => PRJ_ID,
136 :path => repository_path_hash(['subversion_test', 'folder'])[:param]
134 assert_response :success
137 assert_response :success
135 assert_template 'changes'
138 assert_template 'changes'
136
139
137 changesets = assigns(:changesets)
140 changesets = assigns(:changesets)
138 assert_not_nil changesets
141 assert_not_nil changesets
139 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision)
142 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision)
140 end
143 end
141
144
142 def test_entry
145 def test_entry
143 assert_equal 0, @repository.changesets.count
146 assert_equal 0, @repository.changesets.count
144 @repository.fetch_changesets
147 @repository.fetch_changesets
145 @project.reload
148 @project.reload
146 assert_equal NUM_REV, @repository.changesets.count
149 assert_equal NUM_REV, @repository.changesets.count
147 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
150 get :entry, :id => PRJ_ID,
151 :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
148 assert_response :success
152 assert_response :success
149 assert_template 'entry'
153 assert_template 'entry'
150 end
154 end
151
155
152 def test_entry_should_send_if_too_big
156 def test_entry_should_send_if_too_big
153 assert_equal 0, @repository.changesets.count
157 assert_equal 0, @repository.changesets.count
154 @repository.fetch_changesets
158 @repository.fetch_changesets
155 @project.reload
159 @project.reload
156 assert_equal NUM_REV, @repository.changesets.count
160 assert_equal NUM_REV, @repository.changesets.count
157 # no files in the test repo is larger than 1KB...
161 # no files in the test repo is larger than 1KB...
158 with_settings :file_max_size_displayed => 0 do
162 with_settings :file_max_size_displayed => 0 do
159 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
163 get :entry, :id => PRJ_ID,
164 :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
160 assert_response :success
165 assert_response :success
161 assert_template ''
166 assert_template ''
162 assert_equal 'attachment; filename="helloworld.c"',
167 assert_equal 'attachment; filename="helloworld.c"',
163 @response.headers['Content-Disposition']
168 @response.headers['Content-Disposition']
164 end
169 end
165 end
170 end
166
171
167 def test_entry_at_given_revision
172 def test_entry_at_given_revision
168 assert_equal 0, @repository.changesets.count
173 assert_equal 0, @repository.changesets.count
169 @repository.fetch_changesets
174 @repository.fetch_changesets
170 @project.reload
175 @project.reload
171 assert_equal NUM_REV, @repository.changesets.count
176 assert_equal NUM_REV, @repository.changesets.count
172 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
177 get :entry, :id => PRJ_ID,
178 :path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param],
179 :rev => 2
173 assert_response :success
180 assert_response :success
174 assert_template 'entry'
181 assert_template 'entry'
175 # this line was removed in r3 and file was moved in r6
182 # this line was removed in r3 and file was moved in r6
176 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
183 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
177 :content => /Here's the code/
184 :content => /Here's the code/
178 end
185 end
179
186
180 def test_entry_not_found
187 def test_entry_not_found
181 assert_equal 0, @repository.changesets.count
188 assert_equal 0, @repository.changesets.count
182 @repository.fetch_changesets
189 @repository.fetch_changesets
183 @project.reload
190 @project.reload
184 assert_equal NUM_REV, @repository.changesets.count
191 assert_equal NUM_REV, @repository.changesets.count
185 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c']
192 get :entry, :id => PRJ_ID,
193 :path => repository_path_hash(['subversion_test', 'zzz.c'])[:param]
186 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
194 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
187 :content => /The entry or revision was not found in the repository/
195 :content => /The entry or revision was not found in the repository/
188 end
196 end
189
197
190 def test_entry_download
198 def test_entry_download
191 assert_equal 0, @repository.changesets.count
199 assert_equal 0, @repository.changesets.count
192 @repository.fetch_changesets
200 @repository.fetch_changesets
193 @project.reload
201 @project.reload
194 assert_equal NUM_REV, @repository.changesets.count
202 assert_equal NUM_REV, @repository.changesets.count
195 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
203 get :entry, :id => PRJ_ID,
204 :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param],
205 :format => 'raw'
196 assert_response :success
206 assert_response :success
197 assert_template ''
207 assert_template ''
198 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
208 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
199 end
209 end
200
210
201 def test_directory_entry
211 def test_directory_entry
202 assert_equal 0, @repository.changesets.count
212 assert_equal 0, @repository.changesets.count
203 @repository.fetch_changesets
213 @repository.fetch_changesets
204 @project.reload
214 @project.reload
205 assert_equal NUM_REV, @repository.changesets.count
215 assert_equal NUM_REV, @repository.changesets.count
206 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder']
216 get :entry, :id => PRJ_ID,
217 :path => repository_path_hash(['subversion_test', 'folder'])[:param]
207 assert_response :success
218 assert_response :success
208 assert_template 'show'
219 assert_template 'show'
209 assert_not_nil assigns(:entry)
220 assert_not_nil assigns(:entry)
210 assert_equal 'folder', assigns(:entry).name
221 assert_equal 'folder', assigns(:entry).name
211 end
222 end
212
223
213 # TODO: this test needs fixtures.
224 # TODO: this test needs fixtures.
214 def test_revision
225 def test_revision
215 get :revision, :id => 1, :rev => 2
226 get :revision, :id => 1, :rev => 2
216 assert_response :success
227 assert_response :success
217 assert_template 'revision'
228 assert_template 'revision'
218 assert_tag :tag => 'ul',
229 assert_tag :tag => 'ul',
219 :child => { :tag => 'li',
230 :child => { :tag => 'li',
220 # link to the entry at rev 2
231 # link to the entry at rev 2
221 :child => { :tag => 'a',
232 :child => { :tag => 'a',
222 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'},
233 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'},
223 :content => 'repo',
234 :content => 'repo',
224 # link to partial diff
235 # link to partial diff
225 :sibling => { :tag => 'a',
236 :sibling => { :tag => 'a',
226 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' }
237 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' }
227 }
238 }
228 }
239 }
229 }
240 }
230 end
241 end
231
242
232 def test_invalid_revision
243 def test_invalid_revision
233 assert_equal 0, @repository.changesets.count
244 assert_equal 0, @repository.changesets.count
234 @repository.fetch_changesets
245 @repository.fetch_changesets
235 @project.reload
246 @project.reload
236 assert_equal NUM_REV, @repository.changesets.count
247 assert_equal NUM_REV, @repository.changesets.count
237 get :revision, :id => PRJ_ID, :rev => 'something_weird'
248 get :revision, :id => PRJ_ID, :rev => 'something_weird'
238 assert_response 404
249 assert_response 404
239 assert_error_tag :content => /was not found/
250 assert_error_tag :content => /was not found/
240 end
251 end
241
252
242 def test_invalid_revision_diff
253 def test_invalid_revision_diff
243 get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird'
254 get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird'
244 assert_response 404
255 assert_response 404
245 assert_error_tag :content => /was not found/
256 assert_error_tag :content => /was not found/
246 end
257 end
247
258
248 def test_empty_revision
259 def test_empty_revision
249 assert_equal 0, @repository.changesets.count
260 assert_equal 0, @repository.changesets.count
250 @repository.fetch_changesets
261 @repository.fetch_changesets
251 @project.reload
262 @project.reload
252 assert_equal NUM_REV, @repository.changesets.count
263 assert_equal NUM_REV, @repository.changesets.count
253 ['', ' ', nil].each do |r|
264 ['', ' ', nil].each do |r|
254 get :revision, :id => PRJ_ID, :rev => r
265 get :revision, :id => PRJ_ID, :rev => r
255 assert_response 404
266 assert_response 404
256 assert_error_tag :content => /was not found/
267 assert_error_tag :content => /was not found/
257 end
268 end
258 end
269 end
259
270
260 # TODO: this test needs fixtures.
271 # TODO: this test needs fixtures.
261 def test_revision_with_repository_pointing_to_a_subdirectory
272 def test_revision_with_repository_pointing_to_a_subdirectory
262 r = Project.find(1).repository
273 r = Project.find(1).repository
263 # Changes repository url to a subdirectory
274 # Changes repository url to a subdirectory
264 r.update_attribute :url, (r.url + '/test/some')
275 r.update_attribute :url, (r.url + '/test/some')
265
276
266 get :revision, :id => 1, :rev => 2
277 get :revision, :id => 1, :rev => 2
267 assert_response :success
278 assert_response :success
268 assert_template 'revision'
279 assert_template 'revision'
269 assert_tag :tag => 'ul',
280 assert_tag :tag => 'ul',
270 :child => { :tag => 'li',
281 :child => { :tag => 'li',
271 # link to the entry at rev 2
282 # link to the entry at rev 2
272 :child => { :tag => 'a',
283 :child => { :tag => 'a',
273 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'},
284 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'},
274 :content => 'repo',
285 :content => 'repo',
275 # link to partial diff
286 # link to partial diff
276 :sibling => { :tag => 'a',
287 :sibling => { :tag => 'a',
277 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' }
288 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' }
278 }
289 }
279 }
290 }
280 }
291 }
281 end
292 end
282
293
283 def test_revision_diff
294 def test_revision_diff
284 assert_equal 0, @repository.changesets.count
295 assert_equal 0, @repository.changesets.count
285 @repository.fetch_changesets
296 @repository.fetch_changesets
286 @project.reload
297 @project.reload
287 assert_equal NUM_REV, @repository.changesets.count
298 assert_equal NUM_REV, @repository.changesets.count
288 ['inline', 'sbs'].each do |dt|
299 ['inline', 'sbs'].each do |dt|
289 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
300 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
290 assert_response :success
301 assert_response :success
291 assert_template 'diff'
302 assert_template 'diff'
292 assert_tag :tag => 'h2',
303 assert_tag :tag => 'h2',
293 :content => / 3/
304 :content => / 3/
294 end
305 end
295 end
306 end
296
307
297 def test_revision_diff_raw_format
308 def test_revision_diff_raw_format
298 assert_equal 0, @repository.changesets.count
309 assert_equal 0, @repository.changesets.count
299 @repository.fetch_changesets
310 @repository.fetch_changesets
300 @project.reload
311 @project.reload
301 assert_equal NUM_REV, @repository.changesets.count
312 assert_equal NUM_REV, @repository.changesets.count
302
313
303 get :diff, :id => PRJ_ID, :rev => 3, :format => 'diff'
314 get :diff, :id => PRJ_ID, :rev => 3, :format => 'diff'
304 assert_response :success
315 assert_response :success
305 assert_equal 'text/x-patch', @response.content_type
316 assert_equal 'text/x-patch', @response.content_type
306 assert_equal 'Index: subversion_test/textfile.txt', @response.body.split(/\r?\n/).first
317 assert_equal 'Index: subversion_test/textfile.txt', @response.body.split(/\r?\n/).first
307 end
318 end
308
319
309 def test_directory_diff
320 def test_directory_diff
310 assert_equal 0, @repository.changesets.count
321 assert_equal 0, @repository.changesets.count
311 @repository.fetch_changesets
322 @repository.fetch_changesets
312 @project.reload
323 @project.reload
313 assert_equal NUM_REV, @repository.changesets.count
324 assert_equal NUM_REV, @repository.changesets.count
314 ['inline', 'sbs'].each do |dt|
325 ['inline', 'sbs'].each do |dt|
315 get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2,
326 get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2,
316 :path => ['subversion_test', 'folder'], :type => dt
327 :path => repository_path_hash(['subversion_test', 'folder'])[:param],
328 :type => dt
317 assert_response :success
329 assert_response :success
318 assert_template 'diff'
330 assert_template 'diff'
319
331
320 diff = assigns(:diff)
332 diff = assigns(:diff)
321 assert_not_nil diff
333 assert_not_nil diff
322 # 2 files modified
334 # 2 files modified
323 assert_equal 2, Redmine::UnifiedDiff.new(diff).size
335 assert_equal 2, Redmine::UnifiedDiff.new(diff).size
324 assert_tag :tag => 'h2', :content => /2:6/
336 assert_tag :tag => 'h2', :content => /2:6/
325 end
337 end
326 end
338 end
327
339
328 def test_annotate
340 def test_annotate
329 assert_equal 0, @repository.changesets.count
341 assert_equal 0, @repository.changesets.count
330 @repository.fetch_changesets
342 @repository.fetch_changesets
331 @project.reload
343 @project.reload
332 assert_equal NUM_REV, @repository.changesets.count
344 assert_equal NUM_REV, @repository.changesets.count
333 get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
345 get :annotate, :id => PRJ_ID,
346 :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
334 assert_response :success
347 assert_response :success
335 assert_template 'annotate'
348 assert_template 'annotate'
336 end
349 end
337
350
338 def test_annotate_at_given_revision
351 def test_annotate_at_given_revision
339 assert_equal 0, @repository.changesets.count
352 assert_equal 0, @repository.changesets.count
340 @repository.fetch_changesets
353 @repository.fetch_changesets
341 @project.reload
354 @project.reload
342 assert_equal NUM_REV, @repository.changesets.count
355 assert_equal NUM_REV, @repository.changesets.count
343 get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c']
356 get :annotate, :id => PRJ_ID, :rev => 8,
357 :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
344 assert_response :success
358 assert_response :success
345 assert_template 'annotate'
359 assert_template 'annotate'
346 assert_tag :tag => 'h2', :content => /@ 8/
360 assert_tag :tag => 'h2', :content => /@ 8/
347 end
361 end
348
362
349 def test_destroy_valid_repository
363 def test_destroy_valid_repository
350 @request.session[:user_id] = 1 # admin
364 @request.session[:user_id] = 1 # admin
351 assert_equal 0, @repository.changesets.count
365 assert_equal 0, @repository.changesets.count
352 @repository.fetch_changesets
366 @repository.fetch_changesets
353 assert_equal NUM_REV, @repository.changesets.count
367 assert_equal NUM_REV, @repository.changesets.count
354
368
355 assert_difference 'Repository.count', -1 do
369 assert_difference 'Repository.count', -1 do
356 delete :destroy, :id => @repository.id
370 delete :destroy, :id => @repository.id
357 end
371 end
358 assert_response 302
372 assert_response 302
359 @project.reload
373 @project.reload
360 assert_nil @project.repository
374 assert_nil @project.repository
361 end
375 end
362
376
363 def test_destroy_invalid_repository
377 def test_destroy_invalid_repository
364 @request.session[:user_id] = 1 # admin
378 @request.session[:user_id] = 1 # admin
365 @project.repository.destroy
379 @project.repository.destroy
366 @repository = Repository::Subversion.create!(
380 @repository = Repository::Subversion.create!(
367 :project => @project,
381 :project => @project,
368 :url => "file:///invalid")
382 :url => "file:///invalid")
369 @repository.fetch_changesets
383 @repository.fetch_changesets
370 assert_equal 0, @repository.changesets.count
384 assert_equal 0, @repository.changesets.count
371
385
372 assert_difference 'Repository.count', -1 do
386 assert_difference 'Repository.count', -1 do
373 delete :destroy, :id => @repository.id
387 delete :destroy, :id => @repository.id
374 end
388 end
375 assert_response 302
389 assert_response 302
376 @project.reload
390 @project.reload
377 assert_nil @project.repository
391 assert_nil @project.repository
378 end
392 end
379 else
393 else
380 puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
394 puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
381 def test_fake; assert true end
395 def test_fake; assert true end
382 end
396 end
383 end
397 end
General Comments 0
You need to be logged in to leave comments. Login now