##// END OF EJS Templates
Test for repository edit and cleanup....
Jean-Philippe Lang -
r7932:e67afc88866a
parent child
Show More
@@ -1,193 +1,199
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 require 'repositories_controller'
20
21 # Re-raise errors caught by the controller.
22 class RepositoriesController; def rescue_action(e) raise e end; end
23 19
24 20 class RepositoriesBazaarControllerTest < ActionController::TestCase
21 tests RepositoriesController
22
25 23 fixtures :projects, :users, :roles, :members, :member_roles,
26 24 :repositories, :enabled_modules
27 25
28 26 REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository/trunk').to_s
29 27 PRJ_ID = 3
30 28
31 29 def setup
32 @controller = RepositoriesController.new
33 @request = ActionController::TestRequest.new
34 @response = ActionController::TestResponse.new
35 30 User.current = nil
36 31 @project = Project.find(PRJ_ID)
37 32 @repository = Repository::Bazaar.create(
38 33 :project => @project,
39 34 :url => REPOSITORY_PATH,
40 35 :log_encoding => 'UTF-8')
41 36 assert @repository
42 37 end
43 38
44 39 if File.directory?(REPOSITORY_PATH)
40 def test_get_edit
41 @request.session[:user_id] = 1
42 @project.repository.destroy
43 xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Bazaar'
44 assert_response :success
45 assert_equal 'text/javascript', @response.content_type
46 assert_kind_of Repository::Bazaar, assigns(:repository)
47 assert assigns(:repository).new_record?
48 assert_select_rjs :replace_html, 'tab-content-repository'
49 end
50
45 51 def test_browse_root
46 52 get :show, :id => PRJ_ID
47 53 assert_response :success
48 54 assert_template 'show'
49 55 assert_not_nil assigns(:entries)
50 56 assert_equal 2, assigns(:entries).size
51 57 assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'}
52 58 assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'}
53 59 end
54 60
55 61 def test_browse_directory
56 62 get :show, :id => PRJ_ID, :path => ['directory']
57 63 assert_response :success
58 64 assert_template 'show'
59 65 assert_not_nil assigns(:entries)
60 66 assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name)
61 67 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
62 68 assert_not_nil entry
63 69 assert_equal 'file', entry.kind
64 70 assert_equal 'directory/edit.png', entry.path
65 71 end
66 72
67 73 def test_browse_at_given_revision
68 74 get :show, :id => PRJ_ID, :path => [], :rev => 3
69 75 assert_response :success
70 76 assert_template 'show'
71 77 assert_not_nil assigns(:entries)
72 78 assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'],
73 79 assigns(:entries).collect(&:name)
74 80 end
75 81
76 82 def test_changes
77 83 get :changes, :id => PRJ_ID, :path => ['doc-mkdir.txt']
78 84 assert_response :success
79 85 assert_template 'changes'
80 86 assert_tag :tag => 'h2', :content => 'doc-mkdir.txt'
81 87 end
82 88
83 89 def test_entry_show
84 90 get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt']
85 91 assert_response :success
86 92 assert_template 'entry'
87 93 # Line 19
88 94 assert_tag :tag => 'th',
89 95 :content => /29/,
90 96 :attributes => { :class => /line-num/ },
91 97 :sibling => { :tag => 'td', :content => /Show help message/ }
92 98 end
93 99
94 100 def test_entry_download
95 101 get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt'], :format => 'raw'
96 102 assert_response :success
97 103 # File content
98 104 assert @response.body.include?('Show help message')
99 105 end
100 106
101 107 def test_directory_entry
102 108 get :entry, :id => PRJ_ID, :path => ['directory']
103 109 assert_response :success
104 110 assert_template 'show'
105 111 assert_not_nil assigns(:entry)
106 112 assert_equal 'directory', assigns(:entry).name
107 113 end
108 114
109 115 def test_diff
110 116 # Full diff of changeset 3
111 117 ['inline', 'sbs'].each do |dt|
112 118 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
113 119 assert_response :success
114 120 assert_template 'diff'
115 121 # Line 11 removed
116 122 assert_tag :tag => 'th',
117 123 :content => '11',
118 124 :sibling => { :tag => 'td',
119 125 :attributes => { :class => /diff_out/ },
120 126 :content => /Display more information/ }
121 127 end
122 128 end
123 129
124 130 def test_annotate
125 131 get :annotate, :id => PRJ_ID, :path => ['doc-mkdir.txt']
126 132 assert_response :success
127 133 assert_template 'annotate'
128 134 assert_tag :tag => 'th', :content => '2',
129 135 :sibling => {
130 136 :tag => 'td',
131 137 :child => {
132 138 :tag => 'a',
133 139 :content => '3'
134 140 }
135 141 }
136 142 assert_tag :tag => 'th', :content => '2',
137 143 :sibling => { :tag => 'td', :content => /jsmith/ }
138 144 assert_tag :tag => 'th', :content => '2',
139 145 :sibling => {
140 146 :tag => 'td',
141 147 :child => {
142 148 :tag => 'a',
143 149 :content => '3'
144 150 }
145 151 }
146 152 assert_tag :tag => 'th', :content => '2',
147 153 :sibling => { :tag => 'td', :content => /Main purpose/ }
148 154 end
149 155
150 156 def test_destroy_valid_repository
151 157 @request.session[:user_id] = 1 # admin
152 158 assert_equal 0, @repository.changesets.count
153 159 @repository.fetch_changesets
154 160 @project.reload
155 161 assert @repository.changesets.count > 0
156 162
157 163 get :destroy, :id => PRJ_ID
158 164 assert_response 302
159 165 @project.reload
160 166 assert_nil @project.repository
161 167 end
162 168
163 169 def test_destroy_invalid_repository
164 170 @request.session[:user_id] = 1 # admin
165 171 assert_equal 0, @repository.changesets.count
166 172 @repository.fetch_changesets
167 173 @project.reload
168 174 assert @repository.changesets.count > 0
169 175
170 176 get :destroy, :id => PRJ_ID
171 177 assert_response 302
172 178 @project.reload
173 179 assert_nil @project.repository
174 180
175 181 @repository = Repository::Bazaar.create(
176 182 :project => @project,
177 183 :url => "/invalid",
178 184 :log_encoding => 'UTF-8')
179 185 assert @repository
180 186 @repository.fetch_changesets
181 187 @repository.reload
182 188 assert_equal 0, @repository.changesets.count
183 189
184 190 get :destroy, :id => PRJ_ID
185 191 assert_response 302
186 192 @project.reload
187 193 assert_nil @project.repository
188 194 end
189 195 else
190 196 puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!"
191 197 def test_fake; assert true end
192 198 end
193 199 end
@@ -1,282 +1,288
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 require 'repositories_controller'
20
21 # Re-raise errors caught by the controller.
22 class RepositoriesController; def rescue_action(e) raise e end; end
23 19
24 20 class RepositoriesCvsControllerTest < ActionController::TestCase
21 tests RepositoriesController
22
25 23 fixtures :projects, :users, :roles, :members, :member_roles,
26 24 :repositories, :enabled_modules
27 25
28 26 REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
29 27 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
30 28 # CVS module
31 29 MODULE_NAME = 'test'
32 30 PRJ_ID = 3
33 31 NUM_REV = 7
34 32
35 33 def setup
36 @controller = RepositoriesController.new
37 @request = ActionController::TestRequest.new
38 @response = ActionController::TestResponse.new
39 34 Setting.default_language = 'en'
40 35 User.current = nil
41 36
42 37 @project = Project.find(PRJ_ID)
43 38 @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID),
44 39 :root_url => REPOSITORY_PATH,
45 40 :url => MODULE_NAME,
46 41 :log_encoding => 'UTF-8')
47 42 assert @repository
48 43 end
49 44
50 45 if File.directory?(REPOSITORY_PATH)
46 def test_get_edit
47 @request.session[:user_id] = 1
48 @project.repository.destroy
49 xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Cvs'
50 assert_response :success
51 assert_equal 'text/javascript', @response.content_type
52 assert_kind_of Repository::Cvs, assigns(:repository)
53 assert assigns(:repository).new_record?
54 assert_select_rjs :replace_html, 'tab-content-repository'
55 end
56
51 57 def test_browse_root
52 58 assert_equal 0, @repository.changesets.count
53 59 @repository.fetch_changesets
54 60 @project.reload
55 61 assert_equal NUM_REV, @repository.changesets.count
56 62 get :show, :id => PRJ_ID
57 63 assert_response :success
58 64 assert_template 'show'
59 65 assert_not_nil assigns(:entries)
60 66 assert_equal 3, assigns(:entries).size
61 67
62 68 entry = assigns(:entries).detect {|e| e.name == 'images'}
63 69 assert_equal 'dir', entry.kind
64 70
65 71 entry = assigns(:entries).detect {|e| e.name == 'README'}
66 72 assert_equal 'file', entry.kind
67 73
68 74 assert_not_nil assigns(:changesets)
69 75 assert assigns(:changesets).size > 0
70 76 end
71 77
72 78 def test_browse_directory
73 79 assert_equal 0, @repository.changesets.count
74 80 @repository.fetch_changesets
75 81 @project.reload
76 82 assert_equal NUM_REV, @repository.changesets.count
77 83 get :show, :id => PRJ_ID, :path => ['images']
78 84 assert_response :success
79 85 assert_template 'show'
80 86 assert_not_nil assigns(:entries)
81 87 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name)
82 88 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
83 89 assert_not_nil entry
84 90 assert_equal 'file', entry.kind
85 91 assert_equal 'images/edit.png', entry.path
86 92 end
87 93
88 94 def test_browse_at_given_revision
89 95 assert_equal 0, @repository.changesets.count
90 96 @repository.fetch_changesets
91 97 @project.reload
92 98 assert_equal NUM_REV, @repository.changesets.count
93 99 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
94 100 assert_response :success
95 101 assert_template 'show'
96 102 assert_not_nil assigns(:entries)
97 103 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
98 104 end
99 105
100 106 def test_entry
101 107 assert_equal 0, @repository.changesets.count
102 108 @repository.fetch_changesets
103 109 @project.reload
104 110 assert_equal NUM_REV, @repository.changesets.count
105 111 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
106 112 assert_response :success
107 113 assert_template 'entry'
108 114 assert_no_tag :tag => 'td',
109 115 :attributes => { :class => /line-code/},
110 116 :content => /before_filter/
111 117 end
112 118
113 119 def test_entry_at_given_revision
114 120 # changesets must be loaded
115 121 assert_equal 0, @repository.changesets.count
116 122 @repository.fetch_changesets
117 123 @project.reload
118 124 assert_equal NUM_REV, @repository.changesets.count
119 125 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2
120 126 assert_response :success
121 127 assert_template 'entry'
122 128 # this line was removed in r3
123 129 assert_tag :tag => 'td',
124 130 :attributes => { :class => /line-code/},
125 131 :content => /before_filter/
126 132 end
127 133
128 134 def test_entry_not_found
129 135 assert_equal 0, @repository.changesets.count
130 136 @repository.fetch_changesets
131 137 @project.reload
132 138 assert_equal NUM_REV, @repository.changesets.count
133 139 get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c']
134 140 assert_tag :tag => 'p',
135 141 :attributes => { :id => /errorExplanation/ },
136 142 :content => /The entry or revision was not found in the repository/
137 143 end
138 144
139 145 def test_entry_download
140 146 assert_equal 0, @repository.changesets.count
141 147 @repository.fetch_changesets
142 148 @project.reload
143 149 assert_equal NUM_REV, @repository.changesets.count
144 150 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'],
145 151 :format => 'raw'
146 152 assert_response :success
147 153 end
148 154
149 155 def test_directory_entry
150 156 assert_equal 0, @repository.changesets.count
151 157 @repository.fetch_changesets
152 158 @project.reload
153 159 assert_equal NUM_REV, @repository.changesets.count
154 160 get :entry, :id => PRJ_ID, :path => ['sources']
155 161 assert_response :success
156 162 assert_template 'show'
157 163 assert_not_nil assigns(:entry)
158 164 assert_equal 'sources', assigns(:entry).name
159 165 end
160 166
161 167 def test_diff
162 168 assert_equal 0, @repository.changesets.count
163 169 @repository.fetch_changesets
164 170 @project.reload
165 171 assert_equal NUM_REV, @repository.changesets.count
166 172 ['inline', 'sbs'].each do |dt|
167 173 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
168 174 assert_response :success
169 175 assert_template 'diff'
170 176 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
171 177 :content => /before_filter :require_login/
172 178 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
173 179 :content => /with one change/
174 180 end
175 181 end
176 182
177 183 def test_diff_new_files
178 184 assert_equal 0, @repository.changesets.count
179 185 @repository.fetch_changesets
180 186 @project.reload
181 187 assert_equal NUM_REV, @repository.changesets.count
182 188 ['inline', 'sbs'].each do |dt|
183 189 get :diff, :id => PRJ_ID, :rev => 1, :type => dt
184 190 assert_response :success
185 191 assert_template 'diff'
186 192 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
187 193 :content => /watched.remove_watcher/
188 194 assert_tag :tag => 'th', :attributes => { :class => 'filename' },
189 195 :content => /test\/README/
190 196 assert_tag :tag => 'th', :attributes => { :class => 'filename' },
191 197 :content => /test\/images\/delete.png /
192 198 assert_tag :tag => 'th', :attributes => { :class => 'filename' },
193 199 :content => /test\/images\/edit.png/
194 200 assert_tag :tag => 'th', :attributes => { :class => 'filename' },
195 201 :content => /test\/sources\/watchers_controller.rb/
196 202 end
197 203 end
198 204
199 205 def test_annotate
200 206 assert_equal 0, @repository.changesets.count
201 207 @repository.fetch_changesets
202 208 @project.reload
203 209 assert_equal NUM_REV, @repository.changesets.count
204 210 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
205 211 assert_response :success
206 212 assert_template 'annotate'
207 213 # 1.1 line
208 214 assert_tag :tag => 'th',
209 215 :attributes => { :class => 'line-num' },
210 216 :content => '18',
211 217 :sibling => {
212 218 :tag => 'td',
213 219 :attributes => { :class => 'revision' },
214 220 :content => /1.1/,
215 221 :sibling => {
216 222 :tag => 'td',
217 223 :attributes => { :class => 'author' },
218 224 :content => /LANG/
219 225 }
220 226 }
221 227 # 1.2 line
222 228 assert_tag :tag => 'th',
223 229 :attributes => { :class => 'line-num' },
224 230 :content => '32',
225 231 :sibling => {
226 232 :tag => 'td',
227 233 :attributes => { :class => 'revision' },
228 234 :content => /1.2/,
229 235 :sibling => {
230 236 :tag => 'td',
231 237 :attributes => { :class => 'author' },
232 238 :content => /LANG/
233 239 }
234 240 }
235 241 end
236 242
237 243 def test_destroy_valid_repository
238 244 @request.session[:user_id] = 1 # admin
239 245 assert_equal 0, @repository.changesets.count
240 246 @repository.fetch_changesets
241 247 @project.reload
242 248 assert_equal NUM_REV, @repository.changesets.count
243 249
244 250 get :destroy, :id => PRJ_ID
245 251 assert_response 302
246 252 @project.reload
247 253 assert_nil @project.repository
248 254 end
249 255
250 256 def test_destroy_invalid_repository
251 257 @request.session[:user_id] = 1 # admin
252 258 assert_equal 0, @repository.changesets.count
253 259 @repository.fetch_changesets
254 260 @project.reload
255 261 assert_equal NUM_REV, @repository.changesets.count
256 262
257 263 get :destroy, :id => PRJ_ID
258 264 assert_response 302
259 265 @project.reload
260 266 assert_nil @project.repository
261 267
262 268 @repository = Repository::Cvs.create(
263 269 :project => Project.find(PRJ_ID),
264 270 :root_url => "/invalid",
265 271 :url => MODULE_NAME,
266 272 :log_encoding => 'UTF-8'
267 273 )
268 274 assert @repository
269 275 @repository.fetch_changesets
270 276 @project.reload
271 277 assert_equal 0, @repository.changesets.count
272 278
273 279 get :destroy, :id => PRJ_ID
274 280 assert_response 302
275 281 @project.reload
276 282 assert_nil @project.repository
277 283 end
278 284 else
279 285 puts "CVS test repository NOT FOUND. Skipping functional tests !!!"
280 286 def test_fake; assert true end
281 287 end
282 288 end
@@ -1,164 +1,170
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 require 'repositories_controller'
20
21 # Re-raise errors caught by the controller.
22 class RepositoriesController; def rescue_action(e) raise e end; end
23 19
24 20 class RepositoriesDarcsControllerTest < ActionController::TestCase
21 tests RepositoriesController
22
25 23 fixtures :projects, :users, :roles, :members, :member_roles,
26 24 :repositories, :enabled_modules
27 25
28 26 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
29 27 PRJ_ID = 3
30 28 NUM_REV = 6
31 29
32 30 def setup
33 @controller = RepositoriesController.new
34 @request = ActionController::TestRequest.new
35 @response = ActionController::TestResponse.new
36 31 User.current = nil
37 32 @project = Project.find(PRJ_ID)
38 33 @repository = Repository::Darcs.create(
39 34 :project => @project,
40 35 :url => REPOSITORY_PATH,
41 36 :log_encoding => 'UTF-8'
42 37 )
43 38 assert @repository
44 39 end
45 40
46 41 if File.directory?(REPOSITORY_PATH)
42 def test_get_edit
43 @request.session[:user_id] = 1
44 @project.repository.destroy
45 xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Darcs'
46 assert_response :success
47 assert_equal 'text/javascript', @response.content_type
48 assert_kind_of Repository::Darcs, assigns(:repository)
49 assert assigns(:repository).new_record?
50 assert_select_rjs :replace_html, 'tab-content-repository'
51 end
52
47 53 def test_browse_root
48 54 assert_equal 0, @repository.changesets.count
49 55 @repository.fetch_changesets
50 56 @project.reload
51 57 assert_equal NUM_REV, @repository.changesets.count
52 58 get :show, :id => PRJ_ID
53 59 assert_response :success
54 60 assert_template 'show'
55 61 assert_not_nil assigns(:entries)
56 62 assert_equal 3, assigns(:entries).size
57 63 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
58 64 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
59 65 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
60 66 end
61 67
62 68 def test_browse_directory
63 69 assert_equal 0, @repository.changesets.count
64 70 @repository.fetch_changesets
65 71 @project.reload
66 72 assert_equal NUM_REV, @repository.changesets.count
67 73 get :show, :id => PRJ_ID, :path => ['images']
68 74 assert_response :success
69 75 assert_template 'show'
70 76 assert_not_nil assigns(:entries)
71 77 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
72 78 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
73 79 assert_not_nil entry
74 80 assert_equal 'file', entry.kind
75 81 assert_equal 'images/edit.png', entry.path
76 82 end
77 83
78 84 def test_browse_at_given_revision
79 85 assert_equal 0, @repository.changesets.count
80 86 @repository.fetch_changesets
81 87 @project.reload
82 88 assert_equal NUM_REV, @repository.changesets.count
83 89 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
84 90 assert_response :success
85 91 assert_template 'show'
86 92 assert_not_nil assigns(:entries)
87 93 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
88 94 end
89 95
90 96 def test_changes
91 97 assert_equal 0, @repository.changesets.count
92 98 @repository.fetch_changesets
93 99 @project.reload
94 100 assert_equal NUM_REV, @repository.changesets.count
95 101 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
96 102 assert_response :success
97 103 assert_template 'changes'
98 104 assert_tag :tag => 'h2', :content => 'edit.png'
99 105 end
100 106
101 107 def test_diff
102 108 assert_equal 0, @repository.changesets.count
103 109 @repository.fetch_changesets
104 110 @project.reload
105 111 assert_equal NUM_REV, @repository.changesets.count
106 112 # Full diff of changeset 5
107 113 ['inline', 'sbs'].each do |dt|
108 114 get :diff, :id => PRJ_ID, :rev => 5, :type => dt
109 115 assert_response :success
110 116 assert_template 'diff'
111 117 # Line 22 removed
112 118 assert_tag :tag => 'th',
113 119 :content => '22',
114 120 :sibling => { :tag => 'td',
115 121 :attributes => { :class => /diff_out/ },
116 122 :content => /def remove/ }
117 123 end
118 124 end
119 125
120 126 def test_destroy_valid_repository
121 127 @request.session[:user_id] = 1 # admin
122 128 assert_equal 0, @repository.changesets.count
123 129 @repository.fetch_changesets
124 130 @project.reload
125 131 assert_equal NUM_REV, @repository.changesets.count
126 132
127 133 get :destroy, :id => PRJ_ID
128 134 assert_response 302
129 135 @project.reload
130 136 assert_nil @project.repository
131 137 end
132 138
133 139 def test_destroy_invalid_repository
134 140 @request.session[:user_id] = 1 # admin
135 141 assert_equal 0, @repository.changesets.count
136 142 @repository.fetch_changesets
137 143 @project.reload
138 144 assert_equal NUM_REV, @repository.changesets.count
139 145
140 146 get :destroy, :id => PRJ_ID
141 147 assert_response 302
142 148 @project.reload
143 149 assert_nil @project.repository
144 150
145 151 @repository = Repository::Darcs.create(
146 152 :project => @project,
147 153 :url => "/invalid",
148 154 :log_encoding => 'UTF-8'
149 155 )
150 156 assert @repository
151 157 @repository.fetch_changesets
152 158 @project.reload
153 159 assert_equal 0, @repository.changesets.count
154 160
155 161 get :destroy, :id => PRJ_ID
156 162 assert_response 302
157 163 @project.reload
158 164 assert_nil @project.repository
159 165 end
160 166 else
161 167 puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
162 168 def test_fake; assert true end
163 169 end
164 170 end
General Comments 0
You need to be logged in to leave comments. Login now