##// END OF EJS Templates
scm: git: remove duplicate test from functional test....
Toshi MARUYAMA -
r5077:002ff62e331a
parent child
Show More
@@ -1,253 +1,241
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2008 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 require 'repositories_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class RepositoriesController; def rescue_action(e) raise e end; end
23 23
24 24 class RepositoriesGitControllerTest < ActionController::TestCase
25 25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules
26 26
27 27 # No '..' in the repository path
28 28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
29 29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
30 30
31 31 def setup
32 32 @controller = RepositoriesController.new
33 33 @request = ActionController::TestRequest.new
34 34 @response = ActionController::TestResponse.new
35 35 User.current = nil
36 36 @repository = Repository::Git.create(
37 37 :project => Project.find(3),
38 38 :url => REPOSITORY_PATH,
39 39 :path_encoding => 'ISO-8859-1'
40 40 )
41 41 assert @repository
42 42 end
43 43
44 44 if File.directory?(REPOSITORY_PATH)
45 def test_show
46 @repository.fetch_changesets
47 @repository.reload
48 get :show, :id => 3
49 assert_response :success
50 assert_template 'show'
51 assert_not_nil assigns(:entries)
52 assert assigns(:entries).size > 0
53 assert_not_nil assigns(:changesets)
54 assigns(:changesets).size > 0
55 end
56
57 45 def test_browse_root
58 46 @repository.fetch_changesets
59 47 @repository.reload
60 48 get :show, :id => 3
61 49 assert_response :success
62 50 assert_template 'show'
63 51 assert_not_nil assigns(:entries)
64 52 assert_equal 9, assigns(:entries).size
65 53 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
66 54 assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'}
67 55 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
68 56 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
69 57 assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'}
70 58 assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'}
71 59 assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'}
72 60 assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'}
73 61 assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'}
74 62 assert_not_nil assigns(:changesets)
75 63 assigns(:changesets).size > 0
76 64 end
77 65
78 66 def test_browse_branch
79 67 @repository.fetch_changesets
80 68 @repository.reload
81 69 get :show, :id => 3, :rev => 'test_branch'
82 70 assert_response :success
83 71 assert_template 'show'
84 72 assert_not_nil assigns(:entries)
85 73 assert_equal 4, assigns(:entries).size
86 74 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
87 75 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
88 76 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
89 77 assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'}
90 78 assert_not_nil assigns(:changesets)
91 79 assigns(:changesets).size > 0
92 80 end
93 81
94 82 def test_browse_tag
95 83 @repository.fetch_changesets
96 84 @repository.reload
97 85 [
98 86 "tag00.lightweight",
99 87 "tag01.annotated",
100 88 ].each do |t1|
101 89 get :show, :id => 3, :rev => t1
102 90 assert_response :success
103 91 assert_template 'show'
104 92 assert_not_nil assigns(:entries)
105 93 assigns(:entries).size > 0
106 94 assert_not_nil assigns(:changesets)
107 95 assigns(:changesets).size > 0
108 96 end
109 97 end
110 98
111 99 def test_browse_directory
112 100 @repository.fetch_changesets
113 101 @repository.reload
114 102 get :show, :id => 3, :path => ['images']
115 103 assert_response :success
116 104 assert_template 'show'
117 105 assert_not_nil assigns(:entries)
118 106 assert_equal ['edit.png'], assigns(:entries).collect(&:name)
119 107 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
120 108 assert_not_nil entry
121 109 assert_equal 'file', entry.kind
122 110 assert_equal 'images/edit.png', entry.path
123 111 assert_not_nil assigns(:changesets)
124 112 assigns(:changesets).size > 0
125 113 end
126 114
127 115 def test_browse_at_given_revision
128 116 @repository.fetch_changesets
129 117 @repository.reload
130 118 get :show, :id => 3, :path => ['images'], :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
131 119 assert_response :success
132 120 assert_template 'show'
133 121 assert_not_nil assigns(:entries)
134 122 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
135 123 assert_not_nil assigns(:changesets)
136 124 assigns(:changesets).size > 0
137 125 end
138 126
139 127 def test_changes
140 128 get :changes, :id => 3, :path => ['images', 'edit.png']
141 129 assert_response :success
142 130 assert_template 'changes'
143 131 assert_tag :tag => 'h2', :content => 'edit.png'
144 132 end
145 133
146 134 def test_entry_show
147 135 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
148 136 assert_response :success
149 137 assert_template 'entry'
150 138 # Line 19
151 139 assert_tag :tag => 'th',
152 140 :content => /11/,
153 141 :attributes => { :class => /line-num/ },
154 142 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
155 143 end
156 144
157 145 def test_entry_download
158 146 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
159 147 assert_response :success
160 148 # File content
161 149 assert @response.body.include?('WITHOUT ANY WARRANTY')
162 150 end
163 151
164 152 def test_directory_entry
165 153 get :entry, :id => 3, :path => ['sources']
166 154 assert_response :success
167 155 assert_template 'show'
168 156 assert_not_nil assigns(:entry)
169 157 assert_equal 'sources', assigns(:entry).name
170 158 end
171 159
172 160 def test_diff
173 161 @repository.fetch_changesets
174 162 @repository.reload
175 163
176 164 # Full diff of changeset 2f9c0091
177 165 get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
178 166 assert_response :success
179 167 assert_template 'diff'
180 168 # Line 22 removed
181 169 assert_tag :tag => 'th',
182 170 :content => /22/,
183 171 :sibling => { :tag => 'td',
184 172 :attributes => { :class => /diff_out/ },
185 173 :content => /def remove/ }
186 174 assert_tag :tag => 'h2', :content => /2f9c0091/
187 175 end
188 176
189 177 def test_diff_two_revs
190 178 @repository.fetch_changesets
191 179 @repository.reload
192 180
193 181 get :diff, :id => 3, :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
194 182 :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
195 183 assert_response :success
196 184 assert_template 'diff'
197 185
198 186 diff = assigns(:diff)
199 187 assert_not_nil diff
200 188 assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/
201 189 end
202 190
203 191 def test_annotate
204 192 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
205 193 assert_response :success
206 194 assert_template 'annotate'
207 195 # Line 23, changeset 2f9c0091
208 196 assert_tag :tag => 'th', :content => /24/,
209 197 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /2f9c0091/ } },
210 198 :sibling => { :tag => 'td', :content => /jsmith/ },
211 199 :sibling => { :tag => 'td', :content => /watcher =/ }
212 200 end
213 201
214 202 def test_annotate_at_given_revision
215 203 @repository.fetch_changesets
216 204 @repository.reload
217 205 get :annotate, :id => 3, :rev => 'deff7', :path => ['sources', 'watchers_controller.rb']
218 206 assert_response :success
219 207 assert_template 'annotate'
220 208 assert_tag :tag => 'h2', :content => /@ deff712f/
221 209 end
222 210
223 211 def test_annotate_binary_file
224 212 get :annotate, :id => 3, :path => ['images', 'edit.png']
225 213 assert_response 500
226 214 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
227 215 :content => /can not be annotated/
228 216 end
229 217
230 218 def test_revision
231 219 @repository.fetch_changesets
232 220 @repository.reload
233 221 ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
234 222 get :revision, :id => 3, :rev => r
235 223 assert_response :success
236 224 assert_template 'revision'
237 225 end
238 226 end
239 227
240 228 def test_empty_revision
241 229 @repository.fetch_changesets
242 230 @repository.reload
243 231 ['', ' ', nil].each do |r|
244 232 get :revision, :id => 3, :rev => r
245 233 assert_response 404
246 234 assert_error_tag :content => /was not found/
247 235 end
248 236 end
249 237 else
250 238 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
251 239 def test_fake; assert true end
252 240 end
253 241 end
General Comments 0
You need to be logged in to leave comments. Login now