##// END OF EJS Templates
remove unneeded tabs from test/functional/repositories_cvs_controller_test.rb...
Toshi MARUYAMA -
r12815:38fc2e4391a6
parent child
Show More
@@ -1,274 +1,274
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class RepositoriesCvsControllerTest < ActionController::TestCase
21 21 tests RepositoriesController
22 22
23 23 fixtures :projects, :users, :roles, :members, :member_roles,
24 24 :repositories, :enabled_modules
25 25
26 26 REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
27 27 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
28 28 # CVS module
29 29 MODULE_NAME = 'test'
30 30 PRJ_ID = 3
31 31 NUM_REV = 7
32 32
33 33 def setup
34 34 Setting.default_language = 'en'
35 35 User.current = nil
36 36
37 37 @project = Project.find(PRJ_ID)
38 38 @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID),
39 39 :root_url => REPOSITORY_PATH,
40 40 :url => MODULE_NAME,
41 41 :log_encoding => 'UTF-8')
42 42 assert @repository
43 43 end
44 44
45 45 if File.directory?(REPOSITORY_PATH)
46 46 def test_get_new
47 47 @request.session[:user_id] = 1
48 48 @project.repository.destroy
49 49 get :new, :project_id => 'subproject1', :repository_scm => 'Cvs'
50 50 assert_response :success
51 51 assert_template 'new'
52 52 assert_kind_of Repository::Cvs, assigns(:repository)
53 53 assert assigns(:repository).new_record?
54 54 end
55 55
56 56 def test_browse_root
57 57 assert_equal 0, @repository.changesets.count
58 58 @repository.fetch_changesets
59 59 @project.reload
60 60 assert_equal NUM_REV, @repository.changesets.count
61 61 get :show, :id => PRJ_ID
62 62 assert_response :success
63 63 assert_template 'show'
64 64 assert_not_nil assigns(:entries)
65 65 assert_equal 3, assigns(:entries).size
66 66
67 67 entry = assigns(:entries).detect {|e| e.name == 'images'}
68 68 assert_equal 'dir', entry.kind
69 69
70 70 entry = assigns(:entries).detect {|e| e.name == 'README'}
71 71 assert_equal 'file', entry.kind
72 72
73 73 assert_not_nil assigns(:changesets)
74 74 assert assigns(:changesets).size > 0
75 75 end
76 76
77 77 def test_browse_directory
78 78 assert_equal 0, @repository.changesets.count
79 79 @repository.fetch_changesets
80 80 @project.reload
81 81 assert_equal NUM_REV, @repository.changesets.count
82 82 get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param]
83 83 assert_response :success
84 84 assert_template 'show'
85 85 assert_not_nil assigns(:entries)
86 86 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name)
87 87 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
88 88 assert_not_nil entry
89 89 assert_equal 'file', entry.kind
90 90 assert_equal 'images/edit.png', entry.path
91 91 end
92 92
93 93 def test_browse_at_given_revision
94 94 assert_equal 0, @repository.changesets.count
95 95 @repository.fetch_changesets
96 96 @project.reload
97 97 assert_equal NUM_REV, @repository.changesets.count
98 98 get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param],
99 99 :rev => 1
100 100 assert_response :success
101 101 assert_template 'show'
102 102 assert_not_nil assigns(:entries)
103 103 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
104 104 end
105 105
106 106 def test_entry
107 107 assert_equal 0, @repository.changesets.count
108 108 @repository.fetch_changesets
109 109 @project.reload
110 110 assert_equal NUM_REV, @repository.changesets.count
111 111 get :entry, :id => PRJ_ID,
112 112 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
113 113 assert_response :success
114 114 assert_template 'entry'
115 115 assert_no_tag :tag => 'td',
116 116 :attributes => { :class => /line-code/},
117 117 :content => /before_filter/
118 118 end
119 119
120 120 def test_entry_at_given_revision
121 121 # changesets must be loaded
122 122 assert_equal 0, @repository.changesets.count
123 123 @repository.fetch_changesets
124 124 @project.reload
125 125 assert_equal NUM_REV, @repository.changesets.count
126 126 get :entry, :id => PRJ_ID,
127 127 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
128 128 :rev => 2
129 129 assert_response :success
130 130 assert_template 'entry'
131 131 # this line was removed in r3
132 132 assert_tag :tag => 'td',
133 133 :attributes => { :class => /line-code/},
134 134 :content => /before_filter/
135 135 end
136 136
137 137 def test_entry_not_found
138 138 assert_equal 0, @repository.changesets.count
139 139 @repository.fetch_changesets
140 140 @project.reload
141 141 assert_equal NUM_REV, @repository.changesets.count
142 142 get :entry, :id => PRJ_ID,
143 143 :path => repository_path_hash(['sources', 'zzz.c'])[:param]
144 144 assert_tag :tag => 'p',
145 145 :attributes => { :id => /errorExplanation/ },
146 146 :content => /The entry or revision was not found in the repository/
147 147 end
148 148
149 149 def test_entry_download
150 150 assert_equal 0, @repository.changesets.count
151 151 @repository.fetch_changesets
152 152 @project.reload
153 153 assert_equal NUM_REV, @repository.changesets.count
154 154 get :entry, :id => PRJ_ID,
155 155 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
156 156 :format => 'raw'
157 157 assert_response :success
158 158 end
159 159
160 160 def test_directory_entry
161 161 assert_equal 0, @repository.changesets.count
162 162 @repository.fetch_changesets
163 163 @project.reload
164 164 assert_equal NUM_REV, @repository.changesets.count
165 165 get :entry, :id => PRJ_ID,
166 166 :path => repository_path_hash(['sources'])[:param]
167 167 assert_response :success
168 168 assert_template 'show'
169 169 assert_not_nil assigns(:entry)
170 170 assert_equal 'sources', assigns(:entry).name
171 171 end
172 172
173 173 def test_diff
174 174 assert_equal 0, @repository.changesets.count
175 175 @repository.fetch_changesets
176 176 @project.reload
177 177 assert_equal NUM_REV, @repository.changesets.count
178 178 ['inline', 'sbs'].each do |dt|
179 179 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
180 180 assert_response :success
181 181 assert_template 'diff'
182 182 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
183 183 :content => /before_filter :require_login/
184 184 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
185 185 :content => /with one change/
186 186 end
187 187 end
188 188
189 189 def test_diff_new_files
190 190 assert_equal 0, @repository.changesets.count
191 191 @repository.fetch_changesets
192 192 @project.reload
193 193 assert_equal NUM_REV, @repository.changesets.count
194 194 ['inline', 'sbs'].each do |dt|
195 195 get :diff, :id => PRJ_ID, :rev => 1, :type => dt
196 196 assert_response :success
197 197 assert_template 'diff'
198 198 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
199 199 :content => /watched.remove_watcher/
200 200 assert_tag :tag => 'th', :attributes => { :class => 'filename' },
201 201 :content => /test\/README/
202 202 assert_tag :tag => 'th', :attributes => { :class => 'filename' },
203 :content => /test\/images\/delete.png /
203 :content => /test\/images\/delete.png/
204 204 assert_tag :tag => 'th', :attributes => { :class => 'filename' },
205 205 :content => /test\/images\/edit.png/
206 206 assert_tag :tag => 'th', :attributes => { :class => 'filename' },
207 207 :content => /test\/sources\/watchers_controller.rb/
208 208 end
209 209 end
210 210
211 211 def test_annotate
212 212 assert_equal 0, @repository.changesets.count
213 213 @repository.fetch_changesets
214 214 @project.reload
215 215 assert_equal NUM_REV, @repository.changesets.count
216 216 get :annotate, :id => PRJ_ID,
217 217 :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
218 218 assert_response :success
219 219 assert_template 'annotate'
220 220
221 221 # 1.1 line
222 222 assert_select 'tr' do
223 223 assert_select 'th.line-num', :text => '21'
224 224 assert_select 'td.revision', :text => /1.1/
225 225 assert_select 'td.author', :text => /LANG/
226 226 end
227 227 # 1.2 line
228 228 assert_select 'tr' do
229 229 assert_select 'th.line-num', :text => '32'
230 230 assert_select 'td.revision', :text => /1.2/
231 231 assert_select 'td.author', :text => /LANG/
232 232 end
233 233 end
234 234
235 235 def test_destroy_valid_repository
236 236 @request.session[:user_id] = 1 # admin
237 237 assert_equal 0, @repository.changesets.count
238 238 @repository.fetch_changesets
239 239 @project.reload
240 240 assert_equal NUM_REV, @repository.changesets.count
241 241
242 242 assert_difference 'Repository.count', -1 do
243 243 delete :destroy, :id => @repository.id
244 244 end
245 245 assert_response 302
246 246 @project.reload
247 247 assert_nil @project.repository
248 248 end
249 249
250 250 def test_destroy_invalid_repository
251 251 @request.session[:user_id] = 1 # admin
252 252 @project.repository.destroy
253 253 @repository = Repository::Cvs.create!(
254 254 :project => Project.find(PRJ_ID),
255 255 :root_url => "/invalid",
256 256 :url => MODULE_NAME,
257 257 :log_encoding => 'UTF-8'
258 258 )
259 259 @repository.fetch_changesets
260 260 @project.reload
261 261 assert_equal 0, @repository.changesets.count
262 262
263 263 assert_difference 'Repository.count', -1 do
264 264 delete :destroy, :id => @repository.id
265 265 end
266 266 assert_response 302
267 267 @project.reload
268 268 assert_nil @project.repository
269 269 end
270 270 else
271 271 puts "CVS test repository NOT FOUND. Skipping functional tests !!!"
272 272 def test_fake; assert true end
273 273 end
274 274 end
General Comments 0
You need to be logged in to leave comments. Login now