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