##// END OF EJS Templates
scm: mercurial: add path encoding tests in functional test (#2664, #4050)....
Toshi MARUYAMA -
r4880:82c670ba0355
parent child
Show More
@@ -26,6 +26,9 class RepositoriesMercurialControllerTest < ActionController::TestCase
26
26
27 # No '..' in the repository path
27 # No '..' in the repository path
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
29 CHAR_1_HEX = "\xc3\x9c"
30
31 ruby19_non_utf8_pass = (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
29
32
30 def setup
33 def setup
31 @controller = RepositoriesController.new
34 @controller = RepositoriesController.new
@@ -39,9 +42,18 class RepositoriesMercurialControllerTest < ActionController::TestCase
39 )
42 )
40 assert @repository
43 assert @repository
41 @diff_c_support = true
44 @diff_c_support = true
45 @char_1 = CHAR_1_HEX.dup
46 if @char_1.respond_to?(:force_encoding)
47 @char_1.force_encoding('UTF-8')
48 end
42 end
49 end
43
50
44 if File.directory?(REPOSITORY_PATH)
51 if ruby19_non_utf8_pass
52 puts "TODO: Mercurial functional test fails in Ruby 1.9 " +
53 "and Encoding.default_external is not UTF-8. " +
54 "Current value is '#{Encoding.default_external.to_s}'"
55 def test_fake; assert true end
56 elsif File.directory?(REPOSITORY_PATH)
45 def test_show
57 def test_show
46 get :show, :id => 3
58 get :show, :id => 3
47 assert_response :success
59 assert_response :success
@@ -99,6 +111,25 class RepositoriesMercurialControllerTest < ActionController::TestCase
99 end
111 end
100 end
112 end
101
113
114 def test_show_directory_latin_1
115 @repository.fetch_changesets
116 @repository.reload
117 [21, '21', 'adf805632193'].each do |r1|
118 get :show, :id => 3, :path => ['latin-1-dir'], :rev => r1
119 assert_response :success
120 assert_template 'show'
121
122 assert_not_nil assigns(:entries)
123 assert_equal ["make-latin-1-file.rb",
124 "test-#{@char_1}-1.txt",
125 "test-#{@char_1}-2.txt",
126 "test-#{@char_1}.txt"], assigns(:entries).collect(&:name)
127 changesets = assigns(:changesets)
128 assert_not_nil changesets
129 assert_equal %w(21 20 19 18 17), changesets.collect(&:revision)
130 end
131 end
132
102 def test_changes
133 def test_changes
103 get :changes, :id => 3, :path => ['images', 'edit.png']
134 get :changes, :id => 3, :path => ['images', 'edit.png']
104 assert_response :success
135 assert_response :success
@@ -116,6 +147,18 class RepositoriesMercurialControllerTest < ActionController::TestCase
116 :attributes => { :class => 'line-num' },
147 :attributes => { :class => 'line-num' },
117 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
148 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
118 end
149 end
150
151 def test_entry_show_latin_1
152 [21, '21', 'adf805632193'].each do |r1|
153 get :entry, :id => 3, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
154 assert_response :success
155 assert_template 'entry'
156 assert_tag :tag => 'th',
157 :content => '1',
158 :attributes => { :class => 'line-num' },
159 :sibling => { :tag => 'td', :content => /Mercurial is a distributed version control system/ }
160 end
161 end
119
162
120 def test_entry_download
163 def test_entry_download
121 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
164 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
@@ -172,6 +215,19 class RepositoriesMercurialControllerTest < ActionController::TestCase
172 end
215 end
173 end
216 end
174
217
218 def test_diff_latin_1
219 [21, 'adf805632193'].each do |r1|
220 get :diff, :id => 3, :rev => r1
221 assert_response :success
222 assert_template 'diff'
223 assert_tag :tag => 'th',
224 :content => '2',
225 :sibling => { :tag => 'td',
226 :attributes => { :class => /diff_in/ },
227 :content => /It is written in Python/ }
228 end
229 end
230
175 def test_annotate
231 def test_annotate
176 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
232 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
177 assert_response :success
233 assert_response :success
@@ -212,6 +268,38 class RepositoriesMercurialControllerTest < ActionController::TestCase
212 end
268 end
213 end
269 end
214
270
271 def test_annotate_latin_1
272 [21, '21', 'adf805632193'].each do |r1|
273 get :annotate, :id => 3, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
274 assert_response :success
275 assert_template 'annotate'
276 assert_tag :tag => 'th',
277 :content => '1',
278 :attributes => { :class => 'line-num' },
279 :sibling =>
280 {
281 :tag => 'td',
282 :attributes => { :class => 'revision' },
283 :child => { :tag => 'a', :content => '20:709858aafd1b' }
284 }
285 assert_tag :tag => 'th',
286 :content => '1',
287 :attributes => { :class => 'line-num' },
288 :sibling =>
289 {
290 :tag => 'td' ,
291 :content => 'jsmith' ,
292 :attributes => { :class => 'author' },
293
294 }
295 assert_tag :tag => 'th',
296 :content => '1',
297 :attributes => { :class => 'line-num' },
298 :sibling => { :tag => 'td', :content => /Mercurial is a distributed version control system/ }
299
300 end
301 end
302
215 def test_empty_revision
303 def test_empty_revision
216 @repository.fetch_changesets
304 @repository.fetch_changesets
217 @repository.reload
305 @repository.reload
General Comments 0
You need to be logged in to leave comments. Login now