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