##// END OF EJS Templates
scm: filesystem: remove trailing white-spaces from functional test....
Toshi MARUYAMA -
r5562:20f5b6b45dbc
parent child
Show More
@@ -1,108 +1,108
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 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 RepositoriesFilesystemControllerTest < 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/filesystem_repository'
29 29 PRJ_ID = 3
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 Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
37 37 @repository = Repository::Filesystem.create(
38 38 :project => Project.find(PRJ_ID),
39 39 :url => REPOSITORY_PATH,
40 40 :path_encoding => ''
41 41 )
42 42 assert @repository
43 43 end
44 44
45 45 if File.directory?(REPOSITORY_PATH)
46 46 def test_browse_root
47 47 @repository.fetch_changesets
48 48 @repository.reload
49 49 get :show, :id => PRJ_ID
50 50 assert_response :success
51 51 assert_template 'show'
52 52 assert_not_nil assigns(:entries)
53 53 assert assigns(:entries).size > 0
54 54 assert_not_nil assigns(:changesets)
55 55 assert assigns(:changesets).size == 0
56 56 end
57 57
58 58 def test_show_no_extension
59 59 get :entry, :id => PRJ_ID, :path => ['test']
60 60 assert_response :success
61 61 assert_template 'entry'
62 62 assert_tag :tag => 'th',
63 63 :content => '1',
64 64 :attributes => { :class => 'line-num' },
65 65 :sibling => { :tag => 'td', :content => /TEST CAT/ }
66 66 end
67 67
68 68 def test_entry_download_no_extension
69 69 get :entry, :id => PRJ_ID, :path => ['test'], :format => 'raw'
70 70 assert_response :success
71 71 assert_equal 'application/octet-stream', @response.content_type
72 72 end
73 73
74 74 def test_show_non_ascii_contents
75 75 with_settings :repositories_encodings => 'UTF-8,EUC-JP' do
76 76 get :entry, :id => PRJ_ID, :path => ['japanese', 'euc-jp.txt']
77 77 assert_response :success
78 78 assert_template 'entry'
79 79 assert_tag :tag => 'th',
80 80 :content => '2',
81 81 :attributes => { :class => 'line-num' },
82 82 :sibling => { :tag => 'td', :content => /japanese/ }
83 83 end
84 84 end
85 85
86 86 def test_show_utf16
87 87 with_settings :repositories_encodings => 'UTF-16' do
88 88 get :entry, :id => PRJ_ID, :path => ['japanese', 'utf-16.txt']
89 89 assert_response :success
90 90 assert_tag :tag => 'th',
91 91 :content => '2',
92 92 :attributes => { :class => 'line-num' },
93 93 :sibling => { :tag => 'td', :content => /japanese/ }
94 94 end
95 95 end
96 96
97 97 def test_show_text_file_should_send_if_too_big
98 98 with_settings :file_max_size_displayed => 1 do
99 99 get :entry, :id => PRJ_ID, :path => ['japanese', 'big-file.txt']
100 100 assert_response :success
101 101 assert_equal 'text/plain', @response.content_type
102 102 end
103 103 end
104 104 else
105 105 puts "Filesystem test repository NOT FOUND. Skipping functional tests !!!"
106 106 def test_fake; assert true end
107 107 end
108 108 end
General Comments 0
You need to be logged in to leave comments. Login now