##// END OF EJS Templates
remove trailing white-space from test/functional/repositories_bazaar_controller_test.rb (#14931)...
Toshi MARUYAMA -
r11927:11ae71c5b993
parent child
Show More
@@ -1,246 +1,246
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2013 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 RepositoriesBazaarControllerTest < 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/bazaar_repository').to_s
27 27 REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk")
28 28 PRJ_ID = 3
29 29 CHAR_1_UTF8_HEX = "\xc3\x9c"
30 30
31 31 def setup
32 32 User.current = nil
33 33 @project = Project.find(PRJ_ID)
34 34 @repository = Repository::Bazaar.create(
35 35 :project => @project,
36 36 :url => REPOSITORY_PATH_TRUNK,
37 37 :log_encoding => 'UTF-8')
38 38 assert @repository
39 39 @char_1_utf8 = CHAR_1_UTF8_HEX.dup
40 40 if @char_1_utf8.respond_to?(:force_encoding)
41 41 @char_1_utf8.force_encoding('UTF-8')
42 42 end
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 => 'Bazaar'
50 50 assert_response :success
51 51 assert_template 'new'
52 52 assert_kind_of Repository::Bazaar, assigns(:repository)
53 53 assert assigns(:repository).new_record?
54 54 end
55 55
56 56 def test_browse_root
57 57 get :show, :id => PRJ_ID
58 58 assert_response :success
59 59 assert_template 'show'
60 60 assert_not_nil assigns(:entries)
61 61 assert_equal 2, assigns(:entries).size
62 62 assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'}
63 63 assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'}
64 64 end
65 65
66 66 def test_browse_directory
67 67 get :show, :id => PRJ_ID, :path => repository_path_hash(['directory'])[:param]
68 68 assert_response :success
69 69 assert_template 'show'
70 70 assert_not_nil assigns(:entries)
71 71 assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name)
72 72 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
73 73 assert_not_nil entry
74 74 assert_equal 'file', entry.kind
75 75 assert_equal 'directory/edit.png', entry.path
76 76 end
77 77
78 78 def test_browse_at_given_revision
79 79 get :show, :id => PRJ_ID, :path => repository_path_hash([])[:param],
80 80 :rev => 3
81 81 assert_response :success
82 82 assert_template 'show'
83 83 assert_not_nil assigns(:entries)
84 84 assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'],
85 85 assigns(:entries).collect(&:name)
86 86 end
87 87
88 88 def test_changes
89 89 get :changes, :id => PRJ_ID,
90 90 :path => repository_path_hash(['doc-mkdir.txt'])[:param]
91 91 assert_response :success
92 92 assert_template 'changes'
93 93 assert_tag :tag => 'h2', :content => 'doc-mkdir.txt'
94 94 end
95 95
96 96 def test_entry_show
97 97 get :entry, :id => PRJ_ID,
98 98 :path => repository_path_hash(['directory', 'doc-ls.txt'])[:param]
99 99 assert_response :success
100 100 assert_template 'entry'
101 101 # Line 19
102 102 assert_tag :tag => 'th',
103 103 :content => /29/,
104 104 :attributes => { :class => /line-num/ },
105 105 :sibling => { :tag => 'td', :content => /Show help message/ }
106 106 end
107 107
108 108 def test_entry_download
109 109 get :entry, :id => PRJ_ID,
110 110 :path => repository_path_hash(['directory', 'doc-ls.txt'])[:param],
111 111 :format => 'raw'
112 112 assert_response :success
113 113 # File content
114 114 assert @response.body.include?('Show help message')
115 115 end
116 116
117 117 def test_directory_entry
118 118 get :entry, :id => PRJ_ID,
119 119 :path => repository_path_hash(['directory'])[:param]
120 120 assert_response :success
121 121 assert_template 'show'
122 122 assert_not_nil assigns(:entry)
123 123 assert_equal 'directory', assigns(:entry).name
124 124 end
125 125
126 126 def test_diff
127 127 # Full diff of changeset 3
128 128 ['inline', 'sbs'].each do |dt|
129 129 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
130 130 assert_response :success
131 131 assert_template 'diff'
132 132 # Line 11 removed
133 133 assert_tag :tag => 'th',
134 134 :content => '11',
135 135 :sibling => { :tag => 'td',
136 136 :attributes => { :class => /diff_out/ },
137 137 :content => /Display more information/ }
138 138 end
139 139 end
140 140
141 141 def test_annotate
142 142 get :annotate, :id => PRJ_ID,
143 143 :path => repository_path_hash(['doc-mkdir.txt'])[:param]
144 144 assert_response :success
145 145 assert_template 'annotate'
146 146 assert_select "th.line-num", :text => '2' do
147 147 assert_select "+ td.revision" do
148 148 assert_select "a", :text => '3'
149 149 assert_select "+ td.author", :text => "jsmith@" do
150 150 assert_select "+ td",
151 151 :text => "Main purpose:"
152 152 end
153 153 end
154 154 end
155 155 end
156 156
157 157 def test_annotate_author_escaping
158 158 repository = Repository::Bazaar.create(
159 159 :project => @project,
160 160 :url => File.join(REPOSITORY_PATH, "author_escaping"),
161 161 :identifier => 'author_escaping',
162 162 :log_encoding => 'UTF-8')
163 163 assert repository
164 164 get :annotate, :id => PRJ_ID, :repository_id => 'author_escaping',
165 165 :path => repository_path_hash(['author-escaping-test.txt'])[:param]
166 166 assert_response :success
167 167 assert_template 'annotate'
168 168 assert_select "th.line-num", :text => '1' do
169 169 assert_select "+ td.revision" do
170 170 assert_select "a", :text => '2'
171 171 assert_select "+ td.author", :text => "test &amp;" do
172 172 assert_select "+ td",
173 173 :text => "author escaping test"
174 174 end
175 175 end
176 176 end
177 177 end
178 178
179 179 if REPOSITORY_PATH.respond_to?(:force_encoding)
180 180 def test_annotate_author_non_ascii
181 181 log_encoding = nil
182 if Encoding.locale_charmap == "UTF-8" ||
182 if Encoding.locale_charmap == "UTF-8" ||
183 183 Encoding.locale_charmap == "ISO-8859-1"
184 184 log_encoding = Encoding.locale_charmap
185 185 end
186 186 unless log_encoding.nil?
187 187 repository = Repository::Bazaar.create(
188 188 :project => @project,
189 189 :url => File.join(REPOSITORY_PATH, "author_non_ascii"),
190 190 :identifier => 'author_non_ascii',
191 191 :log_encoding => log_encoding)
192 192 assert repository
193 193 get :annotate, :id => PRJ_ID, :repository_id => 'author_non_ascii',
194 194 :path => repository_path_hash(['author-non-ascii-test.txt'])[:param]
195 195 assert_response :success
196 196 assert_template 'annotate'
197 197 assert_select "th.line-num", :text => '1' do
198 198 assert_select "+ td.revision" do
199 199 assert_select "a", :text => '2'
200 200 assert_select "+ td.author", :text => "test #{@char_1_utf8}" do
201 201 assert_select "+ td",
202 202 :text => "author non ASCII test"
203 203 end
204 204 end
205 205 end
206 206 end
207 207 end
208 208 end
209 209
210 210 def test_destroy_valid_repository
211 211 @request.session[:user_id] = 1 # admin
212 212 assert_equal 0, @repository.changesets.count
213 213 @repository.fetch_changesets
214 214 assert @repository.changesets.count > 0
215 215
216 216 assert_difference 'Repository.count', -1 do
217 217 delete :destroy, :id => @repository.id
218 218 end
219 219 assert_response 302
220 220 @project.reload
221 221 assert_nil @project.repository
222 222 end
223 223
224 224 def test_destroy_invalid_repository
225 225 @request.session[:user_id] = 1 # admin
226 226 @project.repository.destroy
227 227 @repository = Repository::Bazaar.create!(
228 228 :project => @project,
229 229 :url => "/invalid",
230 230 :log_encoding => 'UTF-8')
231 231 @repository.fetch_changesets
232 232 @repository.reload
233 233 assert_equal 0, @repository.changesets.count
234 234
235 235 assert_difference 'Repository.count', -1 do
236 236 delete :destroy, :id => @repository.id
237 237 end
238 238 assert_response 302
239 239 @project.reload
240 240 assert_nil @project.repository
241 241 end
242 242 else
243 243 puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!"
244 244 def test_fake; assert true end
245 245 end
246 246 end
General Comments 0
You need to be logged in to leave comments. Login now