##// END OF EJS Templates
Removed duplicated test....
Jean-Philippe Lang -
r8546:141630e771d2
parent child
Show More
@@ -1,392 +1,383
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'}
63 assert_not_nil entry
64 assert_equal 'dir', entry.kind
65
62 assert_tag 'input', :attributes => {:name => 'rev'}
66 assert_tag 'input', :attributes => {:name => 'rev'}
63 assert_tag 'a', :content => 'Statistics'
67 assert_tag 'a', :content => 'Statistics'
64 assert_tag 'a', :content => 'Atom'
68 assert_tag 'a', :content => 'Atom'
65 end
69 end
66
70
67 def test_browse_root
68 assert_equal 0, @repository.changesets.count
69 @repository.fetch_changesets
70 @project.reload
71 assert_equal NUM_REV, @repository.changesets.count
72 get :show, :id => PRJ_ID
73 assert_response :success
74 assert_template 'show'
75 assert_not_nil assigns(:entries)
76 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
77 assert_equal 'dir', entry.kind
78 end
79
80 def test_browse_directory
71 def test_browse_directory
81 assert_equal 0, @repository.changesets.count
72 assert_equal 0, @repository.changesets.count
82 @repository.fetch_changesets
73 @repository.fetch_changesets
83 @project.reload
74 @project.reload
84 assert_equal NUM_REV, @repository.changesets.count
75 assert_equal NUM_REV, @repository.changesets.count
85 get :show, :id => PRJ_ID, :path => ['subversion_test']
76 get :show, :id => PRJ_ID, :path => ['subversion_test']
86 assert_response :success
77 assert_response :success
87 assert_template 'show'
78 assert_template 'show'
88 assert_not_nil assigns(:entries)
79 assert_not_nil assigns(:entries)
89 assert_equal [
80 assert_equal [
90 '[folder_with_brackets]', 'folder', '.project',
81 '[folder_with_brackets]', 'folder', '.project',
91 'helloworld.c', 'textfile.txt'
82 'helloworld.c', 'textfile.txt'
92 ],
83 ],
93 assigns(:entries).collect(&:name)
84 assigns(:entries).collect(&:name)
94 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
85 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
95 assert_equal 'file', entry.kind
86 assert_equal 'file', entry.kind
96 assert_equal 'subversion_test/helloworld.c', entry.path
87 assert_equal 'subversion_test/helloworld.c', entry.path
97 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ }
88 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ }
98 end
89 end
99
90
100 def test_browse_at_given_revision
91 def test_browse_at_given_revision
101 assert_equal 0, @repository.changesets.count
92 assert_equal 0, @repository.changesets.count
102 @repository.fetch_changesets
93 @repository.fetch_changesets
103 @project.reload
94 @project.reload
104 assert_equal NUM_REV, @repository.changesets.count
95 assert_equal NUM_REV, @repository.changesets.count
105 get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4
96 get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4
106 assert_response :success
97 assert_response :success
107 assert_template 'show'
98 assert_template 'show'
108 assert_not_nil assigns(:entries)
99 assert_not_nil assigns(:entries)
109 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'],
100 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'],
110 assigns(:entries).collect(&:name)
101 assigns(:entries).collect(&:name)
111 end
102 end
112
103
113 def test_file_changes
104 def test_file_changes
114 assert_equal 0, @repository.changesets.count
105 assert_equal 0, @repository.changesets.count
115 @repository.fetch_changesets
106 @repository.fetch_changesets
116 @project.reload
107 @project.reload
117 assert_equal NUM_REV, @repository.changesets.count
108 assert_equal NUM_REV, @repository.changesets.count
118 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
109 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
119 assert_response :success
110 assert_response :success
120 assert_template 'changes'
111 assert_template 'changes'
121
112
122 changesets = assigns(:changesets)
113 changesets = assigns(:changesets)
123 assert_not_nil changesets
114 assert_not_nil changesets
124 assert_equal %w(6 3 2), changesets.collect(&:revision)
115 assert_equal %w(6 3 2), changesets.collect(&:revision)
125
116
126 # svn properties displayed with svn >= 1.5 only
117 # svn properties displayed with svn >= 1.5 only
127 if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
118 if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
128 assert_not_nil assigns(:properties)
119 assert_not_nil assigns(:properties)
129 assert_equal 'native', assigns(:properties)['svn:eol-style']
120 assert_equal 'native', assigns(:properties)['svn:eol-style']
130 assert_tag :ul,
121 assert_tag :ul,
131 :child => { :tag => 'li',
122 :child => { :tag => 'li',
132 :child => { :tag => 'b', :content => 'svn:eol-style' },
123 :child => { :tag => 'b', :content => 'svn:eol-style' },
133 :child => { :tag => 'span', :content => 'native' } }
124 :child => { :tag => 'span', :content => 'native' } }
134 end
125 end
135 end
126 end
136
127
137 def test_directory_changes
128 def test_directory_changes
138 assert_equal 0, @repository.changesets.count
129 assert_equal 0, @repository.changesets.count
139 @repository.fetch_changesets
130 @repository.fetch_changesets
140 @project.reload
131 @project.reload
141 assert_equal NUM_REV, @repository.changesets.count
132 assert_equal NUM_REV, @repository.changesets.count
142 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ]
133 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ]
143 assert_response :success
134 assert_response :success
144 assert_template 'changes'
135 assert_template 'changes'
145
136
146 changesets = assigns(:changesets)
137 changesets = assigns(:changesets)
147 assert_not_nil changesets
138 assert_not_nil changesets
148 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision)
139 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision)
149 end
140 end
150
141
151 def test_entry
142 def test_entry
152 assert_equal 0, @repository.changesets.count
143 assert_equal 0, @repository.changesets.count
153 @repository.fetch_changesets
144 @repository.fetch_changesets
154 @project.reload
145 @project.reload
155 assert_equal NUM_REV, @repository.changesets.count
146 assert_equal NUM_REV, @repository.changesets.count
156 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
147 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
157 assert_response :success
148 assert_response :success
158 assert_template 'entry'
149 assert_template 'entry'
159 end
150 end
160
151
161 def test_entry_should_send_if_too_big
152 def test_entry_should_send_if_too_big
162 assert_equal 0, @repository.changesets.count
153 assert_equal 0, @repository.changesets.count
163 @repository.fetch_changesets
154 @repository.fetch_changesets
164 @project.reload
155 @project.reload
165 assert_equal NUM_REV, @repository.changesets.count
156 assert_equal NUM_REV, @repository.changesets.count
166 # no files in the test repo is larger than 1KB...
157 # no files in the test repo is larger than 1KB...
167 with_settings :file_max_size_displayed => 0 do
158 with_settings :file_max_size_displayed => 0 do
168 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
159 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
169 assert_response :success
160 assert_response :success
170 assert_template ''
161 assert_template ''
171 assert_equal 'attachment; filename="helloworld.c"',
162 assert_equal 'attachment; filename="helloworld.c"',
172 @response.headers['Content-Disposition']
163 @response.headers['Content-Disposition']
173 end
164 end
174 end
165 end
175
166
176 def test_entry_at_given_revision
167 def test_entry_at_given_revision
177 assert_equal 0, @repository.changesets.count
168 assert_equal 0, @repository.changesets.count
178 @repository.fetch_changesets
169 @repository.fetch_changesets
179 @project.reload
170 @project.reload
180 assert_equal NUM_REV, @repository.changesets.count
171 assert_equal NUM_REV, @repository.changesets.count
181 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
172 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
182 assert_response :success
173 assert_response :success
183 assert_template 'entry'
174 assert_template 'entry'
184 # this line was removed in r3 and file was moved in r6
175 # this line was removed in r3 and file was moved in r6
185 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
176 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
186 :content => /Here's the code/
177 :content => /Here's the code/
187 end
178 end
188
179
189 def test_entry_not_found
180 def test_entry_not_found
190 assert_equal 0, @repository.changesets.count
181 assert_equal 0, @repository.changesets.count
191 @repository.fetch_changesets
182 @repository.fetch_changesets
192 @project.reload
183 @project.reload
193 assert_equal NUM_REV, @repository.changesets.count
184 assert_equal NUM_REV, @repository.changesets.count
194 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c']
185 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c']
195 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
186 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
196 :content => /The entry or revision was not found in the repository/
187 :content => /The entry or revision was not found in the repository/
197 end
188 end
198
189
199 def test_entry_download
190 def test_entry_download
200 assert_equal 0, @repository.changesets.count
191 assert_equal 0, @repository.changesets.count
201 @repository.fetch_changesets
192 @repository.fetch_changesets
202 @project.reload
193 @project.reload
203 assert_equal NUM_REV, @repository.changesets.count
194 assert_equal NUM_REV, @repository.changesets.count
204 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
195 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
205 assert_response :success
196 assert_response :success
206 assert_template ''
197 assert_template ''
207 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
198 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
208 end
199 end
209
200
210 def test_directory_entry
201 def test_directory_entry
211 assert_equal 0, @repository.changesets.count
202 assert_equal 0, @repository.changesets.count
212 @repository.fetch_changesets
203 @repository.fetch_changesets
213 @project.reload
204 @project.reload
214 assert_equal NUM_REV, @repository.changesets.count
205 assert_equal NUM_REV, @repository.changesets.count
215 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder']
206 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder']
216 assert_response :success
207 assert_response :success
217 assert_template 'show'
208 assert_template 'show'
218 assert_not_nil assigns(:entry)
209 assert_not_nil assigns(:entry)
219 assert_equal 'folder', assigns(:entry).name
210 assert_equal 'folder', assigns(:entry).name
220 end
211 end
221
212
222 # TODO: this test needs fixtures.
213 # TODO: this test needs fixtures.
223 def test_revision
214 def test_revision
224 get :revision, :id => 1, :rev => 2
215 get :revision, :id => 1, :rev => 2
225 assert_response :success
216 assert_response :success
226 assert_template 'revision'
217 assert_template 'revision'
227 assert_tag :tag => 'ul',
218 assert_tag :tag => 'ul',
228 :child => { :tag => 'li',
219 :child => { :tag => 'li',
229 # link to the entry at rev 2
220 # link to the entry at rev 2
230 :child => { :tag => 'a',
221 :child => { :tag => 'a',
231 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'},
222 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'},
232 :content => 'repo',
223 :content => 'repo',
233 # link to partial diff
224 # link to partial diff
234 :sibling => { :tag => 'a',
225 :sibling => { :tag => 'a',
235 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' }
226 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' }
236 }
227 }
237 }
228 }
238 }
229 }
239 end
230 end
240
231
241 def test_invalid_revision
232 def test_invalid_revision
242 assert_equal 0, @repository.changesets.count
233 assert_equal 0, @repository.changesets.count
243 @repository.fetch_changesets
234 @repository.fetch_changesets
244 @project.reload
235 @project.reload
245 assert_equal NUM_REV, @repository.changesets.count
236 assert_equal NUM_REV, @repository.changesets.count
246 get :revision, :id => PRJ_ID, :rev => 'something_weird'
237 get :revision, :id => PRJ_ID, :rev => 'something_weird'
247 assert_response 404
238 assert_response 404
248 assert_error_tag :content => /was not found/
239 assert_error_tag :content => /was not found/
249 end
240 end
250
241
251 def test_invalid_revision_diff
242 def test_invalid_revision_diff
252 get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird'
243 get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird'
253 assert_response 404
244 assert_response 404
254 assert_error_tag :content => /was not found/
245 assert_error_tag :content => /was not found/
255 end
246 end
256
247
257 def test_empty_revision
248 def test_empty_revision
258 assert_equal 0, @repository.changesets.count
249 assert_equal 0, @repository.changesets.count
259 @repository.fetch_changesets
250 @repository.fetch_changesets
260 @project.reload
251 @project.reload
261 assert_equal NUM_REV, @repository.changesets.count
252 assert_equal NUM_REV, @repository.changesets.count
262 ['', ' ', nil].each do |r|
253 ['', ' ', nil].each do |r|
263 get :revision, :id => PRJ_ID, :rev => r
254 get :revision, :id => PRJ_ID, :rev => r
264 assert_response 404
255 assert_response 404
265 assert_error_tag :content => /was not found/
256 assert_error_tag :content => /was not found/
266 end
257 end
267 end
258 end
268
259
269 # TODO: this test needs fixtures.
260 # TODO: this test needs fixtures.
270 def test_revision_with_repository_pointing_to_a_subdirectory
261 def test_revision_with_repository_pointing_to_a_subdirectory
271 r = Project.find(1).repository
262 r = Project.find(1).repository
272 # Changes repository url to a subdirectory
263 # Changes repository url to a subdirectory
273 r.update_attribute :url, (r.url + '/test/some')
264 r.update_attribute :url, (r.url + '/test/some')
274
265
275 get :revision, :id => 1, :rev => 2
266 get :revision, :id => 1, :rev => 2
276 assert_response :success
267 assert_response :success
277 assert_template 'revision'
268 assert_template 'revision'
278 assert_tag :tag => 'ul',
269 assert_tag :tag => 'ul',
279 :child => { :tag => 'li',
270 :child => { :tag => 'li',
280 # link to the entry at rev 2
271 # link to the entry at rev 2
281 :child => { :tag => 'a',
272 :child => { :tag => 'a',
282 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'},
273 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'},
283 :content => 'repo',
274 :content => 'repo',
284 # link to partial diff
275 # link to partial diff
285 :sibling => { :tag => 'a',
276 :sibling => { :tag => 'a',
286 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' }
277 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' }
287 }
278 }
288 }
279 }
289 }
280 }
290 end
281 end
291
282
292 def test_revision_diff
283 def test_revision_diff
293 assert_equal 0, @repository.changesets.count
284 assert_equal 0, @repository.changesets.count
294 @repository.fetch_changesets
285 @repository.fetch_changesets
295 @project.reload
286 @project.reload
296 assert_equal NUM_REV, @repository.changesets.count
287 assert_equal NUM_REV, @repository.changesets.count
297 ['inline', 'sbs'].each do |dt|
288 ['inline', 'sbs'].each do |dt|
298 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
289 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
299 assert_response :success
290 assert_response :success
300 assert_template 'diff'
291 assert_template 'diff'
301 assert_tag :tag => 'h2',
292 assert_tag :tag => 'h2',
302 :content => / 3/
293 :content => / 3/
303 end
294 end
304 end
295 end
305
296
306 def test_revision_diff_raw_format
297 def test_revision_diff_raw_format
307 assert_equal 0, @repository.changesets.count
298 assert_equal 0, @repository.changesets.count
308 @repository.fetch_changesets
299 @repository.fetch_changesets
309 @project.reload
300 @project.reload
310 assert_equal NUM_REV, @repository.changesets.count
301 assert_equal NUM_REV, @repository.changesets.count
311
302
312 get :diff, :id => PRJ_ID, :rev => 3, :format => 'diff'
303 get :diff, :id => PRJ_ID, :rev => 3, :format => 'diff'
313 assert_response :success
304 assert_response :success
314 assert_equal 'text/x-patch', @response.content_type
305 assert_equal 'text/x-patch', @response.content_type
315 assert_equal 'Index: subversion_test/textfile.txt', @response.body.split(/\r?\n/).first
306 assert_equal 'Index: subversion_test/textfile.txt', @response.body.split(/\r?\n/).first
316 end
307 end
317
308
318 def test_directory_diff
309 def test_directory_diff
319 assert_equal 0, @repository.changesets.count
310 assert_equal 0, @repository.changesets.count
320 @repository.fetch_changesets
311 @repository.fetch_changesets
321 @project.reload
312 @project.reload
322 assert_equal NUM_REV, @repository.changesets.count
313 assert_equal NUM_REV, @repository.changesets.count
323 ['inline', 'sbs'].each do |dt|
314 ['inline', 'sbs'].each do |dt|
324 get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2,
315 get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2,
325 :path => ['subversion_test', 'folder'], :type => dt
316 :path => ['subversion_test', 'folder'], :type => dt
326 assert_response :success
317 assert_response :success
327 assert_template 'diff'
318 assert_template 'diff'
328
319
329 diff = assigns(:diff)
320 diff = assigns(:diff)
330 assert_not_nil diff
321 assert_not_nil diff
331 # 2 files modified
322 # 2 files modified
332 assert_equal 2, Redmine::UnifiedDiff.new(diff).size
323 assert_equal 2, Redmine::UnifiedDiff.new(diff).size
333 assert_tag :tag => 'h2', :content => /2:6/
324 assert_tag :tag => 'h2', :content => /2:6/
334 end
325 end
335 end
326 end
336
327
337 def test_annotate
328 def test_annotate
338 assert_equal 0, @repository.changesets.count
329 assert_equal 0, @repository.changesets.count
339 @repository.fetch_changesets
330 @repository.fetch_changesets
340 @project.reload
331 @project.reload
341 assert_equal NUM_REV, @repository.changesets.count
332 assert_equal NUM_REV, @repository.changesets.count
342 get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
333 get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
343 assert_response :success
334 assert_response :success
344 assert_template 'annotate'
335 assert_template 'annotate'
345 end
336 end
346
337
347 def test_annotate_at_given_revision
338 def test_annotate_at_given_revision
348 assert_equal 0, @repository.changesets.count
339 assert_equal 0, @repository.changesets.count
349 @repository.fetch_changesets
340 @repository.fetch_changesets
350 @project.reload
341 @project.reload
351 assert_equal NUM_REV, @repository.changesets.count
342 assert_equal NUM_REV, @repository.changesets.count
352 get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c']
343 get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c']
353 assert_response :success
344 assert_response :success
354 assert_template 'annotate'
345 assert_template 'annotate'
355 assert_tag :tag => 'h2', :content => /@ 8/
346 assert_tag :tag => 'h2', :content => /@ 8/
356 end
347 end
357
348
358 def test_destroy_valid_repository
349 def test_destroy_valid_repository
359 @request.session[:user_id] = 1 # admin
350 @request.session[:user_id] = 1 # admin
360 assert_equal 0, @repository.changesets.count
351 assert_equal 0, @repository.changesets.count
361 @repository.fetch_changesets
352 @repository.fetch_changesets
362 assert_equal NUM_REV, @repository.changesets.count
353 assert_equal NUM_REV, @repository.changesets.count
363
354
364 assert_difference 'Repository.count', -1 do
355 assert_difference 'Repository.count', -1 do
365 delete :destroy, :id => @repository.id
356 delete :destroy, :id => @repository.id
366 end
357 end
367 assert_response 302
358 assert_response 302
368 @project.reload
359 @project.reload
369 assert_nil @project.repository
360 assert_nil @project.repository
370 end
361 end
371
362
372 def test_destroy_invalid_repository
363 def test_destroy_invalid_repository
373 @request.session[:user_id] = 1 # admin
364 @request.session[:user_id] = 1 # admin
374 @project.repository.destroy
365 @project.repository.destroy
375 @repository = Repository::Subversion.create!(
366 @repository = Repository::Subversion.create!(
376 :project => @project,
367 :project => @project,
377 :url => "file:///invalid")
368 :url => "file:///invalid")
378 @repository.fetch_changesets
369 @repository.fetch_changesets
379 assert_equal 0, @repository.changesets.count
370 assert_equal 0, @repository.changesets.count
380
371
381 assert_difference 'Repository.count', -1 do
372 assert_difference 'Repository.count', -1 do
382 delete :destroy, :id => @repository.id
373 delete :destroy, :id => @repository.id
383 end
374 end
384 assert_response 302
375 assert_response 302
385 @project.reload
376 @project.reload
386 assert_nil @project.repository
377 assert_nil @project.repository
387 end
378 end
388 else
379 else
389 puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
380 puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
390 def test_fake; assert true end
381 def test_fake; assert true end
391 end
382 end
392 end
383 end
General Comments 0
You need to be logged in to leave comments. Login now