@@ -1,662 +1,662 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2014 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2014 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 |
|
19 | |||
20 | class RepositoriesGitControllerTest < ActionController::TestCase |
|
20 | class RepositoriesGitControllerTest < ActionController::TestCase | |
21 | tests RepositoriesController |
|
21 | tests RepositoriesController | |
22 |
|
22 | |||
23 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
23 | fixtures :projects, :users, :roles, :members, :member_roles, | |
24 | :repositories, :enabled_modules |
|
24 | :repositories, :enabled_modules | |
25 |
|
25 | |||
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |
27 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
27 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
28 | PRJ_ID = 3 |
|
28 | PRJ_ID = 3 | |
29 | CHAR_1_HEX = "\xc3\x9c" |
|
29 | CHAR_1_HEX = "\xc3\x9c" | |
30 | FELIX_HEX = "Felix Sch\xC3\xA4fer" |
|
30 | FELIX_HEX = "Felix Sch\xC3\xA4fer" | |
31 | NUM_REV = 28 |
|
31 | NUM_REV = 28 | |
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 | User.current = nil |
|
45 | User.current = nil | |
46 | @project = Project.find(PRJ_ID) |
|
46 | @project = Project.find(PRJ_ID) | |
47 | @repository = Repository::Git.create( |
|
47 | @repository = Repository::Git.create( | |
48 | :project => @project, |
|
48 | :project => @project, | |
49 | :url => REPOSITORY_PATH, |
|
49 | :url => REPOSITORY_PATH, | |
50 | :path_encoding => 'ISO-8859-1' |
|
50 | :path_encoding => 'ISO-8859-1' | |
51 | ) |
|
51 | ) | |
52 | assert @repository |
|
52 | assert @repository | |
53 | @char_1 = CHAR_1_HEX.dup |
|
53 | @char_1 = CHAR_1_HEX.dup | |
54 | @felix_utf8 = FELIX_HEX.dup |
|
54 | @felix_utf8 = FELIX_HEX.dup | |
55 | if @char_1.respond_to?(:force_encoding) |
|
55 | if @char_1.respond_to?(:force_encoding) | |
56 | @char_1.force_encoding('UTF-8') |
|
56 | @char_1.force_encoding('UTF-8') | |
57 | @felix_utf8.force_encoding('UTF-8') |
|
57 | @felix_utf8.force_encoding('UTF-8') | |
58 | end |
|
58 | end | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | def test_create_and_update |
|
61 | def test_create_and_update | |
62 | @request.session[:user_id] = 1 |
|
62 | @request.session[:user_id] = 1 | |
63 | assert_difference 'Repository.count' do |
|
63 | assert_difference 'Repository.count' do | |
64 | post :create, :project_id => 'subproject1', |
|
64 | post :create, :project_id => 'subproject1', | |
65 | :repository_scm => 'Git', |
|
65 | :repository_scm => 'Git', | |
66 | :repository => { |
|
66 | :repository => { | |
67 | :url => '/test', |
|
67 | :url => '/test', | |
68 | :is_default => '0', |
|
68 | :is_default => '0', | |
69 | :identifier => 'test-create', |
|
69 | :identifier => 'test-create', | |
70 | :extra_report_last_commit => '1', |
|
70 | :extra_report_last_commit => '1', | |
71 | } |
|
71 | } | |
72 | end |
|
72 | end | |
73 | assert_response 302 |
|
73 | assert_response 302 | |
74 | repository = Repository.order('id DESC').first |
|
74 | repository = Repository.order('id DESC').first | |
75 | assert_kind_of Repository::Git, repository |
|
75 | assert_kind_of Repository::Git, repository | |
76 | assert_equal '/test', repository.url |
|
76 | assert_equal '/test', repository.url | |
77 | assert_equal true, repository.extra_report_last_commit |
|
77 | assert_equal true, repository.extra_report_last_commit | |
78 |
|
78 | |||
79 | put :update, :id => repository.id, |
|
79 | put :update, :id => repository.id, | |
80 | :repository => { |
|
80 | :repository => { | |
81 | :extra_report_last_commit => '0' |
|
81 | :extra_report_last_commit => '0' | |
82 | } |
|
82 | } | |
83 | assert_response 302 |
|
83 | assert_response 302 | |
84 | repo2 = Repository.find(repository.id) |
|
84 | repo2 = Repository.find(repository.id) | |
85 | assert_equal false, repo2.extra_report_last_commit |
|
85 | assert_equal false, repo2.extra_report_last_commit | |
86 | end |
|
86 | end | |
87 |
|
87 | |||
88 | if File.directory?(REPOSITORY_PATH) |
|
88 | if File.directory?(REPOSITORY_PATH) | |
89 | ## Ruby uses ANSI api to fork a process on Windows. |
|
89 | ## Ruby uses ANSI api to fork a process on Windows. | |
90 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem |
|
90 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem | |
91 | ## and these are incompatible with ASCII. |
|
91 | ## and these are incompatible with ASCII. | |
92 | ## Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10 |
|
92 | ## Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10 | |
93 | ## http://code.google.com/p/msysgit/issues/detail?id=80 |
|
93 | ## http://code.google.com/p/msysgit/issues/detail?id=80 | |
94 | ## So, Latin-1 path tests fail on Japanese Windows |
|
94 | ## So, Latin-1 path tests fail on Japanese Windows | |
95 | WINDOWS_PASS = (Redmine::Platform.mswin? && |
|
95 | WINDOWS_PASS = (Redmine::Platform.mswin? && | |
96 | Redmine::Scm::Adapters::GitAdapter.client_version_above?([1, 7, 10])) |
|
96 | Redmine::Scm::Adapters::GitAdapter.client_version_above?([1, 7, 10])) | |
97 | WINDOWS_SKIP_STR = "TODO: This test fails in Git for Windows above 1.7.10" |
|
97 | WINDOWS_SKIP_STR = "TODO: This test fails in Git for Windows above 1.7.10" | |
98 |
|
98 | |||
99 | def test_get_new |
|
99 | def test_get_new | |
100 | @request.session[:user_id] = 1 |
|
100 | @request.session[:user_id] = 1 | |
101 | @project.repository.destroy |
|
101 | @project.repository.destroy | |
102 | get :new, :project_id => 'subproject1', :repository_scm => 'Git' |
|
102 | get :new, :project_id => 'subproject1', :repository_scm => 'Git' | |
103 | assert_response :success |
|
103 | assert_response :success | |
104 | assert_template 'new' |
|
104 | assert_template 'new' | |
105 | assert_kind_of Repository::Git, assigns(:repository) |
|
105 | assert_kind_of Repository::Git, assigns(:repository) | |
106 | assert assigns(:repository).new_record? |
|
106 | assert assigns(:repository).new_record? | |
107 | end |
|
107 | end | |
108 |
|
108 | |||
109 | def test_browse_root |
|
109 | def test_browse_root | |
110 | assert_equal 0, @repository.changesets.count |
|
110 | assert_equal 0, @repository.changesets.count | |
111 | @repository.fetch_changesets |
|
111 | @repository.fetch_changesets | |
112 | @project.reload |
|
112 | @project.reload | |
113 | assert_equal NUM_REV, @repository.changesets.count |
|
113 | assert_equal NUM_REV, @repository.changesets.count | |
114 |
|
114 | |||
115 | get :show, :id => PRJ_ID |
|
115 | get :show, :id => PRJ_ID | |
116 | assert_response :success |
|
116 | assert_response :success | |
117 | assert_template 'show' |
|
117 | assert_template 'show' | |
118 | assert_not_nil assigns(:entries) |
|
118 | assert_not_nil assigns(:entries) | |
119 | assert_equal 9, assigns(:entries).size |
|
119 | assert_equal 9, assigns(:entries).size | |
120 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
120 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
121 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} |
|
121 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} | |
122 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
122 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
123 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
123 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
124 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} |
|
124 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} | |
125 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} |
|
125 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} | |
126 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} |
|
126 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} | |
127 | assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} |
|
127 | assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} | |
128 | assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} |
|
128 | assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} | |
129 | assert_not_nil assigns(:changesets) |
|
129 | assert_not_nil assigns(:changesets) | |
130 | assert assigns(:changesets).size > 0 |
|
130 | assert assigns(:changesets).size > 0 | |
131 | end |
|
131 | end | |
132 |
|
132 | |||
133 | def test_browse_branch |
|
133 | def test_browse_branch | |
134 | assert_equal 0, @repository.changesets.count |
|
134 | assert_equal 0, @repository.changesets.count | |
135 | @repository.fetch_changesets |
|
135 | @repository.fetch_changesets | |
136 | @project.reload |
|
136 | @project.reload | |
137 | assert_equal NUM_REV, @repository.changesets.count |
|
137 | assert_equal NUM_REV, @repository.changesets.count | |
138 | get :show, :id => PRJ_ID, :rev => 'test_branch' |
|
138 | get :show, :id => PRJ_ID, :rev => 'test_branch' | |
139 | assert_response :success |
|
139 | assert_response :success | |
140 | assert_template 'show' |
|
140 | assert_template 'show' | |
141 | assert_not_nil assigns(:entries) |
|
141 | assert_not_nil assigns(:entries) | |
142 | assert_equal 4, assigns(:entries).size |
|
142 | assert_equal 4, assigns(:entries).size | |
143 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
143 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
144 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
144 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
145 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
145 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
146 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} |
|
146 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} | |
147 | assert_not_nil assigns(:changesets) |
|
147 | assert_not_nil assigns(:changesets) | |
148 | assert assigns(:changesets).size > 0 |
|
148 | assert assigns(:changesets).size > 0 | |
149 | end |
|
149 | end | |
150 |
|
150 | |||
151 | def test_browse_tag |
|
151 | def test_browse_tag | |
152 | assert_equal 0, @repository.changesets.count |
|
152 | assert_equal 0, @repository.changesets.count | |
153 | @repository.fetch_changesets |
|
153 | @repository.fetch_changesets | |
154 | @project.reload |
|
154 | @project.reload | |
155 | assert_equal NUM_REV, @repository.changesets.count |
|
155 | assert_equal NUM_REV, @repository.changesets.count | |
156 | [ |
|
156 | [ | |
157 | "tag00.lightweight", |
|
157 | "tag00.lightweight", | |
158 | "tag01.annotated", |
|
158 | "tag01.annotated", | |
159 | ].each do |t1| |
|
159 | ].each do |t1| | |
160 | get :show, :id => PRJ_ID, :rev => t1 |
|
160 | get :show, :id => PRJ_ID, :rev => t1 | |
161 | assert_response :success |
|
161 | assert_response :success | |
162 | assert_template 'show' |
|
162 | assert_template 'show' | |
163 | assert_not_nil assigns(:entries) |
|
163 | assert_not_nil assigns(:entries) | |
164 | assert assigns(:entries).size > 0 |
|
164 | assert assigns(:entries).size > 0 | |
165 | assert_not_nil assigns(:changesets) |
|
165 | assert_not_nil assigns(:changesets) | |
166 | assert assigns(:changesets).size > 0 |
|
166 | assert assigns(:changesets).size > 0 | |
167 | end |
|
167 | end | |
168 | end |
|
168 | end | |
169 |
|
169 | |||
170 | def test_browse_directory |
|
170 | def test_browse_directory | |
171 | assert_equal 0, @repository.changesets.count |
|
171 | assert_equal 0, @repository.changesets.count | |
172 | @repository.fetch_changesets |
|
172 | @repository.fetch_changesets | |
173 | @project.reload |
|
173 | @project.reload | |
174 | assert_equal NUM_REV, @repository.changesets.count |
|
174 | assert_equal NUM_REV, @repository.changesets.count | |
175 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] |
|
175 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] | |
176 | assert_response :success |
|
176 | assert_response :success | |
177 | assert_template 'show' |
|
177 | assert_template 'show' | |
178 | assert_not_nil assigns(:entries) |
|
178 | assert_not_nil assigns(:entries) | |
179 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) |
|
179 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) | |
180 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
180 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
181 | assert_not_nil entry |
|
181 | assert_not_nil entry | |
182 | assert_equal 'file', entry.kind |
|
182 | assert_equal 'file', entry.kind | |
183 | assert_equal 'images/edit.png', entry.path |
|
183 | assert_equal 'images/edit.png', entry.path | |
184 | assert_not_nil assigns(:changesets) |
|
184 | assert_not_nil assigns(:changesets) | |
185 | assert assigns(:changesets).size > 0 |
|
185 | assert assigns(:changesets).size > 0 | |
186 | end |
|
186 | end | |
187 |
|
187 | |||
188 | def test_browse_at_given_revision |
|
188 | def test_browse_at_given_revision | |
189 | assert_equal 0, @repository.changesets.count |
|
189 | assert_equal 0, @repository.changesets.count | |
190 | @repository.fetch_changesets |
|
190 | @repository.fetch_changesets | |
191 | @project.reload |
|
191 | @project.reload | |
192 | assert_equal NUM_REV, @repository.changesets.count |
|
192 | assert_equal NUM_REV, @repository.changesets.count | |
193 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], |
|
193 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], | |
194 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' |
|
194 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' | |
195 | assert_response :success |
|
195 | assert_response :success | |
196 | assert_template 'show' |
|
196 | assert_template 'show' | |
197 | assert_not_nil assigns(:entries) |
|
197 | assert_not_nil assigns(:entries) | |
198 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
198 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
199 | assert_not_nil assigns(:changesets) |
|
199 | assert_not_nil assigns(:changesets) | |
200 | assert assigns(:changesets).size > 0 |
|
200 | assert assigns(:changesets).size > 0 | |
201 | end |
|
201 | end | |
202 |
|
202 | |||
203 | def test_changes |
|
203 | def test_changes | |
204 | get :changes, :id => PRJ_ID, |
|
204 | get :changes, :id => PRJ_ID, | |
205 | :path => repository_path_hash(['images', 'edit.png'])[:param] |
|
205 | :path => repository_path_hash(['images', 'edit.png'])[:param] | |
206 | assert_response :success |
|
206 | assert_response :success | |
207 | assert_template 'changes' |
|
207 | assert_template 'changes' | |
208 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
208 | assert_tag :tag => 'h2', :content => 'edit.png' | |
209 | end |
|
209 | end | |
210 |
|
210 | |||
211 | def test_entry_show |
|
211 | def test_entry_show | |
212 | get :entry, :id => PRJ_ID, |
|
212 | get :entry, :id => PRJ_ID, | |
213 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
213 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
214 | assert_response :success |
|
214 | assert_response :success | |
215 | assert_template 'entry' |
|
215 | assert_template 'entry' | |
216 | # Line 19 |
|
216 | # Line 19 | |
217 | assert_tag :tag => 'th', |
|
217 | assert_tag :tag => 'th', | |
218 | :content => '11', |
|
218 | :content => '11', | |
219 | :attributes => { :class => 'line-num' }, |
|
219 | :attributes => { :class => 'line-num' }, | |
220 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
220 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } | |
221 | end |
|
221 | end | |
222 |
|
222 | |||
223 | def test_entry_show_latin_1 |
|
223 | def test_entry_show_latin_1 | |
224 | if @ruby19_non_utf8_pass |
|
224 | if @ruby19_non_utf8_pass | |
225 | puts_ruby19_non_utf8_pass() |
|
225 | puts_ruby19_non_utf8_pass() | |
226 | elsif WINDOWS_PASS |
|
226 | elsif WINDOWS_PASS | |
227 | puts WINDOWS_SKIP_STR |
|
227 | puts WINDOWS_SKIP_STR | |
228 | elsif JRUBY_SKIP |
|
228 | elsif JRUBY_SKIP | |
229 | puts JRUBY_SKIP_STR |
|
229 | puts JRUBY_SKIP_STR | |
230 | else |
|
230 | else | |
231 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
231 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
232 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
232 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
233 | get :entry, :id => PRJ_ID, |
|
233 | get :entry, :id => PRJ_ID, | |
234 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], |
|
234 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |
235 | :rev => r1 |
|
235 | :rev => r1 | |
236 | assert_response :success |
|
236 | assert_response :success | |
237 | assert_template 'entry' |
|
237 | assert_template 'entry' | |
238 | assert_tag :tag => 'th', |
|
238 | assert_tag :tag => 'th', | |
239 | :content => '1', |
|
239 | :content => '1', | |
240 | :attributes => { :class => 'line-num' }, |
|
240 | :attributes => { :class => 'line-num' }, | |
241 | :sibling => { :tag => 'td', |
|
241 | :sibling => { :tag => 'td', | |
242 | :content => /test-#{@char_1}.txt/ } |
|
242 | :content => /test-#{@char_1}.txt/ } | |
243 | end |
|
243 | end | |
244 | end |
|
244 | end | |
245 | end |
|
245 | end | |
246 | end |
|
246 | end | |
247 |
|
247 | |||
248 | def test_entry_download |
|
248 | def test_entry_download | |
249 | get :entry, :id => PRJ_ID, |
|
249 | get :entry, :id => PRJ_ID, | |
250 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], |
|
250 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
251 | :format => 'raw' |
|
251 | :format => 'raw' | |
252 | assert_response :success |
|
252 | assert_response :success | |
253 | # File content |
|
253 | # File content | |
254 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
254 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |
255 | end |
|
255 | end | |
256 |
|
256 | |||
257 | def test_directory_entry |
|
257 | def test_directory_entry | |
258 | get :entry, :id => PRJ_ID, |
|
258 | get :entry, :id => PRJ_ID, | |
259 | :path => repository_path_hash(['sources'])[:param] |
|
259 | :path => repository_path_hash(['sources'])[:param] | |
260 | assert_response :success |
|
260 | assert_response :success | |
261 | assert_template 'show' |
|
261 | assert_template 'show' | |
262 | assert_not_nil assigns(:entry) |
|
262 | assert_not_nil assigns(:entry) | |
263 | assert_equal 'sources', assigns(:entry).name |
|
263 | assert_equal 'sources', assigns(:entry).name | |
264 | end |
|
264 | end | |
265 |
|
265 | |||
266 | def test_diff |
|
266 | def test_diff | |
267 | assert_equal true, @repository.is_default |
|
267 | assert_equal true, @repository.is_default | |
268 | assert_nil @repository.identifier |
|
268 | assert_nil @repository.identifier | |
269 | assert_equal 0, @repository.changesets.count |
|
269 | assert_equal 0, @repository.changesets.count | |
270 | @repository.fetch_changesets |
|
270 | @repository.fetch_changesets | |
271 | @project.reload |
|
271 | @project.reload | |
272 | assert_equal NUM_REV, @repository.changesets.count |
|
272 | assert_equal NUM_REV, @repository.changesets.count | |
273 | # Full diff of changeset 2f9c0091 |
|
273 | # Full diff of changeset 2f9c0091 | |
274 | ['inline', 'sbs'].each do |dt| |
|
274 | ['inline', 'sbs'].each do |dt| | |
275 | get :diff, |
|
275 | get :diff, | |
276 | :id => PRJ_ID, |
|
276 | :id => PRJ_ID, | |
277 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
277 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
278 | :type => dt |
|
278 | :type => dt | |
279 | assert_response :success |
|
279 | assert_response :success | |
280 | assert_template 'diff' |
|
280 | assert_template 'diff' | |
281 | # Line 22 removed |
|
281 | # Line 22 removed | |
282 | assert_tag :tag => 'th', |
|
282 | assert_tag :tag => 'th', | |
283 | :content => /22/, |
|
283 | :content => /22/, | |
284 | :sibling => { :tag => 'td', |
|
284 | :sibling => { :tag => 'td', | |
285 | :attributes => { :class => /diff_out/ }, |
|
285 | :attributes => { :class => /diff_out/ }, | |
286 | :content => /def remove/ } |
|
286 | :content => /def remove/ } | |
287 | assert_tag :tag => 'h2', :content => /2f9c0091/ |
|
287 | assert_tag :tag => 'h2', :content => /2f9c0091/ | |
288 | end |
|
288 | end | |
289 | end |
|
289 | end | |
290 |
|
290 | |||
291 | def test_diff_with_rev_and_path |
|
291 | def test_diff_with_rev_and_path | |
292 | assert_equal 0, @repository.changesets.count |
|
292 | assert_equal 0, @repository.changesets.count | |
293 | @repository.fetch_changesets |
|
293 | @repository.fetch_changesets | |
294 | @project.reload |
|
294 | @project.reload | |
295 | assert_equal NUM_REV, @repository.changesets.count |
|
295 | assert_equal NUM_REV, @repository.changesets.count | |
296 | with_settings :diff_max_lines_displayed => 1000 do |
|
296 | with_settings :diff_max_lines_displayed => 1000 do | |
297 | # Full diff of changeset 2f9c0091 |
|
297 | # Full diff of changeset 2f9c0091 | |
298 | ['inline', 'sbs'].each do |dt| |
|
298 | ['inline', 'sbs'].each do |dt| | |
299 | get :diff, |
|
299 | get :diff, | |
300 | :id => PRJ_ID, |
|
300 | :id => PRJ_ID, | |
301 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
301 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
302 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], |
|
302 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
303 | :type => dt |
|
303 | :type => dt | |
304 | assert_response :success |
|
304 | assert_response :success | |
305 | assert_template 'diff' |
|
305 | assert_template 'diff' | |
306 | # Line 22 removed |
|
306 | # Line 22 removed | |
307 | assert_tag :tag => 'th', |
|
307 | assert_tag :tag => 'th', | |
308 | :content => '22', |
|
308 | :content => '22', | |
309 | :sibling => { :tag => 'td', |
|
309 | :sibling => { :tag => 'td', | |
310 | :attributes => { :class => /diff_out/ }, |
|
310 | :attributes => { :class => /diff_out/ }, | |
311 | :content => /def remove/ } |
|
311 | :content => /def remove/ } | |
312 | assert_tag :tag => 'h2', :content => /2f9c0091/ |
|
312 | assert_tag :tag => 'h2', :content => /2f9c0091/ | |
313 | end |
|
313 | end | |
314 | end |
|
314 | end | |
315 | end |
|
315 | end | |
316 |
|
316 | |||
317 | def test_diff_truncated |
|
317 | def test_diff_truncated | |
318 | assert_equal 0, @repository.changesets.count |
|
318 | assert_equal 0, @repository.changesets.count | |
319 | @repository.fetch_changesets |
|
319 | @repository.fetch_changesets | |
320 | @project.reload |
|
320 | @project.reload | |
321 | assert_equal NUM_REV, @repository.changesets.count |
|
321 | assert_equal NUM_REV, @repository.changesets.count | |
322 |
|
322 | |||
323 | with_settings :diff_max_lines_displayed => 5 do |
|
323 | with_settings :diff_max_lines_displayed => 5 do | |
324 | # Truncated diff of changeset 2f9c0091 |
|
324 | # Truncated diff of changeset 2f9c0091 | |
325 | with_cache do |
|
325 | with_cache do | |
326 | with_settings :default_language => 'en' do |
|
326 | with_settings :default_language => 'en' do | |
327 | get :diff, :id => PRJ_ID, :type => 'inline', |
|
327 | get :diff, :id => PRJ_ID, :type => 'inline', | |
328 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
328 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
329 | assert_response :success |
|
329 | assert_response :success | |
330 | assert @response.body.include?("... This diff was truncated") |
|
330 | assert @response.body.include?("... This diff was truncated") | |
331 | end |
|
331 | end | |
332 | with_settings :default_language => 'fr' do |
|
332 | with_settings :default_language => 'fr' do | |
333 | get :diff, :id => PRJ_ID, :type => 'inline', |
|
333 | get :diff, :id => PRJ_ID, :type => 'inline', | |
334 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
334 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
335 | assert_response :success |
|
335 | assert_response :success | |
336 | assert ! @response.body.include?("... This diff was truncated") |
|
336 | assert ! @response.body.include?("... This diff was truncated") | |
337 | assert @response.body.include?("... Ce diff") |
|
337 | assert @response.body.include?("... Ce diff") | |
338 | end |
|
338 | end | |
339 | end |
|
339 | end | |
340 | end |
|
340 | end | |
341 | end |
|
341 | end | |
342 |
|
342 | |||
343 | def test_diff_two_revs |
|
343 | def test_diff_two_revs | |
344 | assert_equal 0, @repository.changesets.count |
|
344 | assert_equal 0, @repository.changesets.count | |
345 | @repository.fetch_changesets |
|
345 | @repository.fetch_changesets | |
346 | @project.reload |
|
346 | @project.reload | |
347 | assert_equal NUM_REV, @repository.changesets.count |
|
347 | assert_equal NUM_REV, @repository.changesets.count | |
348 | ['inline', 'sbs'].each do |dt| |
|
348 | ['inline', 'sbs'].each do |dt| | |
349 | get :diff, |
|
349 | get :diff, | |
350 | :id => PRJ_ID, |
|
350 | :id => PRJ_ID, | |
351 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
351 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
352 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
352 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
353 | :type => dt |
|
353 | :type => dt | |
354 | assert_response :success |
|
354 | assert_response :success | |
355 | assert_template 'diff' |
|
355 | assert_template 'diff' | |
356 | diff = assigns(:diff) |
|
356 | diff = assigns(:diff) | |
357 | assert_not_nil diff |
|
357 | assert_not_nil diff | |
358 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ |
|
358 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ | |
359 | assert_tag :tag => "form", |
|
359 | assert_tag :tag => "form", | |
360 | :attributes => { |
|
360 | :attributes => { | |
361 | :action => "/projects/subproject1/repository/revisions/" + |
|
361 | :action => "/projects/subproject1/repository/revisions/" + | |
362 | "61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff" |
|
362 | "61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff" | |
363 | } |
|
363 | } | |
364 | assert_tag :tag => 'input', |
|
364 | assert_tag :tag => 'input', | |
365 | :attributes => { |
|
365 | :attributes => { | |
366 | :id => "rev_to", |
|
366 | :id => "rev_to", | |
367 | :name => "rev_to", |
|
367 | :name => "rev_to", | |
368 | :type => "hidden", |
|
368 | :type => "hidden", | |
369 | :value => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
369 | :value => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
370 | } |
|
370 | } | |
371 | end |
|
371 | end | |
372 | end |
|
372 | end | |
373 |
|
373 | |||
374 | def test_diff_path_in_subrepo |
|
374 | def test_diff_path_in_subrepo | |
375 | repo = Repository::Git.create( |
|
375 | repo = Repository::Git.create( | |
376 | :project => @project, |
|
376 | :project => @project, | |
377 | :url => REPOSITORY_PATH, |
|
377 | :url => REPOSITORY_PATH, | |
378 | :identifier => 'test-diff-path', |
|
378 | :identifier => 'test-diff-path', | |
379 | :path_encoding => 'ISO-8859-1' |
|
379 | :path_encoding => 'ISO-8859-1' | |
380 |
) |
|
380 | ) | |
381 | assert repo |
|
381 | assert repo | |
382 | assert_equal false, repo.is_default |
|
382 | assert_equal false, repo.is_default | |
383 | assert_equal 'test-diff-path', repo.identifier |
|
383 | assert_equal 'test-diff-path', repo.identifier | |
384 | get :diff, |
|
384 | get :diff, | |
385 | :id => PRJ_ID, |
|
385 | :id => PRJ_ID, | |
386 | :repository_id => 'test-diff-path', |
|
386 | :repository_id => 'test-diff-path', | |
387 | :rev => '61b685fbe55ab05b', |
|
387 | :rev => '61b685fbe55ab05b', | |
388 | :rev_to => '2f9c0091c754a91a', |
|
388 | :rev_to => '2f9c0091c754a91a', | |
389 | :type => 'inline' |
|
389 | :type => 'inline' | |
390 | assert_response :success |
|
390 | assert_response :success | |
391 | assert_template 'diff' |
|
391 | assert_template 'diff' | |
392 | diff = assigns(:diff) |
|
392 | diff = assigns(:diff) | |
393 | assert_not_nil diff |
|
393 | assert_not_nil diff | |
394 | assert_tag :tag => "form", |
|
394 | assert_tag :tag => "form", | |
395 | :attributes => { |
|
395 | :attributes => { | |
396 | :action => "/projects/subproject1/repository/test-diff-path/" + |
|
396 | :action => "/projects/subproject1/repository/test-diff-path/" + | |
397 | "revisions/61b685fbe55ab05b/diff" |
|
397 | "revisions/61b685fbe55ab05b/diff" | |
398 | } |
|
398 | } | |
399 | assert_tag :tag => 'input', |
|
399 | assert_tag :tag => 'input', | |
400 | :attributes => { |
|
400 | :attributes => { | |
401 | :id => "rev_to", |
|
401 | :id => "rev_to", | |
402 | :name => "rev_to", |
|
402 | :name => "rev_to", | |
403 | :type => "hidden", |
|
403 | :type => "hidden", | |
404 | :value => '2f9c0091c754a91a' |
|
404 | :value => '2f9c0091c754a91a' | |
405 | } |
|
405 | } | |
406 | end |
|
406 | end | |
407 |
|
407 | |||
408 | def test_diff_latin_1 |
|
408 | def test_diff_latin_1 | |
409 | if @ruby19_non_utf8_pass |
|
409 | if @ruby19_non_utf8_pass | |
410 | puts_ruby19_non_utf8_pass() |
|
410 | puts_ruby19_non_utf8_pass() | |
411 | else |
|
411 | else | |
412 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
412 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
413 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
413 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
414 | ['inline', 'sbs'].each do |dt| |
|
414 | ['inline', 'sbs'].each do |dt| | |
415 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
415 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
416 | assert_response :success |
|
416 | assert_response :success | |
417 | assert_template 'diff' |
|
417 | assert_template 'diff' | |
418 | assert_tag :tag => 'thead', |
|
418 | assert_tag :tag => 'thead', | |
419 | :descendant => { |
|
419 | :descendant => { | |
420 | :tag => 'th', |
|
420 | :tag => 'th', | |
421 | :attributes => { :class => 'filename' } , |
|
421 | :attributes => { :class => 'filename' } , | |
422 | :content => /latin-1-dir\/test-#{@char_1}.txt/ , |
|
422 | :content => /latin-1-dir\/test-#{@char_1}.txt/ , | |
423 | }, |
|
423 | }, | |
424 | :sibling => { |
|
424 | :sibling => { | |
425 | :tag => 'tbody', |
|
425 | :tag => 'tbody', | |
426 | :descendant => { |
|
426 | :descendant => { | |
427 | :tag => 'td', |
|
427 | :tag => 'td', | |
428 | :attributes => { :class => /diff_in/ }, |
|
428 | :attributes => { :class => /diff_in/ }, | |
429 | :content => /test-#{@char_1}.txt/ |
|
429 | :content => /test-#{@char_1}.txt/ | |
430 | } |
|
430 | } | |
431 | } |
|
431 | } | |
432 | end |
|
432 | end | |
433 | end |
|
433 | end | |
434 | end |
|
434 | end | |
435 | end |
|
435 | end | |
436 | end |
|
436 | end | |
437 |
|
437 | |||
438 | def test_diff_should_show_filenames |
|
438 | def test_diff_should_show_filenames | |
439 | get :diff, :id => PRJ_ID, :rev => 'deff712f05a90d96edbd70facc47d944be5897e3', :type => 'inline' |
|
439 | get :diff, :id => PRJ_ID, :rev => 'deff712f05a90d96edbd70facc47d944be5897e3', :type => 'inline' | |
440 | assert_response :success |
|
440 | assert_response :success | |
441 | assert_template 'diff' |
|
441 | assert_template 'diff' | |
442 | # modified file |
|
442 | # modified file | |
443 | assert_select 'th.filename', :text => 'sources/watchers_controller.rb' |
|
443 | assert_select 'th.filename', :text => 'sources/watchers_controller.rb' | |
444 | # deleted file |
|
444 | # deleted file | |
445 | assert_select 'th.filename', :text => 'test.txt' |
|
445 | assert_select 'th.filename', :text => 'test.txt' | |
446 | end |
|
446 | end | |
447 |
|
447 | |||
448 | def test_save_diff_type |
|
448 | def test_save_diff_type | |
449 | user1 = User.find(1) |
|
449 | user1 = User.find(1) | |
450 | user1.pref[:diff_type] = nil |
|
450 | user1.pref[:diff_type] = nil | |
451 | user1.preference.save |
|
451 | user1.preference.save | |
452 | user = User.find(1) |
|
452 | user = User.find(1) | |
453 | assert_nil user.pref[:diff_type] |
|
453 | assert_nil user.pref[:diff_type] | |
454 |
|
454 | |||
455 | @request.session[:user_id] = 1 # admin |
|
455 | @request.session[:user_id] = 1 # admin | |
456 | get :diff, |
|
456 | get :diff, | |
457 | :id => PRJ_ID, |
|
457 | :id => PRJ_ID, | |
458 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
458 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
459 | assert_response :success |
|
459 | assert_response :success | |
460 | assert_template 'diff' |
|
460 | assert_template 'diff' | |
461 | user.reload |
|
461 | user.reload | |
462 | assert_equal "inline", user.pref[:diff_type] |
|
462 | assert_equal "inline", user.pref[:diff_type] | |
463 | get :diff, |
|
463 | get :diff, | |
464 | :id => PRJ_ID, |
|
464 | :id => PRJ_ID, | |
465 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
465 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
466 | :type => 'sbs' |
|
466 | :type => 'sbs' | |
467 | assert_response :success |
|
467 | assert_response :success | |
468 | assert_template 'diff' |
|
468 | assert_template 'diff' | |
469 | user.reload |
|
469 | user.reload | |
470 | assert_equal "sbs", user.pref[:diff_type] |
|
470 | assert_equal "sbs", user.pref[:diff_type] | |
471 | end |
|
471 | end | |
472 |
|
472 | |||
473 | def test_annotate |
|
473 | def test_annotate | |
474 | get :annotate, :id => PRJ_ID, |
|
474 | get :annotate, :id => PRJ_ID, | |
475 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
475 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
476 | assert_response :success |
|
476 | assert_response :success | |
477 | assert_template 'annotate' |
|
477 | assert_template 'annotate' | |
478 |
|
478 | |||
479 | # Line 23, changeset 2f9c0091 |
|
479 | # Line 23, changeset 2f9c0091 | |
480 | assert_select 'tr' do |
|
480 | assert_select 'tr' do | |
481 | assert_select 'th.line-num', :text => '23' |
|
481 | assert_select 'th.line-num', :text => '23' | |
482 | assert_select 'td.revision', :text => /2f9c0091/ |
|
482 | assert_select 'td.revision', :text => /2f9c0091/ | |
483 | assert_select 'td.author', :text => 'jsmith' |
|
483 | assert_select 'td.author', :text => 'jsmith' | |
484 | assert_select 'td', :text => /remove_watcher/ |
|
484 | assert_select 'td', :text => /remove_watcher/ | |
485 | end |
|
485 | end | |
486 | end |
|
486 | end | |
487 |
|
487 | |||
488 | def test_annotate_at_given_revision |
|
488 | def test_annotate_at_given_revision | |
489 | assert_equal 0, @repository.changesets.count |
|
489 | assert_equal 0, @repository.changesets.count | |
490 | @repository.fetch_changesets |
|
490 | @repository.fetch_changesets | |
491 | @project.reload |
|
491 | @project.reload | |
492 | assert_equal NUM_REV, @repository.changesets.count |
|
492 | assert_equal NUM_REV, @repository.changesets.count | |
493 | get :annotate, :id => PRJ_ID, :rev => 'deff7', |
|
493 | get :annotate, :id => PRJ_ID, :rev => 'deff7', | |
494 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
494 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
495 | assert_response :success |
|
495 | assert_response :success | |
496 | assert_template 'annotate' |
|
496 | assert_template 'annotate' | |
497 | assert_tag :tag => 'h2', :content => /@ deff712f/ |
|
497 | assert_tag :tag => 'h2', :content => /@ deff712f/ | |
498 | end |
|
498 | end | |
499 |
|
499 | |||
500 | def test_annotate_binary_file |
|
500 | def test_annotate_binary_file | |
501 | get :annotate, :id => PRJ_ID, |
|
501 | get :annotate, :id => PRJ_ID, | |
502 | :path => repository_path_hash(['images', 'edit.png'])[:param] |
|
502 | :path => repository_path_hash(['images', 'edit.png'])[:param] | |
503 | assert_response 500 |
|
503 | assert_response 500 | |
504 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
504 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
505 | :content => /cannot be annotated/ |
|
505 | :content => /cannot be annotated/ | |
506 | end |
|
506 | end | |
507 |
|
507 | |||
508 | def test_annotate_error_when_too_big |
|
508 | def test_annotate_error_when_too_big | |
509 | with_settings :file_max_size_displayed => 1 do |
|
509 | with_settings :file_max_size_displayed => 1 do | |
510 | get :annotate, :id => PRJ_ID, |
|
510 | get :annotate, :id => PRJ_ID, | |
511 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], |
|
511 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
512 | :rev => 'deff712f' |
|
512 | :rev => 'deff712f' | |
513 | assert_response 500 |
|
513 | assert_response 500 | |
514 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
514 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
515 | :content => /exceeds the maximum text file size/ |
|
515 | :content => /exceeds the maximum text file size/ | |
516 |
|
516 | |||
517 | get :annotate, :id => PRJ_ID, |
|
517 | get :annotate, :id => PRJ_ID, | |
518 | :path => repository_path_hash(['README'])[:param], |
|
518 | :path => repository_path_hash(['README'])[:param], | |
519 | :rev => '7234cb2' |
|
519 | :rev => '7234cb2' | |
520 | assert_response :success |
|
520 | assert_response :success | |
521 | assert_template 'annotate' |
|
521 | assert_template 'annotate' | |
522 | end |
|
522 | end | |
523 | end |
|
523 | end | |
524 |
|
524 | |||
525 | def test_annotate_latin_1 |
|
525 | def test_annotate_latin_1 | |
526 | if @ruby19_non_utf8_pass |
|
526 | if @ruby19_non_utf8_pass | |
527 | puts_ruby19_non_utf8_pass() |
|
527 | puts_ruby19_non_utf8_pass() | |
528 | elsif WINDOWS_PASS |
|
528 | elsif WINDOWS_PASS | |
529 | puts WINDOWS_SKIP_STR |
|
529 | puts WINDOWS_SKIP_STR | |
530 | elsif JRUBY_SKIP |
|
530 | elsif JRUBY_SKIP | |
531 | puts JRUBY_SKIP_STR |
|
531 | puts JRUBY_SKIP_STR | |
532 | else |
|
532 | else | |
533 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
533 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
534 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
534 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
535 | get :annotate, :id => PRJ_ID, |
|
535 | get :annotate, :id => PRJ_ID, | |
536 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], |
|
536 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |
537 | :rev => r1 |
|
537 | :rev => r1 | |
538 | assert_select "th.line-num", :text => '1' do |
|
538 | assert_select "th.line-num", :text => '1' do | |
539 | assert_select "+ td.revision" do |
|
539 | assert_select "+ td.revision" do | |
540 | assert_select "a", :text => '57ca437c' |
|
540 | assert_select "a", :text => '57ca437c' | |
541 | assert_select "+ td.author", :text => "jsmith" do |
|
541 | assert_select "+ td.author", :text => "jsmith" do | |
542 | assert_select "+ td", |
|
542 | assert_select "+ td", | |
543 | :text => "test-#{@char_1}.txt" |
|
543 | :text => "test-#{@char_1}.txt" | |
544 | end |
|
544 | end | |
545 | end |
|
545 | end | |
546 | end |
|
546 | end | |
547 | end |
|
547 | end | |
548 | end |
|
548 | end | |
549 | end |
|
549 | end | |
550 | end |
|
550 | end | |
551 |
|
551 | |||
552 | def test_annotate_latin_1_author |
|
552 | def test_annotate_latin_1_author | |
553 | ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', '83ca5fd546063a'].each do |r1| |
|
553 | ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', '83ca5fd546063a'].each do |r1| | |
554 | get :annotate, :id => PRJ_ID, |
|
554 | get :annotate, :id => PRJ_ID, | |
555 | :path => repository_path_hash([" filename with a leading space.txt "])[:param], |
|
555 | :path => repository_path_hash([" filename with a leading space.txt "])[:param], | |
556 | :rev => r1 |
|
556 | :rev => r1 | |
557 | assert_select "th.line-num", :text => '1' do |
|
557 | assert_select "th.line-num", :text => '1' do | |
558 | assert_select "+ td.revision" do |
|
558 | assert_select "+ td.revision" do | |
559 | assert_select "a", :text => '83ca5fd5' |
|
559 | assert_select "a", :text => '83ca5fd5' | |
560 | assert_select "+ td.author", :text => @felix_utf8 do |
|
560 | assert_select "+ td.author", :text => @felix_utf8 do | |
561 | assert_select "+ td", |
|
561 | assert_select "+ td", | |
562 | :text => "And this is a file with a leading and trailing space..." |
|
562 | :text => "And this is a file with a leading and trailing space..." | |
563 | end |
|
563 | end | |
564 | end |
|
564 | end | |
565 | end |
|
565 | end | |
566 | end |
|
566 | end | |
567 | end |
|
567 | end | |
568 |
|
568 | |||
569 | def test_revisions |
|
569 | def test_revisions | |
570 | assert_equal 0, @repository.changesets.count |
|
570 | assert_equal 0, @repository.changesets.count | |
571 | @repository.fetch_changesets |
|
571 | @repository.fetch_changesets | |
572 | @project.reload |
|
572 | @project.reload | |
573 | assert_equal NUM_REV, @repository.changesets.count |
|
573 | assert_equal NUM_REV, @repository.changesets.count | |
574 | get :revisions, :id => PRJ_ID |
|
574 | get :revisions, :id => PRJ_ID | |
575 | assert_response :success |
|
575 | assert_response :success | |
576 | assert_template 'revisions' |
|
576 | assert_template 'revisions' | |
577 | assert_tag :tag => 'form', |
|
577 | assert_tag :tag => 'form', | |
578 | :attributes => { |
|
578 | :attributes => { | |
579 | :method => 'get', |
|
579 | :method => 'get', | |
580 | :action => '/projects/subproject1/repository/revision' |
|
580 | :action => '/projects/subproject1/repository/revision' | |
581 | } |
|
581 | } | |
582 | end |
|
582 | end | |
583 |
|
583 | |||
584 | def test_revision |
|
584 | def test_revision | |
585 | assert_equal 0, @repository.changesets.count |
|
585 | assert_equal 0, @repository.changesets.count | |
586 | @repository.fetch_changesets |
|
586 | @repository.fetch_changesets | |
587 | @project.reload |
|
587 | @project.reload | |
588 | assert_equal NUM_REV, @repository.changesets.count |
|
588 | assert_equal NUM_REV, @repository.changesets.count | |
589 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| |
|
589 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| | |
590 | get :revision, :id => PRJ_ID, :rev => r |
|
590 | get :revision, :id => PRJ_ID, :rev => r | |
591 | assert_response :success |
|
591 | assert_response :success | |
592 | assert_template 'revision' |
|
592 | assert_template 'revision' | |
593 | end |
|
593 | end | |
594 | end |
|
594 | end | |
595 |
|
595 | |||
596 | def test_empty_revision |
|
596 | def test_empty_revision | |
597 | assert_equal 0, @repository.changesets.count |
|
597 | assert_equal 0, @repository.changesets.count | |
598 | @repository.fetch_changesets |
|
598 | @repository.fetch_changesets | |
599 | @project.reload |
|
599 | @project.reload | |
600 | assert_equal NUM_REV, @repository.changesets.count |
|
600 | assert_equal NUM_REV, @repository.changesets.count | |
601 | ['', ' ', nil].each do |r| |
|
601 | ['', ' ', nil].each do |r| | |
602 | get :revision, :id => PRJ_ID, :rev => r |
|
602 | get :revision, :id => PRJ_ID, :rev => r | |
603 | assert_response 404 |
|
603 | assert_response 404 | |
604 | assert_error_tag :content => /was not found/ |
|
604 | assert_error_tag :content => /was not found/ | |
605 | end |
|
605 | end | |
606 | end |
|
606 | end | |
607 |
|
607 | |||
608 | def test_destroy_valid_repository |
|
608 | def test_destroy_valid_repository | |
609 | @request.session[:user_id] = 1 # admin |
|
609 | @request.session[:user_id] = 1 # admin | |
610 | assert_equal 0, @repository.changesets.count |
|
610 | assert_equal 0, @repository.changesets.count | |
611 | @repository.fetch_changesets |
|
611 | @repository.fetch_changesets | |
612 | @project.reload |
|
612 | @project.reload | |
613 | assert_equal NUM_REV, @repository.changesets.count |
|
613 | assert_equal NUM_REV, @repository.changesets.count | |
614 |
|
614 | |||
615 | assert_difference 'Repository.count', -1 do |
|
615 | assert_difference 'Repository.count', -1 do | |
616 | delete :destroy, :id => @repository.id |
|
616 | delete :destroy, :id => @repository.id | |
617 | end |
|
617 | end | |
618 | assert_response 302 |
|
618 | assert_response 302 | |
619 | @project.reload |
|
619 | @project.reload | |
620 | assert_nil @project.repository |
|
620 | assert_nil @project.repository | |
621 | end |
|
621 | end | |
622 |
|
622 | |||
623 | def test_destroy_invalid_repository |
|
623 | def test_destroy_invalid_repository | |
624 | @request.session[:user_id] = 1 # admin |
|
624 | @request.session[:user_id] = 1 # admin | |
625 | @project.repository.destroy |
|
625 | @project.repository.destroy | |
626 | @repository = Repository::Git.create!( |
|
626 | @repository = Repository::Git.create!( | |
627 | :project => @project, |
|
627 | :project => @project, | |
628 | :url => "/invalid", |
|
628 | :url => "/invalid", | |
629 | :path_encoding => 'ISO-8859-1' |
|
629 | :path_encoding => 'ISO-8859-1' | |
630 | ) |
|
630 | ) | |
631 | @repository.fetch_changesets |
|
631 | @repository.fetch_changesets | |
632 | @repository.reload |
|
632 | @repository.reload | |
633 | assert_equal 0, @repository.changesets.count |
|
633 | assert_equal 0, @repository.changesets.count | |
634 |
|
634 | |||
635 | assert_difference 'Repository.count', -1 do |
|
635 | assert_difference 'Repository.count', -1 do | |
636 | delete :destroy, :id => @repository.id |
|
636 | delete :destroy, :id => @repository.id | |
637 | end |
|
637 | end | |
638 | assert_response 302 |
|
638 | assert_response 302 | |
639 | @project.reload |
|
639 | @project.reload | |
640 | assert_nil @project.repository |
|
640 | assert_nil @project.repository | |
641 | end |
|
641 | end | |
642 |
|
642 | |||
643 | private |
|
643 | private | |
644 |
|
644 | |||
645 | def puts_ruby19_non_utf8_pass |
|
645 | def puts_ruby19_non_utf8_pass | |
646 | puts "TODO: This test fails in Ruby 1.9 " + |
|
646 | puts "TODO: This test fails in Ruby 1.9 " + | |
647 | "and Encoding.default_external is not UTF-8. " + |
|
647 | "and Encoding.default_external is not UTF-8. " + | |
648 | "Current value is '#{Encoding.default_external.to_s}'" |
|
648 | "Current value is '#{Encoding.default_external.to_s}'" | |
649 | end |
|
649 | end | |
650 | else |
|
650 | else | |
651 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" |
|
651 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" | |
652 | def test_fake; assert true end |
|
652 | def test_fake; assert true end | |
653 | end |
|
653 | end | |
654 |
|
654 | |||
655 | private |
|
655 | private | |
656 | def with_cache(&block) |
|
656 | def with_cache(&block) | |
657 | before = ActionController::Base.perform_caching |
|
657 | before = ActionController::Base.perform_caching | |
658 | ActionController::Base.perform_caching = true |
|
658 | ActionController::Base.perform_caching = true | |
659 | block.call |
|
659 | block.call | |
660 | ActionController::Base.perform_caching = before |
|
660 | ActionController::Base.perform_caching = before | |
661 | end |
|
661 | end | |
662 | end |
|
662 | end |
General Comments 0
You need to be logged in to leave comments.
Login now