@@ -1,396 +1,408 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 | require 'repositories_controller' |
|
19 | require 'repositories_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class RepositoriesController; def rescue_action(e) raise e end; end |
|
22 | class RepositoriesController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class RepositoriesGitControllerTest < ActionController::TestCase |
|
24 | class RepositoriesGitControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
25 | fixtures :projects, :users, :roles, :members, :member_roles, | |
26 | :repositories, :enabled_modules |
|
26 | :repositories, :enabled_modules | |
27 |
|
27 | |||
28 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s |
|
28 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |
29 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
29 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
30 | PRJ_ID = 3 |
|
30 | PRJ_ID = 3 | |
31 | CHAR_1_HEX = "\xc3\x9c" |
|
31 | CHAR_1_HEX = "\xc3\x9c" | |
32 |
|
32 | |||
33 | ## Git, Mercurial and CVS path encodings are binary. |
|
33 | ## Git, Mercurial and CVS path encodings are binary. | |
34 | ## Subversion supports URL encoding for path. |
|
34 | ## Subversion supports URL encoding for path. | |
35 | ## Redmine Mercurial adapter and extension use URL encoding. |
|
35 | ## Redmine Mercurial adapter and extension use URL encoding. | |
36 | ## Git accepts only binary path in command line parameter. |
|
36 | ## Git accepts only binary path in command line parameter. | |
37 | ## So, there is no way to use binary command line parameter in JRuby. |
|
37 | ## So, there is no way to use binary command line parameter in JRuby. | |
38 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') |
|
38 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') | |
39 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" |
|
39 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" | |
40 |
|
40 | |||
41 | def setup |
|
41 | def setup | |
42 | @ruby19_non_utf8_pass = |
|
42 | @ruby19_non_utf8_pass = | |
43 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') |
|
43 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') | |
44 |
|
44 | |||
45 | @controller = RepositoriesController.new |
|
45 | @controller = RepositoriesController.new | |
46 | @request = ActionController::TestRequest.new |
|
46 | @request = ActionController::TestRequest.new | |
47 | @response = ActionController::TestResponse.new |
|
47 | @response = ActionController::TestResponse.new | |
48 | User.current = nil |
|
48 | User.current = nil | |
49 | @project = Project.find(PRJ_ID) |
|
49 | @project = Project.find(PRJ_ID) | |
50 | @repository = Repository::Git.create( |
|
50 | @repository = Repository::Git.create( | |
51 | :project => @project, |
|
51 | :project => @project, | |
52 | :url => REPOSITORY_PATH, |
|
52 | :url => REPOSITORY_PATH, | |
53 | :path_encoding => 'ISO-8859-1' |
|
53 | :path_encoding => 'ISO-8859-1' | |
54 | ) |
|
54 | ) | |
55 | assert @repository |
|
55 | assert @repository | |
56 | @char_1 = CHAR_1_HEX.dup |
|
56 | @char_1 = CHAR_1_HEX.dup | |
57 | if @char_1.respond_to?(:force_encoding) |
|
57 | if @char_1.respond_to?(:force_encoding) | |
58 | @char_1.force_encoding('UTF-8') |
|
58 | @char_1.force_encoding('UTF-8') | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | Setting.default_language = 'en' |
|
61 | Setting.default_language = 'en' | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | if File.directory?(REPOSITORY_PATH) |
|
64 | if File.directory?(REPOSITORY_PATH) | |
65 | def test_browse_root |
|
65 | def test_browse_root | |
66 | @repository.fetch_changesets |
|
66 | @repository.fetch_changesets | |
67 | @repository.reload |
|
67 | @repository.reload | |
68 | get :show, :id => PRJ_ID |
|
68 | get :show, :id => PRJ_ID | |
69 | assert_response :success |
|
69 | assert_response :success | |
70 | assert_template 'show' |
|
70 | assert_template 'show' | |
71 | assert_not_nil assigns(:entries) |
|
71 | assert_not_nil assigns(:entries) | |
72 | assert_equal 9, assigns(:entries).size |
|
72 | assert_equal 9, assigns(:entries).size | |
73 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
73 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
74 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} |
|
74 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} | |
75 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
75 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
76 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
76 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
77 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} |
|
77 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} | |
78 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} |
|
78 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} | |
79 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} |
|
79 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} | |
80 | assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} |
|
80 | assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} | |
81 | assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} |
|
81 | assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} | |
82 | assert_not_nil assigns(:changesets) |
|
82 | assert_not_nil assigns(:changesets) | |
83 | assert assigns(:changesets).size > 0 |
|
83 | assert assigns(:changesets).size > 0 | |
84 | end |
|
84 | end | |
85 |
|
85 | |||
86 | def test_browse_branch |
|
86 | def test_browse_branch | |
87 | @repository.fetch_changesets |
|
87 | @repository.fetch_changesets | |
88 | @repository.reload |
|
88 | @repository.reload | |
89 | get :show, :id => PRJ_ID, :rev => 'test_branch' |
|
89 | get :show, :id => PRJ_ID, :rev => 'test_branch' | |
90 | assert_response :success |
|
90 | assert_response :success | |
91 | assert_template 'show' |
|
91 | assert_template 'show' | |
92 | assert_not_nil assigns(:entries) |
|
92 | assert_not_nil assigns(:entries) | |
93 | assert_equal 4, assigns(:entries).size |
|
93 | assert_equal 4, assigns(:entries).size | |
94 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
94 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
95 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
95 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
96 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
96 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
97 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} |
|
97 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} | |
98 | assert_not_nil assigns(:changesets) |
|
98 | assert_not_nil assigns(:changesets) | |
99 | assert assigns(:changesets).size > 0 |
|
99 | assert assigns(:changesets).size > 0 | |
100 | end |
|
100 | end | |
101 |
|
101 | |||
102 | def test_browse_tag |
|
102 | def test_browse_tag | |
103 | @repository.fetch_changesets |
|
103 | @repository.fetch_changesets | |
104 | @repository.reload |
|
104 | @repository.reload | |
105 | [ |
|
105 | [ | |
106 | "tag00.lightweight", |
|
106 | "tag00.lightweight", | |
107 | "tag01.annotated", |
|
107 | "tag01.annotated", | |
108 | ].each do |t1| |
|
108 | ].each do |t1| | |
109 | get :show, :id => PRJ_ID, :rev => t1 |
|
109 | get :show, :id => PRJ_ID, :rev => t1 | |
110 | assert_response :success |
|
110 | assert_response :success | |
111 | assert_template 'show' |
|
111 | assert_template 'show' | |
112 | assert_not_nil assigns(:entries) |
|
112 | assert_not_nil assigns(:entries) | |
113 | assert assigns(:entries).size > 0 |
|
113 | assert assigns(:entries).size > 0 | |
114 | assert_not_nil assigns(:changesets) |
|
114 | assert_not_nil assigns(:changesets) | |
115 | assert assigns(:changesets).size > 0 |
|
115 | assert assigns(:changesets).size > 0 | |
116 | end |
|
116 | end | |
117 | end |
|
117 | end | |
118 |
|
118 | |||
119 | def test_browse_directory |
|
119 | def test_browse_directory | |
120 | @repository.fetch_changesets |
|
120 | @repository.fetch_changesets | |
121 | @repository.reload |
|
121 | @repository.reload | |
122 | get :show, :id => PRJ_ID, :path => ['images'] |
|
122 | get :show, :id => PRJ_ID, :path => ['images'] | |
123 | assert_response :success |
|
123 | assert_response :success | |
124 | assert_template 'show' |
|
124 | assert_template 'show' | |
125 | assert_not_nil assigns(:entries) |
|
125 | assert_not_nil assigns(:entries) | |
126 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) |
|
126 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) | |
127 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
127 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
128 | assert_not_nil entry |
|
128 | assert_not_nil entry | |
129 | assert_equal 'file', entry.kind |
|
129 | assert_equal 'file', entry.kind | |
130 | assert_equal 'images/edit.png', entry.path |
|
130 | assert_equal 'images/edit.png', entry.path | |
131 | assert_not_nil assigns(:changesets) |
|
131 | assert_not_nil assigns(:changesets) | |
132 | assert assigns(:changesets).size > 0 |
|
132 | assert assigns(:changesets).size > 0 | |
133 | end |
|
133 | end | |
134 |
|
134 | |||
135 | def test_browse_at_given_revision |
|
135 | def test_browse_at_given_revision | |
136 | @repository.fetch_changesets |
|
136 | @repository.fetch_changesets | |
137 | @repository.reload |
|
137 | @repository.reload | |
138 | get :show, :id => PRJ_ID, :path => ['images'], |
|
138 | get :show, :id => PRJ_ID, :path => ['images'], | |
139 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' |
|
139 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' | |
140 | assert_response :success |
|
140 | assert_response :success | |
141 | assert_template 'show' |
|
141 | assert_template 'show' | |
142 | assert_not_nil assigns(:entries) |
|
142 | assert_not_nil assigns(:entries) | |
143 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
143 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
144 | assert_not_nil assigns(:changesets) |
|
144 | assert_not_nil assigns(:changesets) | |
145 | assert assigns(:changesets).size > 0 |
|
145 | assert assigns(:changesets).size > 0 | |
146 | end |
|
146 | end | |
147 |
|
147 | |||
148 | def test_changes |
|
148 | def test_changes | |
149 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] |
|
149 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
150 | assert_response :success |
|
150 | assert_response :success | |
151 | assert_template 'changes' |
|
151 | assert_template 'changes' | |
152 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
152 | assert_tag :tag => 'h2', :content => 'edit.png' | |
153 | end |
|
153 | end | |
154 |
|
154 | |||
155 | def test_entry_show |
|
155 | def test_entry_show | |
156 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
156 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
157 | assert_response :success |
|
157 | assert_response :success | |
158 | assert_template 'entry' |
|
158 | assert_template 'entry' | |
159 | # Line 19 |
|
159 | # Line 19 | |
160 | assert_tag :tag => 'th', |
|
160 | assert_tag :tag => 'th', | |
161 | :content => '11', |
|
161 | :content => '11', | |
162 | :attributes => { :class => 'line-num' }, |
|
162 | :attributes => { :class => 'line-num' }, | |
163 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
163 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } | |
164 | end |
|
164 | end | |
165 |
|
165 | |||
166 | def test_entry_show_latin_1 |
|
166 | def test_entry_show_latin_1 | |
167 | if @ruby19_non_utf8_pass |
|
167 | if @ruby19_non_utf8_pass | |
168 | puts_ruby19_non_utf8_pass() |
|
168 | puts_ruby19_non_utf8_pass() | |
169 | elsif JRUBY_SKIP |
|
169 | elsif JRUBY_SKIP | |
170 | puts JRUBY_SKIP_STR |
|
170 | puts JRUBY_SKIP_STR | |
171 | else |
|
171 | else | |
172 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
172 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
173 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
173 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
174 | get :entry, :id => PRJ_ID, |
|
174 | get :entry, :id => PRJ_ID, | |
175 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
175 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 | |
176 | assert_response :success |
|
176 | assert_response :success | |
177 | assert_template 'entry' |
|
177 | assert_template 'entry' | |
178 | assert_tag :tag => 'th', |
|
178 | assert_tag :tag => 'th', | |
179 | :content => '1', |
|
179 | :content => '1', | |
180 | :attributes => { :class => 'line-num' }, |
|
180 | :attributes => { :class => 'line-num' }, | |
181 | :sibling => { :tag => 'td', |
|
181 | :sibling => { :tag => 'td', | |
182 | :content => /test-#{@char_1}.txt/ } |
|
182 | :content => /test-#{@char_1}.txt/ } | |
183 | end |
|
183 | end | |
184 | end |
|
184 | end | |
185 | end |
|
185 | end | |
186 | end |
|
186 | end | |
187 |
|
187 | |||
188 | def test_entry_download |
|
188 | def test_entry_download | |
189 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], |
|
189 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], | |
190 | :format => 'raw' |
|
190 | :format => 'raw' | |
191 | assert_response :success |
|
191 | assert_response :success | |
192 | # File content |
|
192 | # File content | |
193 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
193 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |
194 | end |
|
194 | end | |
195 |
|
195 | |||
196 | def test_directory_entry |
|
196 | def test_directory_entry | |
197 | get :entry, :id => PRJ_ID, :path => ['sources'] |
|
197 | get :entry, :id => PRJ_ID, :path => ['sources'] | |
198 | assert_response :success |
|
198 | assert_response :success | |
199 | assert_template 'show' |
|
199 | assert_template 'show' | |
200 | assert_not_nil assigns(:entry) |
|
200 | assert_not_nil assigns(:entry) | |
201 | assert_equal 'sources', assigns(:entry).name |
|
201 | assert_equal 'sources', assigns(:entry).name | |
202 | end |
|
202 | end | |
203 |
|
203 | |||
204 | def test_diff |
|
204 | def test_diff | |
205 | @repository.fetch_changesets |
|
205 | @repository.fetch_changesets | |
206 | @repository.reload |
|
206 | @repository.reload | |
207 | # Full diff of changeset 2f9c0091 |
|
207 | # Full diff of changeset 2f9c0091 | |
208 | ['inline', 'sbs'].each do |dt| |
|
208 | ['inline', 'sbs'].each do |dt| | |
209 | get :diff, |
|
209 | get :diff, | |
210 | :id => PRJ_ID, |
|
210 | :id => PRJ_ID, | |
211 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
211 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
212 | :type => dt |
|
212 | :type => dt | |
213 | assert_response :success |
|
213 | assert_response :success | |
214 | assert_template 'diff' |
|
214 | assert_template 'diff' | |
215 | # Line 22 removed |
|
215 | # Line 22 removed | |
216 | assert_tag :tag => 'th', |
|
216 | assert_tag :tag => 'th', | |
217 | :content => /22/, |
|
217 | :content => /22/, | |
218 | :sibling => { :tag => 'td', |
|
218 | :sibling => { :tag => 'td', | |
219 | :attributes => { :class => /diff_out/ }, |
|
219 | :attributes => { :class => /diff_out/ }, | |
220 | :content => /def remove/ } |
|
220 | :content => /def remove/ } | |
221 | assert_tag :tag => 'h2', :content => /2f9c0091/ |
|
221 | assert_tag :tag => 'h2', :content => /2f9c0091/ | |
222 | end |
|
222 | end | |
223 | end |
|
223 | end | |
224 |
|
224 | |||
225 | def test_diff_truncated |
|
225 | def test_diff_truncated | |
226 | @repository.fetch_changesets |
|
226 | @repository.fetch_changesets | |
227 | @repository.reload |
|
227 | @repository.reload | |
228 | Setting.diff_max_lines_displayed = 5 |
|
228 | Setting.diff_max_lines_displayed = 5 | |
229 |
|
229 | |||
230 | # Truncated diff of changeset 2f9c0091 |
|
230 | # Truncated diff of changeset 2f9c0091 | |
231 | with_cache do |
|
231 | with_cache do | |
232 | get :diff, :id => PRJ_ID, :type => 'inline', |
|
232 | get :diff, :id => PRJ_ID, :type => 'inline', | |
233 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
233 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
234 | assert_response :success |
|
234 | assert_response :success | |
235 | assert @response.body.include?("... This diff was truncated") |
|
235 | assert @response.body.include?("... This diff was truncated") | |
236 |
|
236 | |||
237 | Setting.default_language = 'fr' |
|
237 | Setting.default_language = 'fr' | |
238 | get :diff, :id => PRJ_ID, :type => 'inline', |
|
238 | get :diff, :id => PRJ_ID, :type => 'inline', | |
239 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
239 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
240 | assert_response :success |
|
240 | assert_response :success | |
241 | assert ! @response.body.include?("... This diff was truncated") |
|
241 | assert ! @response.body.include?("... This diff was truncated") | |
242 | assert @response.body.include?("... Ce diff") |
|
242 | assert @response.body.include?("... Ce diff") | |
243 | end |
|
243 | end | |
244 | end |
|
244 | end | |
245 |
|
245 | |||
246 | def test_diff_two_revs |
|
246 | def test_diff_two_revs | |
247 | @repository.fetch_changesets |
|
247 | @repository.fetch_changesets | |
248 | @repository.reload |
|
248 | @repository.reload | |
249 | ['inline', 'sbs'].each do |dt| |
|
249 | ['inline', 'sbs'].each do |dt| | |
250 | get :diff, |
|
250 | get :diff, | |
251 | :id => PRJ_ID, |
|
251 | :id => PRJ_ID, | |
252 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
252 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
253 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
253 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
254 | :type => dt |
|
254 | :type => dt | |
255 | assert_response :success |
|
255 | assert_response :success | |
256 | assert_template 'diff' |
|
256 | assert_template 'diff' | |
257 | diff = assigns(:diff) |
|
257 | diff = assigns(:diff) | |
258 | assert_not_nil diff |
|
258 | assert_not_nil diff | |
259 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ |
|
259 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ | |
260 | end |
|
260 | end | |
261 | end |
|
261 | end | |
262 |
|
262 | |||
263 | def test_diff_latin_1 |
|
263 | def test_diff_latin_1 | |
264 | if @ruby19_non_utf8_pass |
|
264 | if @ruby19_non_utf8_pass | |
265 | puts_ruby19_non_utf8_pass() |
|
265 | puts_ruby19_non_utf8_pass() | |
266 | else |
|
266 | else | |
267 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
267 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
268 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
268 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
269 | ['inline', 'sbs'].each do |dt| |
|
269 | ['inline', 'sbs'].each do |dt| | |
270 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
270 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
271 | assert_response :success |
|
271 | assert_response :success | |
272 | assert_template 'diff' |
|
272 | assert_template 'diff' | |
273 | assert_tag :tag => 'thead', |
|
273 | assert_tag :tag => 'thead', | |
274 | :descendant => { |
|
274 | :descendant => { | |
275 | :tag => 'th', |
|
275 | :tag => 'th', | |
276 | :attributes => { :class => 'filename' } , |
|
276 | :attributes => { :class => 'filename' } , | |
277 | :content => /latin-1-dir\/test-#{@char_1}.txt/ , |
|
277 | :content => /latin-1-dir\/test-#{@char_1}.txt/ , | |
278 | }, |
|
278 | }, | |
279 | :sibling => { |
|
279 | :sibling => { | |
280 | :tag => 'tbody', |
|
280 | :tag => 'tbody', | |
281 | :descendant => { |
|
281 | :descendant => { | |
282 | :tag => 'td', |
|
282 | :tag => 'td', | |
283 | :attributes => { :class => /diff_in/ }, |
|
283 | :attributes => { :class => /diff_in/ }, | |
284 | :content => /test-#{@char_1}.txt/ |
|
284 | :content => /test-#{@char_1}.txt/ | |
285 | } |
|
285 | } | |
286 | } |
|
286 | } | |
287 | end |
|
287 | end | |
288 | end |
|
288 | end | |
289 | end |
|
289 | end | |
290 | end |
|
290 | end | |
291 | end |
|
291 | end | |
292 |
|
292 | |||
293 | def test_annotate |
|
293 | def test_annotate | |
294 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
294 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
295 | assert_response :success |
|
295 | assert_response :success | |
296 | assert_template 'annotate' |
|
296 | assert_template 'annotate' | |
297 | # Line 24, changeset 2f9c0091 |
|
297 | # Line 24, changeset 2f9c0091 | |
298 | assert_tag :tag => 'th', :content => '24', |
|
298 | assert_tag :tag => 'th', :content => '24', | |
299 | :sibling => { |
|
299 | :sibling => { | |
300 | :tag => 'td', |
|
300 | :tag => 'td', | |
301 | :child => { |
|
301 | :child => { | |
302 | :tag => 'a', |
|
302 | :tag => 'a', | |
303 | :content => /2f9c0091/ |
|
303 | :content => /2f9c0091/ | |
304 | } |
|
304 | } | |
305 | } |
|
305 | } | |
306 | assert_tag :tag => 'th', :content => '24', |
|
306 | assert_tag :tag => 'th', :content => '24', | |
307 | :sibling => { :tag => 'td', :content => /jsmith/ } |
|
307 | :sibling => { :tag => 'td', :content => /jsmith/ } | |
308 | assert_tag :tag => 'th', :content => '24', |
|
308 | assert_tag :tag => 'th', :content => '24', | |
309 | :sibling => { |
|
309 | :sibling => { | |
310 | :tag => 'td', |
|
310 | :tag => 'td', | |
311 | :child => { |
|
311 | :child => { | |
312 | :tag => 'a', |
|
312 | :tag => 'a', | |
313 | :content => /2f9c0091/ |
|
313 | :content => /2f9c0091/ | |
314 | } |
|
314 | } | |
315 | } |
|
315 | } | |
316 | assert_tag :tag => 'th', :content => '24', |
|
316 | assert_tag :tag => 'th', :content => '24', | |
317 | :sibling => { :tag => 'td', :content => /watcher =/ } |
|
317 | :sibling => { :tag => 'td', :content => /watcher =/ } | |
318 | end |
|
318 | end | |
319 |
|
319 | |||
320 | def test_annotate_at_given_revision |
|
320 | def test_annotate_at_given_revision | |
321 | @repository.fetch_changesets |
|
321 | @repository.fetch_changesets | |
322 | @repository.reload |
|
322 | @repository.reload | |
323 | get :annotate, :id => PRJ_ID, :rev => 'deff7', |
|
323 | get :annotate, :id => PRJ_ID, :rev => 'deff7', | |
324 | :path => ['sources', 'watchers_controller.rb'] |
|
324 | :path => ['sources', 'watchers_controller.rb'] | |
325 | assert_response :success |
|
325 | assert_response :success | |
326 | assert_template 'annotate' |
|
326 | assert_template 'annotate' | |
327 | assert_tag :tag => 'h2', :content => /@ deff712f/ |
|
327 | assert_tag :tag => 'h2', :content => /@ deff712f/ | |
328 | end |
|
328 | end | |
329 |
|
329 | |||
330 | def test_annotate_binary_file |
|
330 | def test_annotate_binary_file | |
331 | get :annotate, :id => PRJ_ID, :path => ['images', 'edit.png'] |
|
331 | get :annotate, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
332 | assert_response 500 |
|
332 | assert_response 500 | |
333 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
333 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
334 | :content => /cannot be annotated/ |
|
334 | :content => /cannot be annotated/ | |
335 | end |
|
335 | end | |
336 |
|
336 | |||
337 | def test_annotate_latin_1 |
|
337 | def test_annotate_latin_1 | |
338 | if @ruby19_non_utf8_pass |
|
338 | if @ruby19_non_utf8_pass | |
339 | puts_ruby19_non_utf8_pass() |
|
339 | puts_ruby19_non_utf8_pass() | |
340 | elsif JRUBY_SKIP |
|
340 | elsif JRUBY_SKIP | |
341 | puts JRUBY_SKIP_STR |
|
341 | puts JRUBY_SKIP_STR | |
342 | else |
|
342 | else | |
343 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
343 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
344 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
344 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
345 | get :annotate, :id => PRJ_ID, |
|
345 | get :annotate, :id => PRJ_ID, | |
346 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
346 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 | |
347 | assert_tag :tag => 'th', |
|
347 | assert_tag :tag => 'th', | |
348 | :content => '1', |
|
348 | :content => '1', | |
349 | :attributes => { :class => 'line-num' }, |
|
349 | :attributes => { :class => 'line-num' }, | |
350 | :sibling => { :tag => 'td', |
|
350 | :sibling => { :tag => 'td', | |
351 | :content => /test-#{@char_1}.txt/ } |
|
351 | :content => /test-#{@char_1}.txt/ } | |
352 | end |
|
352 | end | |
353 | end |
|
353 | end | |
354 | end |
|
354 | end | |
355 | end |
|
355 | end | |
356 |
|
356 | |||
357 | def test_revision |
|
357 | def test_revision | |
358 | @repository.fetch_changesets |
|
358 | @repository.fetch_changesets | |
359 | @repository.reload |
|
359 | @repository.reload | |
360 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| |
|
360 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| | |
361 | get :revision, :id => PRJ_ID, :rev => r |
|
361 | get :revision, :id => PRJ_ID, :rev => r | |
362 | assert_response :success |
|
362 | assert_response :success | |
363 | assert_template 'revision' |
|
363 | assert_template 'revision' | |
364 | end |
|
364 | end | |
365 | end |
|
365 | end | |
366 |
|
366 | |||
367 | def test_empty_revision |
|
367 | def test_empty_revision | |
368 | @repository.fetch_changesets |
|
368 | @repository.fetch_changesets | |
369 | @repository.reload |
|
369 | @repository.reload | |
370 | ['', ' ', nil].each do |r| |
|
370 | ['', ' ', nil].each do |r| | |
371 | get :revision, :id => PRJ_ID, :rev => r |
|
371 | get :revision, :id => PRJ_ID, :rev => r | |
372 | assert_response 404 |
|
372 | assert_response 404 | |
373 | assert_error_tag :content => /was not found/ |
|
373 | assert_error_tag :content => /was not found/ | |
374 | end |
|
374 | end | |
375 | end |
|
375 | end | |
376 |
|
376 | |||
|
377 | def test_destroy_valid_repository | |||
|
378 | @request.session[:user_id] = 1 # admin | |||
|
379 | @repository.fetch_changesets | |||
|
380 | @repository.reload | |||
|
381 | assert @repository.changesets.count > 0 | |||
|
382 | ||||
|
383 | get :destroy, :id => PRJ_ID | |||
|
384 | assert_response 302 | |||
|
385 | @project.reload | |||
|
386 | assert_nil @project.repository | |||
|
387 | end | |||
|
388 | ||||
377 | private |
|
389 | private | |
378 |
|
390 | |||
379 | def puts_ruby19_non_utf8_pass |
|
391 | def puts_ruby19_non_utf8_pass | |
380 | puts "TODO: This test fails in Ruby 1.9 " + |
|
392 | puts "TODO: This test fails in Ruby 1.9 " + | |
381 | "and Encoding.default_external is not UTF-8. " + |
|
393 | "and Encoding.default_external is not UTF-8. " + | |
382 | "Current value is '#{Encoding.default_external.to_s}'" |
|
394 | "Current value is '#{Encoding.default_external.to_s}'" | |
383 | end |
|
395 | end | |
384 | else |
|
396 | else | |
385 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" |
|
397 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" | |
386 | def test_fake; assert true end |
|
398 | def test_fake; assert true end | |
387 | end |
|
399 | end | |
388 |
|
400 | |||
389 | private |
|
401 | private | |
390 | def with_cache(&block) |
|
402 | def with_cache(&block) | |
391 | before = ActionController::Base.perform_caching |
|
403 | before = ActionController::Base.perform_caching | |
392 | ActionController::Base.perform_caching = true |
|
404 | ActionController::Base.perform_caching = true | |
393 | block.call |
|
405 | block.call | |
394 | ActionController::Base.perform_caching = before |
|
406 | ActionController::Base.perform_caching = before | |
395 | end |
|
407 | end | |
396 | end |
|
408 | end |
General Comments 0
You need to be logged in to leave comments.
Login now