@@ -1,490 +1,487 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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 RepositoriesMercurialControllerTest < ActionController::TestCase |
|
20 | class RepositoriesMercurialControllerTest < ActionController::TestCase | |
21 | tests RepositoriesController |
|
21 | tests RepositoriesController | |
22 |
|
22 | |||
23 | fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, |
|
23 | fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, | |
24 | :repositories, :enabled_modules |
|
24 | :repositories, :enabled_modules | |
25 |
|
25 | |||
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s | |
27 | CHAR_1_HEX = "\xc3\x9c" |
|
27 | CHAR_1_HEX = "\xc3\x9c" | |
28 | PRJ_ID = 3 |
|
28 | PRJ_ID = 3 | |
29 | NUM_REV = 34 |
|
29 | NUM_REV = 34 | |
30 |
|
30 | |||
31 | ruby19_non_utf8_pass = Encoding.default_external.to_s != 'UTF-8' |
|
31 | ruby19_non_utf8_pass = Encoding.default_external.to_s != 'UTF-8' | |
32 |
|
32 | |||
33 | def setup |
|
33 | def setup | |
34 | User.current = nil |
|
34 | User.current = nil | |
35 | @project = Project.find(PRJ_ID) |
|
35 | @project = Project.find(PRJ_ID) | |
36 | @repository = Repository::Mercurial.create( |
|
36 | @repository = Repository::Mercurial.create( | |
37 | :project => @project, |
|
37 | :project => @project, | |
38 | :url => REPOSITORY_PATH, |
|
38 | :url => REPOSITORY_PATH, | |
39 | :path_encoding => 'ISO-8859-1' |
|
39 | :path_encoding => 'ISO-8859-1' | |
40 | ) |
|
40 | ) | |
41 | assert @repository |
|
41 | assert @repository | |
42 | @diff_c_support = true |
|
42 | @diff_c_support = true | |
43 | @char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8') |
|
43 | @char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8') | |
44 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00".force_encoding('UTF-8') |
|
44 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00".force_encoding('UTF-8') | |
45 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00".force_encoding('UTF-8') |
|
45 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00".force_encoding('UTF-8') | |
46 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8') |
|
46 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8') | |
47 | end |
|
47 | end | |
48 |
|
48 | |||
49 | if ruby19_non_utf8_pass |
|
49 | if ruby19_non_utf8_pass | |
50 | puts "TODO: Mercurial functional test fails " + |
|
50 | puts "TODO: Mercurial functional test fails " + | |
51 | "when Encoding.default_external is not UTF-8. " + |
|
51 | "when Encoding.default_external is not UTF-8. " + | |
52 | "Current value is '#{Encoding.default_external.to_s}'" |
|
52 | "Current value is '#{Encoding.default_external.to_s}'" | |
53 | def test_fake; assert true end |
|
53 | def test_fake; assert true end | |
54 | elsif File.directory?(REPOSITORY_PATH) |
|
54 | elsif File.directory?(REPOSITORY_PATH) | |
55 |
|
55 | |||
56 | def test_get_new |
|
56 | def test_get_new | |
57 | @request.session[:user_id] = 1 |
|
57 | @request.session[:user_id] = 1 | |
58 | @project.repository.destroy |
|
58 | @project.repository.destroy | |
59 | get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial' |
|
59 | get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial' | |
60 | assert_response :success |
|
60 | assert_response :success | |
61 | assert_template 'new' |
|
61 | assert_template 'new' | |
62 | assert_kind_of Repository::Mercurial, assigns(:repository) |
|
62 | assert_kind_of Repository::Mercurial, assigns(:repository) | |
63 | assert assigns(:repository).new_record? |
|
63 | assert assigns(:repository).new_record? | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | def test_show_root |
|
66 | def test_show_root | |
67 | assert_equal 0, @repository.changesets.count |
|
67 | assert_equal 0, @repository.changesets.count | |
68 | @repository.fetch_changesets |
|
68 | @repository.fetch_changesets | |
69 | @project.reload |
|
69 | @project.reload | |
70 | assert_equal NUM_REV, @repository.changesets.count |
|
70 | assert_equal NUM_REV, @repository.changesets.count | |
71 | get :show, :id => PRJ_ID |
|
71 | get :show, :id => PRJ_ID | |
72 | assert_response :success |
|
72 | assert_response :success | |
73 | assert_template 'show' |
|
73 | assert_template 'show' | |
74 | assert_not_nil assigns(:entries) |
|
74 | assert_not_nil assigns(:entries) | |
75 | assert_equal 4, assigns(:entries).size |
|
75 | assert_equal 4, assigns(:entries).size | |
76 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
76 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
77 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
77 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
78 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
78 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
79 | assert_not_nil assigns(:changesets) |
|
79 | assert_not_nil assigns(:changesets) | |
80 | assert assigns(:changesets).size > 0 |
|
80 | assert assigns(:changesets).size > 0 | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | def test_show_directory |
|
83 | def test_show_directory | |
84 | assert_equal 0, @repository.changesets.count |
|
84 | assert_equal 0, @repository.changesets.count | |
85 | @repository.fetch_changesets |
|
85 | @repository.fetch_changesets | |
86 | @project.reload |
|
86 | @project.reload | |
87 | assert_equal NUM_REV, @repository.changesets.count |
|
87 | assert_equal NUM_REV, @repository.changesets.count | |
88 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] |
|
88 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] | |
89 | assert_response :success |
|
89 | assert_response :success | |
90 | assert_template 'show' |
|
90 | assert_template 'show' | |
91 | assert_not_nil assigns(:entries) |
|
91 | assert_not_nil assigns(:entries) | |
92 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
|
92 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | |
93 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
93 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
94 | assert_not_nil entry |
|
94 | assert_not_nil entry | |
95 | assert_equal 'file', entry.kind |
|
95 | assert_equal 'file', entry.kind | |
96 | assert_equal 'images/edit.png', entry.path |
|
96 | assert_equal 'images/edit.png', entry.path | |
97 | assert_not_nil assigns(:changesets) |
|
97 | assert_not_nil assigns(:changesets) | |
98 | assert assigns(:changesets).size > 0 |
|
98 | assert assigns(:changesets).size > 0 | |
99 | end |
|
99 | end | |
100 |
|
100 | |||
101 | def test_show_at_given_revision |
|
101 | def test_show_at_given_revision | |
102 | assert_equal 0, @repository.changesets.count |
|
102 | assert_equal 0, @repository.changesets.count | |
103 | @repository.fetch_changesets |
|
103 | @repository.fetch_changesets | |
104 | @project.reload |
|
104 | @project.reload | |
105 | assert_equal NUM_REV, @repository.changesets.count |
|
105 | assert_equal NUM_REV, @repository.changesets.count | |
106 | [0, '0', '0885933ad4f6'].each do |r1| |
|
106 | [0, '0', '0885933ad4f6'].each do |r1| | |
107 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], |
|
107 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], | |
108 | :rev => r1 |
|
108 | :rev => r1 | |
109 | assert_response :success |
|
109 | assert_response :success | |
110 | assert_template 'show' |
|
110 | assert_template 'show' | |
111 | assert_not_nil assigns(:entries) |
|
111 | assert_not_nil assigns(:entries) | |
112 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
112 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
113 | assert_not_nil assigns(:changesets) |
|
113 | assert_not_nil assigns(:changesets) | |
114 | assert assigns(:changesets).size > 0 |
|
114 | assert assigns(:changesets).size > 0 | |
115 | end |
|
115 | end | |
116 | end |
|
116 | end | |
117 |
|
117 | |||
118 | def test_show_directory_sql_escape_percent |
|
118 | def test_show_directory_sql_escape_percent | |
119 | assert_equal 0, @repository.changesets.count |
|
119 | assert_equal 0, @repository.changesets.count | |
120 | @repository.fetch_changesets |
|
120 | @repository.fetch_changesets | |
121 | @project.reload |
|
121 | @project.reload | |
122 | assert_equal NUM_REV, @repository.changesets.count |
|
122 | assert_equal NUM_REV, @repository.changesets.count | |
123 | [13, '13', '3a330eb32958'].each do |r1| |
|
123 | [13, '13', '3a330eb32958'].each do |r1| | |
124 | get :show, :id => PRJ_ID, |
|
124 | get :show, :id => PRJ_ID, | |
125 | :path => repository_path_hash(['sql_escape', 'percent%dir'])[:param], |
|
125 | :path => repository_path_hash(['sql_escape', 'percent%dir'])[:param], | |
126 | :rev => r1 |
|
126 | :rev => r1 | |
127 | assert_response :success |
|
127 | assert_response :success | |
128 | assert_template 'show' |
|
128 | assert_template 'show' | |
129 |
|
129 | |||
130 | assert_not_nil assigns(:entries) |
|
130 | assert_not_nil assigns(:entries) | |
131 | assert_equal ['percent%file1.txt', 'percentfile1.txt'], |
|
131 | assert_equal ['percent%file1.txt', 'percentfile1.txt'], | |
132 | assigns(:entries).collect(&:name) |
|
132 | assigns(:entries).collect(&:name) | |
133 | changesets = assigns(:changesets) |
|
133 | changesets = assigns(:changesets) | |
134 | assert_not_nil changesets |
|
134 | assert_not_nil changesets | |
135 | assert assigns(:changesets).size > 0 |
|
135 | assert assigns(:changesets).size > 0 | |
136 | assert_equal %w(13 11 10 9), changesets.collect(&:revision) |
|
136 | assert_equal %w(13 11 10 9), changesets.collect(&:revision) | |
137 | end |
|
137 | end | |
138 | end |
|
138 | end | |
139 |
|
139 | |||
140 | def test_show_directory_latin_1_path |
|
140 | def test_show_directory_latin_1_path | |
141 | assert_equal 0, @repository.changesets.count |
|
141 | assert_equal 0, @repository.changesets.count | |
142 | @repository.fetch_changesets |
|
142 | @repository.fetch_changesets | |
143 | @project.reload |
|
143 | @project.reload | |
144 | assert_equal NUM_REV, @repository.changesets.count |
|
144 | assert_equal NUM_REV, @repository.changesets.count | |
145 | [21, '21', 'adf805632193'].each do |r1| |
|
145 | [21, '21', 'adf805632193'].each do |r1| | |
146 | get :show, :id => PRJ_ID, |
|
146 | get :show, :id => PRJ_ID, | |
147 | :path => repository_path_hash(['latin-1-dir'])[:param], |
|
147 | :path => repository_path_hash(['latin-1-dir'])[:param], | |
148 | :rev => r1 |
|
148 | :rev => r1 | |
149 | assert_response :success |
|
149 | assert_response :success | |
150 | assert_template 'show' |
|
150 | assert_template 'show' | |
151 |
|
151 | |||
152 | assert_not_nil assigns(:entries) |
|
152 | assert_not_nil assigns(:entries) | |
153 | assert_equal ["make-latin-1-file.rb", |
|
153 | assert_equal ["make-latin-1-file.rb", | |
154 | "test-#{@char_1}-1.txt", |
|
154 | "test-#{@char_1}-1.txt", | |
155 | "test-#{@char_1}-2.txt", |
|
155 | "test-#{@char_1}-2.txt", | |
156 | "test-#{@char_1}.txt"], assigns(:entries).collect(&:name) |
|
156 | "test-#{@char_1}.txt"], assigns(:entries).collect(&:name) | |
157 | changesets = assigns(:changesets) |
|
157 | changesets = assigns(:changesets) | |
158 | assert_not_nil changesets |
|
158 | assert_not_nil changesets | |
159 | assert_equal %w(21 20 19 18 17), changesets.collect(&:revision) |
|
159 | assert_equal %w(21 20 19 18 17), changesets.collect(&:revision) | |
160 | end |
|
160 | end | |
161 | end |
|
161 | end | |
162 |
|
162 | |||
163 | def show_should_show_branch_selection_form |
|
163 | def show_should_show_branch_selection_form | |
164 | @repository.fetch_changesets |
|
164 | @repository.fetch_changesets | |
165 | @project.reload |
|
165 | @project.reload | |
166 | get :show, :id => PRJ_ID |
|
166 | get :show, :id => PRJ_ID | |
167 | assert_select 'form#revision_selector[action=?]', '/projects/subproject1/repository/show' do |
|
167 | assert_select 'form#revision_selector[action=?]', '/projects/subproject1/repository/show' do | |
168 | assert_select 'select[name=branch]' do |
|
168 | assert_select 'select[name=branch]' do | |
169 | assert_select 'option[value=?]', 'test-branch-01' |
|
169 | assert_select 'option[value=?]', 'test-branch-01' | |
170 | end |
|
170 | end | |
171 | end |
|
171 | end | |
172 | end |
|
172 | end | |
173 |
|
173 | |||
174 | def test_show_branch |
|
174 | def test_show_branch | |
175 | assert_equal 0, @repository.changesets.count |
|
175 | assert_equal 0, @repository.changesets.count | |
176 | @repository.fetch_changesets |
|
176 | @repository.fetch_changesets | |
177 | @project.reload |
|
177 | @project.reload | |
178 | assert_equal NUM_REV, @repository.changesets.count |
|
178 | assert_equal NUM_REV, @repository.changesets.count | |
179 | [ |
|
179 | [ | |
180 | 'default', |
|
180 | 'default', | |
181 | @branch_char_1, |
|
181 | @branch_char_1, | |
182 | 'branch (1)[2]&,%.-3_4', |
|
182 | 'branch (1)[2]&,%.-3_4', | |
183 | @branch_char_0, |
|
183 | @branch_char_0, | |
184 | 'test_branch.latin-1', |
|
184 | 'test_branch.latin-1', | |
185 | 'test-branch-00', |
|
185 | 'test-branch-00', | |
186 | ].each do |bra| |
|
186 | ].each do |bra| | |
187 | get :show, :id => PRJ_ID, :rev => bra |
|
187 | get :show, :id => PRJ_ID, :rev => bra | |
188 | assert_response :success |
|
188 | assert_response :success | |
189 | assert_template 'show' |
|
189 | assert_template 'show' | |
190 | assert_not_nil assigns(:entries) |
|
190 | assert_not_nil assigns(:entries) | |
191 | assert assigns(:entries).size > 0 |
|
191 | assert assigns(:entries).size > 0 | |
192 | assert_not_nil assigns(:changesets) |
|
192 | assert_not_nil assigns(:changesets) | |
193 | assert assigns(:changesets).size > 0 |
|
193 | assert assigns(:changesets).size > 0 | |
194 | end |
|
194 | end | |
195 | end |
|
195 | end | |
196 |
|
196 | |||
197 | def test_show_tag |
|
197 | def test_show_tag | |
198 | assert_equal 0, @repository.changesets.count |
|
198 | assert_equal 0, @repository.changesets.count | |
199 | @repository.fetch_changesets |
|
199 | @repository.fetch_changesets | |
200 | @project.reload |
|
200 | @project.reload | |
201 | assert_equal NUM_REV, @repository.changesets.count |
|
201 | assert_equal NUM_REV, @repository.changesets.count | |
202 | [ |
|
202 | [ | |
203 | @tag_char_1, |
|
203 | @tag_char_1, | |
204 | 'tag_test.00', |
|
204 | 'tag_test.00', | |
205 | 'tag-init-revision' |
|
205 | 'tag-init-revision' | |
206 | ].each do |tag| |
|
206 | ].each do |tag| | |
207 | get :show, :id => PRJ_ID, :rev => tag |
|
207 | get :show, :id => PRJ_ID, :rev => tag | |
208 | assert_response :success |
|
208 | assert_response :success | |
209 | assert_template 'show' |
|
209 | assert_template 'show' | |
210 | assert_not_nil assigns(:entries) |
|
210 | assert_not_nil assigns(:entries) | |
211 | assert assigns(:entries).size > 0 |
|
211 | assert assigns(:entries).size > 0 | |
212 | assert_not_nil assigns(:changesets) |
|
212 | assert_not_nil assigns(:changesets) | |
213 | assert assigns(:changesets).size > 0 |
|
213 | assert assigns(:changesets).size > 0 | |
214 | end |
|
214 | end | |
215 | end |
|
215 | end | |
216 |
|
216 | |||
217 | def test_changes |
|
217 | def test_changes | |
218 | get :changes, :id => PRJ_ID, |
|
218 | get :changes, :id => PRJ_ID, | |
219 | :path => repository_path_hash(['images', 'edit.png'])[:param] |
|
219 | :path => repository_path_hash(['images', 'edit.png'])[:param] | |
220 | assert_response :success |
|
220 | assert_response :success | |
221 | assert_template 'changes' |
|
221 | assert_template 'changes' | |
222 | assert_select 'h2', :text => /edit.png/ |
|
222 | assert_select 'h2', :text => /edit.png/ | |
223 | end |
|
223 | end | |
224 |
|
224 | |||
225 | def test_entry_show |
|
225 | def test_entry_show | |
226 | get :entry, :id => PRJ_ID, |
|
226 | get :entry, :id => PRJ_ID, | |
227 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
227 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
228 | assert_response :success |
|
228 | assert_response :success | |
229 | assert_template 'entry' |
|
229 | assert_template 'entry' | |
230 | # Line 10 |
|
230 | # Line 10 | |
231 | assert_select 'tr#L10 td.line-code', :text => /WITHOUT ANY WARRANTY/ |
|
231 | assert_select 'tr#L10 td.line-code', :text => /WITHOUT ANY WARRANTY/ | |
232 | end |
|
232 | end | |
233 |
|
233 | |||
234 | def test_entry_show_latin_1_path |
|
234 | def test_entry_show_latin_1_path | |
235 | [21, '21', 'adf805632193'].each do |r1| |
|
235 | [21, '21', 'adf805632193'].each do |r1| | |
236 | get :entry, :id => PRJ_ID, |
|
236 | get :entry, :id => PRJ_ID, | |
237 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param], |
|
237 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param], | |
238 | :rev => r1 |
|
238 | :rev => r1 | |
239 | assert_response :success |
|
239 | assert_response :success | |
240 | assert_template 'entry' |
|
240 | assert_template 'entry' | |
241 | assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/ |
|
241 | assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/ | |
242 | end |
|
242 | end | |
243 | end |
|
243 | end | |
244 |
|
244 | |||
245 | def test_entry_show_latin_1_contents |
|
245 | def test_entry_show_latin_1_contents | |
246 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
246 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
247 | [27, '27', '7bbf4c738e71'].each do |r1| |
|
247 | [27, '27', '7bbf4c738e71'].each do |r1| | |
248 | get :entry, :id => PRJ_ID, |
|
248 | get :entry, :id => PRJ_ID, | |
249 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], |
|
249 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |
250 | :rev => r1 |
|
250 | :rev => r1 | |
251 | assert_response :success |
|
251 | assert_response :success | |
252 | assert_template 'entry' |
|
252 | assert_template 'entry' | |
253 | assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ |
|
253 | assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ | |
254 | end |
|
254 | end | |
255 | end |
|
255 | end | |
256 | end |
|
256 | end | |
257 |
|
257 | |||
258 | def test_entry_download |
|
258 | def test_entry_download | |
259 | get :entry, :id => PRJ_ID, |
|
259 | get :entry, :id => PRJ_ID, | |
260 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], |
|
260 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
261 | :format => 'raw' |
|
261 | :format => 'raw' | |
262 | assert_response :success |
|
262 | assert_response :success | |
263 | # File content |
|
263 | # File content | |
264 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
264 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |
265 | end |
|
265 | end | |
266 |
|
266 | |||
267 | def test_entry_binary_force_download |
|
267 | def test_entry_binary_force_download | |
268 | get :entry, :id => PRJ_ID, :rev => 1, |
|
268 | # TODO: add a binary file which is not an image to the test repo | |
269 | :path => repository_path_hash(['images', 'edit.png'])[:param] |
|
|||
270 | assert_response :success |
|
|||
271 | assert_equal 'image/png', @response.content_type |
|
|||
272 | end |
|
269 | end | |
273 |
|
270 | |||
274 | def test_directory_entry |
|
271 | def test_directory_entry | |
275 | get :entry, :id => PRJ_ID, |
|
272 | get :entry, :id => PRJ_ID, | |
276 | :path => repository_path_hash(['sources'])[:param] |
|
273 | :path => repository_path_hash(['sources'])[:param] | |
277 | assert_response :success |
|
274 | assert_response :success | |
278 | assert_template 'show' |
|
275 | assert_template 'show' | |
279 | assert_not_nil assigns(:entry) |
|
276 | assert_not_nil assigns(:entry) | |
280 | assert_equal 'sources', assigns(:entry).name |
|
277 | assert_equal 'sources', assigns(:entry).name | |
281 | end |
|
278 | end | |
282 |
|
279 | |||
283 | def test_diff |
|
280 | def test_diff | |
284 | assert_equal 0, @repository.changesets.count |
|
281 | assert_equal 0, @repository.changesets.count | |
285 | @repository.fetch_changesets |
|
282 | @repository.fetch_changesets | |
286 | @project.reload |
|
283 | @project.reload | |
287 | assert_equal NUM_REV, @repository.changesets.count |
|
284 | assert_equal NUM_REV, @repository.changesets.count | |
288 | [4, '4', 'def6d2f1254a'].each do |r1| |
|
285 | [4, '4', 'def6d2f1254a'].each do |r1| | |
289 | # Full diff of changeset 4 |
|
286 | # Full diff of changeset 4 | |
290 | ['inline', 'sbs'].each do |dt| |
|
287 | ['inline', 'sbs'].each do |dt| | |
291 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
288 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
292 | assert_response :success |
|
289 | assert_response :success | |
293 | assert_template 'diff' |
|
290 | assert_template 'diff' | |
294 | if @diff_c_support |
|
291 | if @diff_c_support | |
295 | # Line 22 removed |
|
292 | # Line 22 removed | |
296 | assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/ |
|
293 | assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/ | |
297 | assert_select 'h2', :text => /4:def6d2f1254a/ |
|
294 | assert_select 'h2', :text => /4:def6d2f1254a/ | |
298 | end |
|
295 | end | |
299 | end |
|
296 | end | |
300 | end |
|
297 | end | |
301 | end |
|
298 | end | |
302 |
|
299 | |||
303 | def test_diff_two_revs |
|
300 | def test_diff_two_revs | |
304 | assert_equal 0, @repository.changesets.count |
|
301 | assert_equal 0, @repository.changesets.count | |
305 | @repository.fetch_changesets |
|
302 | @repository.fetch_changesets | |
306 | @project.reload |
|
303 | @project.reload | |
307 | assert_equal NUM_REV, @repository.changesets.count |
|
304 | assert_equal NUM_REV, @repository.changesets.count | |
308 | [2, '400bb8672109', '400', 400].each do |r1| |
|
305 | [2, '400bb8672109', '400', 400].each do |r1| | |
309 | [4, 'def6d2f1254a'].each do |r2| |
|
306 | [4, 'def6d2f1254a'].each do |r2| | |
310 | ['inline', 'sbs'].each do |dt| |
|
307 | ['inline', 'sbs'].each do |dt| | |
311 | get :diff, |
|
308 | get :diff, | |
312 | :id => PRJ_ID, |
|
309 | :id => PRJ_ID, | |
313 | :rev => r1, |
|
310 | :rev => r1, | |
314 | :rev_to => r2, |
|
311 | :rev_to => r2, | |
315 | :type => dt |
|
312 | :type => dt | |
316 | assert_response :success |
|
313 | assert_response :success | |
317 | assert_template 'diff' |
|
314 | assert_template 'diff' | |
318 | diff = assigns(:diff) |
|
315 | diff = assigns(:diff) | |
319 | assert_not_nil diff |
|
316 | assert_not_nil diff | |
320 | assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/ |
|
317 | assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/ | |
321 | end |
|
318 | end | |
322 | end |
|
319 | end | |
323 | end |
|
320 | end | |
324 | end |
|
321 | end | |
325 |
|
322 | |||
326 | def test_diff_latin_1_path |
|
323 | def test_diff_latin_1_path | |
327 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
324 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
328 | [21, 'adf805632193'].each do |r1| |
|
325 | [21, 'adf805632193'].each do |r1| | |
329 | ['inline', 'sbs'].each do |dt| |
|
326 | ['inline', 'sbs'].each do |dt| | |
330 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
327 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
331 | assert_response :success |
|
328 | assert_response :success | |
332 | assert_template 'diff' |
|
329 | assert_template 'diff' | |
333 | assert_select 'table' do |
|
330 | assert_select 'table' do | |
334 | assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/ |
|
331 | assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/ | |
335 | assert_select 'tbody td.diff_in', :text => /It is written in Python/ |
|
332 | assert_select 'tbody td.diff_in', :text => /It is written in Python/ | |
336 | end |
|
333 | end | |
337 | end |
|
334 | end | |
338 | end |
|
335 | end | |
339 | end |
|
336 | end | |
340 | end |
|
337 | end | |
341 |
|
338 | |||
342 | def test_diff_should_show_modified_filenames |
|
339 | def test_diff_should_show_modified_filenames | |
343 | get :diff, :id => PRJ_ID, :rev => '400bb8672109', :type => 'inline' |
|
340 | get :diff, :id => PRJ_ID, :rev => '400bb8672109', :type => 'inline' | |
344 | assert_response :success |
|
341 | assert_response :success | |
345 | assert_template 'diff' |
|
342 | assert_template 'diff' | |
346 | assert_select 'th.filename', :text => 'sources/watchers_controller.rb' |
|
343 | assert_select 'th.filename', :text => 'sources/watchers_controller.rb' | |
347 | end |
|
344 | end | |
348 |
|
345 | |||
349 | def test_diff_should_show_deleted_filenames |
|
346 | def test_diff_should_show_deleted_filenames | |
350 | get :diff, :id => PRJ_ID, :rev => 'b3a615152df8', :type => 'inline' |
|
347 | get :diff, :id => PRJ_ID, :rev => 'b3a615152df8', :type => 'inline' | |
351 | assert_response :success |
|
348 | assert_response :success | |
352 | assert_template 'diff' |
|
349 | assert_template 'diff' | |
353 | assert_select 'th.filename', :text => 'sources/welcome_controller.rb' |
|
350 | assert_select 'th.filename', :text => 'sources/welcome_controller.rb' | |
354 | end |
|
351 | end | |
355 |
|
352 | |||
356 | def test_annotate |
|
353 | def test_annotate | |
357 | get :annotate, :id => PRJ_ID, |
|
354 | get :annotate, :id => PRJ_ID, | |
358 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
355 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
359 | assert_response :success |
|
356 | assert_response :success | |
360 | assert_template 'annotate' |
|
357 | assert_template 'annotate' | |
361 |
|
358 | |||
362 | # Line 22, revision 4:def6d2f1254a |
|
359 | # Line 22, revision 4:def6d2f1254a | |
363 | assert_select 'tr' do |
|
360 | assert_select 'tr' do | |
364 | assert_select 'th.line-num', :text => '22' |
|
361 | assert_select 'th.line-num', :text => '22' | |
365 | assert_select 'td.revision', :text => '4:def6d2f1254a' |
|
362 | assert_select 'td.revision', :text => '4:def6d2f1254a' | |
366 | assert_select 'td.author', :text => 'jsmith' |
|
363 | assert_select 'td.author', :text => 'jsmith' | |
367 | assert_select 'td', :text => /remove_watcher/ |
|
364 | assert_select 'td', :text => /remove_watcher/ | |
368 | end |
|
365 | end | |
369 | end |
|
366 | end | |
370 |
|
367 | |||
371 | def test_annotate_not_in_tip |
|
368 | def test_annotate_not_in_tip | |
372 | assert_equal 0, @repository.changesets.count |
|
369 | assert_equal 0, @repository.changesets.count | |
373 | @repository.fetch_changesets |
|
370 | @repository.fetch_changesets | |
374 | @project.reload |
|
371 | @project.reload | |
375 | assert_equal NUM_REV, @repository.changesets.count |
|
372 | assert_equal NUM_REV, @repository.changesets.count | |
376 | get :annotate, :id => PRJ_ID, |
|
373 | get :annotate, :id => PRJ_ID, | |
377 | :path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param] |
|
374 | :path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param] | |
378 | assert_response 404 |
|
375 | assert_response 404 | |
379 | assert_select_error /was not found/ |
|
376 | assert_select_error /was not found/ | |
380 | end |
|
377 | end | |
381 |
|
378 | |||
382 | def test_annotate_at_given_revision |
|
379 | def test_annotate_at_given_revision | |
383 | assert_equal 0, @repository.changesets.count |
|
380 | assert_equal 0, @repository.changesets.count | |
384 | @repository.fetch_changesets |
|
381 | @repository.fetch_changesets | |
385 | @project.reload |
|
382 | @project.reload | |
386 | assert_equal NUM_REV, @repository.changesets.count |
|
383 | assert_equal NUM_REV, @repository.changesets.count | |
387 | [2, '400bb8672109', '400', 400].each do |r1| |
|
384 | [2, '400bb8672109', '400', 400].each do |r1| | |
388 | get :annotate, :id => PRJ_ID, :rev => r1, |
|
385 | get :annotate, :id => PRJ_ID, :rev => r1, | |
389 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
386 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
390 | assert_response :success |
|
387 | assert_response :success | |
391 | assert_template 'annotate' |
|
388 | assert_template 'annotate' | |
392 | assert_select 'h2', :text => /@ 2:400bb8672109/ |
|
389 | assert_select 'h2', :text => /@ 2:400bb8672109/ | |
393 | end |
|
390 | end | |
394 | end |
|
391 | end | |
395 |
|
392 | |||
396 | def test_annotate_latin_1_path |
|
393 | def test_annotate_latin_1_path | |
397 | [21, '21', 'adf805632193'].each do |r1| |
|
394 | [21, '21', 'adf805632193'].each do |r1| | |
398 | get :annotate, :id => PRJ_ID, |
|
395 | get :annotate, :id => PRJ_ID, | |
399 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param], |
|
396 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param], | |
400 | :rev => r1 |
|
397 | :rev => r1 | |
401 | assert_response :success |
|
398 | assert_response :success | |
402 | assert_template 'annotate' |
|
399 | assert_template 'annotate' | |
403 | assert_select "th.line-num", :text => '1' do |
|
400 | assert_select "th.line-num", :text => '1' do | |
404 | assert_select "+ td.revision" do |
|
401 | assert_select "+ td.revision" do | |
405 | assert_select "a", :text => '20:709858aafd1b' |
|
402 | assert_select "a", :text => '20:709858aafd1b' | |
406 | assert_select "+ td.author", :text => "jsmith" do |
|
403 | assert_select "+ td.author", :text => "jsmith" do | |
407 | assert_select "+ td", |
|
404 | assert_select "+ td", | |
408 | :text => "Mercurial is a distributed version control system." |
|
405 | :text => "Mercurial is a distributed version control system." | |
409 | end |
|
406 | end | |
410 | end |
|
407 | end | |
411 | end |
|
408 | end | |
412 | end |
|
409 | end | |
413 | end |
|
410 | end | |
414 |
|
411 | |||
415 | def test_annotate_latin_1_contents |
|
412 | def test_annotate_latin_1_contents | |
416 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
413 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
417 | [27, '7bbf4c738e71'].each do |r1| |
|
414 | [27, '7bbf4c738e71'].each do |r1| | |
418 | get :annotate, :id => PRJ_ID, |
|
415 | get :annotate, :id => PRJ_ID, | |
419 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], |
|
416 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |
420 | :rev => r1 |
|
417 | :rev => r1 | |
421 | assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ |
|
418 | assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ | |
422 | end |
|
419 | end | |
423 | end |
|
420 | end | |
424 | end |
|
421 | end | |
425 |
|
422 | |||
426 | def test_revision |
|
423 | def test_revision | |
427 | assert_equal 0, @repository.changesets.count |
|
424 | assert_equal 0, @repository.changesets.count | |
428 | @repository.fetch_changesets |
|
425 | @repository.fetch_changesets | |
429 | @project.reload |
|
426 | @project.reload | |
430 | assert_equal NUM_REV, @repository.changesets.count |
|
427 | assert_equal NUM_REV, @repository.changesets.count | |
431 | ['1', '9d5b5b', '9d5b5b004199'].each do |r| |
|
428 | ['1', '9d5b5b', '9d5b5b004199'].each do |r| | |
432 | with_settings :default_language => "en" do |
|
429 | with_settings :default_language => "en" do | |
433 | get :revision, :id => PRJ_ID, :rev => r |
|
430 | get :revision, :id => PRJ_ID, :rev => r | |
434 | assert_response :success |
|
431 | assert_response :success | |
435 | assert_template 'revision' |
|
432 | assert_template 'revision' | |
436 | assert_select 'title', |
|
433 | assert_select 'title', | |
437 | :text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine' |
|
434 | :text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine' | |
438 | end |
|
435 | end | |
439 | end |
|
436 | end | |
440 | end |
|
437 | end | |
441 |
|
438 | |||
442 | def test_empty_revision |
|
439 | def test_empty_revision | |
443 | assert_equal 0, @repository.changesets.count |
|
440 | assert_equal 0, @repository.changesets.count | |
444 | @repository.fetch_changesets |
|
441 | @repository.fetch_changesets | |
445 | @project.reload |
|
442 | @project.reload | |
446 | assert_equal NUM_REV, @repository.changesets.count |
|
443 | assert_equal NUM_REV, @repository.changesets.count | |
447 | ['', ' ', nil].each do |r| |
|
444 | ['', ' ', nil].each do |r| | |
448 | get :revision, :id => PRJ_ID, :rev => r |
|
445 | get :revision, :id => PRJ_ID, :rev => r | |
449 | assert_response 404 |
|
446 | assert_response 404 | |
450 | assert_select_error /was not found/ |
|
447 | assert_select_error /was not found/ | |
451 | end |
|
448 | end | |
452 | end |
|
449 | end | |
453 |
|
450 | |||
454 | def test_destroy_valid_repository |
|
451 | def test_destroy_valid_repository | |
455 | @request.session[:user_id] = 1 # admin |
|
452 | @request.session[:user_id] = 1 # admin | |
456 | assert_equal 0, @repository.changesets.count |
|
453 | assert_equal 0, @repository.changesets.count | |
457 | @repository.fetch_changesets |
|
454 | @repository.fetch_changesets | |
458 | assert_equal NUM_REV, @repository.changesets.count |
|
455 | assert_equal NUM_REV, @repository.changesets.count | |
459 |
|
456 | |||
460 | assert_difference 'Repository.count', -1 do |
|
457 | assert_difference 'Repository.count', -1 do | |
461 | delete :destroy, :id => @repository.id |
|
458 | delete :destroy, :id => @repository.id | |
462 | end |
|
459 | end | |
463 | assert_response 302 |
|
460 | assert_response 302 | |
464 | @project.reload |
|
461 | @project.reload | |
465 | assert_nil @project.repository |
|
462 | assert_nil @project.repository | |
466 | end |
|
463 | end | |
467 |
|
464 | |||
468 | def test_destroy_invalid_repository |
|
465 | def test_destroy_invalid_repository | |
469 | @request.session[:user_id] = 1 # admin |
|
466 | @request.session[:user_id] = 1 # admin | |
470 | @project.repository.destroy |
|
467 | @project.repository.destroy | |
471 | @repository = Repository::Mercurial.create!( |
|
468 | @repository = Repository::Mercurial.create!( | |
472 | :project => Project.find(PRJ_ID), |
|
469 | :project => Project.find(PRJ_ID), | |
473 | :url => "/invalid", |
|
470 | :url => "/invalid", | |
474 | :path_encoding => 'ISO-8859-1' |
|
471 | :path_encoding => 'ISO-8859-1' | |
475 | ) |
|
472 | ) | |
476 | @repository.fetch_changesets |
|
473 | @repository.fetch_changesets | |
477 | assert_equal 0, @repository.changesets.count |
|
474 | assert_equal 0, @repository.changesets.count | |
478 |
|
475 | |||
479 | assert_difference 'Repository.count', -1 do |
|
476 | assert_difference 'Repository.count', -1 do | |
480 | delete :destroy, :id => @repository.id |
|
477 | delete :destroy, :id => @repository.id | |
481 | end |
|
478 | end | |
482 | assert_response 302 |
|
479 | assert_response 302 | |
483 | @project.reload |
|
480 | @project.reload | |
484 | assert_nil @project.repository |
|
481 | assert_nil @project.repository | |
485 | end |
|
482 | end | |
486 | else |
|
483 | else | |
487 | puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!" |
|
484 | puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!" | |
488 | def test_fake; assert true end |
|
485 | def test_fake; assert true end | |
489 | end |
|
486 | end | |
490 | end |
|
487 | end |
@@ -1,421 +1,421 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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 RepositoriesSubversionControllerTest < ActionController::TestCase |
|
20 | class RepositoriesSubversionControllerTest < ActionController::TestCase | |
21 | tests RepositoriesController |
|
21 | tests RepositoriesController | |
22 |
|
22 | |||
23 | fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, :enabled_modules, |
|
23 | fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, :enabled_modules, | |
24 | :repositories, :issues, :issue_statuses, :changesets, :changes, |
|
24 | :repositories, :issues, :issue_statuses, :changesets, :changes, | |
25 | :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers |
|
25 | :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |
26 |
|
26 | |||
27 | PRJ_ID = 3 |
|
27 | PRJ_ID = 3 | |
28 | NUM_REV = 11 |
|
28 | NUM_REV = 11 | |
29 |
|
29 | |||
30 | def setup |
|
30 | def setup | |
31 | Setting.default_language = 'en' |
|
31 | Setting.default_language = 'en' | |
32 | User.current = nil |
|
32 | User.current = nil | |
33 |
|
33 | |||
34 | @project = Project.find(PRJ_ID) |
|
34 | @project = Project.find(PRJ_ID) | |
35 | @repository = Repository::Subversion.create(:project => @project, |
|
35 | @repository = Repository::Subversion.create(:project => @project, | |
36 | :url => self.class.subversion_repository_url) |
|
36 | :url => self.class.subversion_repository_url) | |
37 | assert @repository |
|
37 | assert @repository | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | if repository_configured?('subversion') |
|
40 | if repository_configured?('subversion') | |
41 | def test_new |
|
41 | def test_new | |
42 | @request.session[:user_id] = 1 |
|
42 | @request.session[:user_id] = 1 | |
43 | @project.repository.destroy |
|
43 | @project.repository.destroy | |
44 | get :new, :project_id => 'subproject1', :repository_scm => 'Subversion' |
|
44 | get :new, :project_id => 'subproject1', :repository_scm => 'Subversion' | |
45 | assert_response :success |
|
45 | assert_response :success | |
46 | assert_template 'new' |
|
46 | assert_template 'new' | |
47 | assert_kind_of Repository::Subversion, assigns(:repository) |
|
47 | assert_kind_of Repository::Subversion, assigns(:repository) | |
48 | assert assigns(:repository).new_record? |
|
48 | assert assigns(:repository).new_record? | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | def test_show |
|
51 | def test_show | |
52 | assert_equal 0, @repository.changesets.count |
|
52 | assert_equal 0, @repository.changesets.count | |
53 | @repository.fetch_changesets |
|
53 | @repository.fetch_changesets | |
54 | @project.reload |
|
54 | @project.reload | |
55 | assert_equal NUM_REV, @repository.changesets.count |
|
55 | assert_equal NUM_REV, @repository.changesets.count | |
56 | get :show, :id => PRJ_ID |
|
56 | get :show, :id => PRJ_ID | |
57 | assert_response :success |
|
57 | assert_response :success | |
58 | assert_template 'show' |
|
58 | assert_template 'show' | |
59 | assert_not_nil assigns(:entries) |
|
59 | assert_not_nil assigns(:entries) | |
60 | assert_not_nil assigns(:changesets) |
|
60 | assert_not_nil assigns(:changesets) | |
61 |
|
61 | |||
62 | entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} |
|
62 | entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} | |
63 | assert_not_nil entry |
|
63 | assert_not_nil entry | |
64 | assert_equal 'dir', entry.kind |
|
64 | assert_equal 'dir', entry.kind | |
65 | assert_select 'tr.dir a[href="/projects/subproject1/repository/show/subversion_test"]' |
|
65 | assert_select 'tr.dir a[href="/projects/subproject1/repository/show/subversion_test"]' | |
66 |
|
66 | |||
67 | assert_select 'input[name=rev]' |
|
67 | assert_select 'input[name=rev]' | |
68 | assert_select 'a', :text => 'Statistics' |
|
68 | assert_select 'a', :text => 'Statistics' | |
69 | assert_select 'a', :text => 'Atom' |
|
69 | assert_select 'a', :text => 'Atom' | |
70 | assert_select 'a[href=?]', '/projects/subproject1/repository', :text => 'root' |
|
70 | assert_select 'a[href=?]', '/projects/subproject1/repository', :text => 'root' | |
71 | end |
|
71 | end | |
72 |
|
72 | |||
73 | def test_show_non_default |
|
73 | def test_show_non_default | |
74 | Repository::Subversion.create(:project => @project, |
|
74 | Repository::Subversion.create(:project => @project, | |
75 | :url => self.class.subversion_repository_url, |
|
75 | :url => self.class.subversion_repository_url, | |
76 | :is_default => false, :identifier => 'svn') |
|
76 | :is_default => false, :identifier => 'svn') | |
77 |
|
77 | |||
78 | get :show, :id => PRJ_ID, :repository_id => 'svn' |
|
78 | get :show, :id => PRJ_ID, :repository_id => 'svn' | |
79 | assert_response :success |
|
79 | assert_response :success | |
80 | assert_template 'show' |
|
80 | assert_template 'show' | |
81 | assert_select 'tr.dir a[href="/projects/subproject1/repository/svn/show/subversion_test"]' |
|
81 | assert_select 'tr.dir a[href="/projects/subproject1/repository/svn/show/subversion_test"]' | |
82 | # Repository menu should link to the main repo |
|
82 | # Repository menu should link to the main repo | |
83 | assert_select '#main-menu a[href="/projects/subproject1/repository"]' |
|
83 | assert_select '#main-menu a[href="/projects/subproject1/repository"]' | |
84 | end |
|
84 | end | |
85 |
|
85 | |||
86 | def test_browse_directory |
|
86 | def test_browse_directory | |
87 | assert_equal 0, @repository.changesets.count |
|
87 | assert_equal 0, @repository.changesets.count | |
88 | @repository.fetch_changesets |
|
88 | @repository.fetch_changesets | |
89 | @project.reload |
|
89 | @project.reload | |
90 | assert_equal NUM_REV, @repository.changesets.count |
|
90 | assert_equal NUM_REV, @repository.changesets.count | |
91 | get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param] |
|
91 | get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param] | |
92 | assert_response :success |
|
92 | assert_response :success | |
93 | assert_template 'show' |
|
93 | assert_template 'show' | |
94 | assert_not_nil assigns(:entries) |
|
94 | assert_not_nil assigns(:entries) | |
95 | assert_equal [ |
|
95 | assert_equal [ | |
96 | '[folder_with_brackets]', 'folder', '.project', |
|
96 | '[folder_with_brackets]', 'folder', '.project', | |
97 | 'helloworld.c', 'textfile.txt' |
|
97 | 'helloworld.c', 'textfile.txt' | |
98 | ], |
|
98 | ], | |
99 | assigns(:entries).collect(&:name) |
|
99 | assigns(:entries).collect(&:name) | |
100 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} |
|
100 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} | |
101 | assert_equal 'file', entry.kind |
|
101 | assert_equal 'file', entry.kind | |
102 | assert_equal 'subversion_test/helloworld.c', entry.path |
|
102 | assert_equal 'subversion_test/helloworld.c', entry.path | |
103 | assert_select 'a.text-x-c', :text => 'helloworld.c' |
|
103 | assert_select 'a.text-x-c', :text => 'helloworld.c' | |
104 | end |
|
104 | end | |
105 |
|
105 | |||
106 | def test_browse_at_given_revision |
|
106 | def test_browse_at_given_revision | |
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 | get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param], |
|
111 | get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param], | |
112 | :rev => 4 |
|
112 | :rev => 4 | |
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 ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], |
|
116 | assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], | |
117 | assigns(:entries).collect(&:name) |
|
117 | assigns(:entries).collect(&:name) | |
118 | end |
|
118 | end | |
119 |
|
119 | |||
120 | def test_file_changes |
|
120 | def test_file_changes | |
121 | assert_equal 0, @repository.changesets.count |
|
121 | assert_equal 0, @repository.changesets.count | |
122 | @repository.fetch_changesets |
|
122 | @repository.fetch_changesets | |
123 | @project.reload |
|
123 | @project.reload | |
124 | assert_equal NUM_REV, @repository.changesets.count |
|
124 | assert_equal NUM_REV, @repository.changesets.count | |
125 | get :changes, :id => PRJ_ID, |
|
125 | get :changes, :id => PRJ_ID, | |
126 | :path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param] |
|
126 | :path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param] | |
127 | assert_response :success |
|
127 | assert_response :success | |
128 | assert_template 'changes' |
|
128 | assert_template 'changes' | |
129 |
|
129 | |||
130 | changesets = assigns(:changesets) |
|
130 | changesets = assigns(:changesets) | |
131 | assert_not_nil changesets |
|
131 | assert_not_nil changesets | |
132 | assert_equal %w(6 3 2), changesets.collect(&:revision) |
|
132 | assert_equal %w(6 3 2), changesets.collect(&:revision) | |
133 |
|
133 | |||
134 | # svn properties displayed with svn >= 1.5 only |
|
134 | # svn properties displayed with svn >= 1.5 only | |
135 | if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) |
|
135 | if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) | |
136 | assert_not_nil assigns(:properties) |
|
136 | assert_not_nil assigns(:properties) | |
137 | assert_equal 'native', assigns(:properties)['svn:eol-style'] |
|
137 | assert_equal 'native', assigns(:properties)['svn:eol-style'] | |
138 | assert_select 'ul li' do |
|
138 | assert_select 'ul li' do | |
139 | assert_select 'b', :text => 'svn:eol-style' |
|
139 | assert_select 'b', :text => 'svn:eol-style' | |
140 | assert_select 'span', :text => 'native' |
|
140 | assert_select 'span', :text => 'native' | |
141 | end |
|
141 | end | |
142 | end |
|
142 | end | |
143 | end |
|
143 | end | |
144 |
|
144 | |||
145 | def test_directory_changes |
|
145 | def test_directory_changes | |
146 | assert_equal 0, @repository.changesets.count |
|
146 | assert_equal 0, @repository.changesets.count | |
147 | @repository.fetch_changesets |
|
147 | @repository.fetch_changesets | |
148 | @project.reload |
|
148 | @project.reload | |
149 | assert_equal NUM_REV, @repository.changesets.count |
|
149 | assert_equal NUM_REV, @repository.changesets.count | |
150 | get :changes, :id => PRJ_ID, |
|
150 | get :changes, :id => PRJ_ID, | |
151 | :path => repository_path_hash(['subversion_test', 'folder'])[:param] |
|
151 | :path => repository_path_hash(['subversion_test', 'folder'])[:param] | |
152 | assert_response :success |
|
152 | assert_response :success | |
153 | assert_template 'changes' |
|
153 | assert_template 'changes' | |
154 |
|
154 | |||
155 | changesets = assigns(:changesets) |
|
155 | changesets = assigns(:changesets) | |
156 | assert_not_nil changesets |
|
156 | assert_not_nil changesets | |
157 | assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) |
|
157 | assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) | |
158 | end |
|
158 | end | |
159 |
|
159 | |||
160 | def test_entry |
|
160 | def test_entry | |
161 | assert_equal 0, @repository.changesets.count |
|
161 | assert_equal 0, @repository.changesets.count | |
162 | @repository.fetch_changesets |
|
162 | @repository.fetch_changesets | |
163 | @project.reload |
|
163 | @project.reload | |
164 | assert_equal NUM_REV, @repository.changesets.count |
|
164 | assert_equal NUM_REV, @repository.changesets.count | |
165 | get :entry, :id => PRJ_ID, |
|
165 | get :entry, :id => PRJ_ID, | |
166 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
166 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] | |
167 | assert_response :success |
|
167 | assert_response :success | |
168 | assert_template 'entry' |
|
168 | assert_template 'entry' | |
169 | end |
|
169 | end | |
170 |
|
170 | |||
171 | def test_entry_should_send_if_too_big |
|
171 | def test_entry_should_send_if_too_big | |
172 | assert_equal 0, @repository.changesets.count |
|
172 | assert_equal 0, @repository.changesets.count | |
173 | @repository.fetch_changesets |
|
173 | @repository.fetch_changesets | |
174 | @project.reload |
|
174 | @project.reload | |
175 | assert_equal NUM_REV, @repository.changesets.count |
|
175 | assert_equal NUM_REV, @repository.changesets.count | |
176 | # no files in the test repo is larger than 1KB... |
|
176 | # no files in the test repo is larger than 1KB... | |
177 | with_settings :file_max_size_displayed => 0 do |
|
177 | with_settings :file_max_size_displayed => 0 do | |
178 | get :entry, :id => PRJ_ID, |
|
178 | get :entry, :id => PRJ_ID, | |
179 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
179 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] | |
180 | assert_response :success |
|
180 | assert_response :success | |
181 | assert_equal 'attachment; filename="helloworld.c"', |
|
181 | assert_equal 'attachment; filename="helloworld.c"', | |
182 | @response.headers['Content-Disposition'] |
|
182 | @response.headers['Content-Disposition'] | |
183 | end |
|
183 | end | |
184 | end |
|
184 | end | |
185 |
|
185 | |||
186 |
def test_entry_should_ |
|
186 | def test_entry_should_display_images | |
187 | get :entry, :id => PRJ_ID, |
|
187 | get :entry, :id => PRJ_ID, | |
188 | :path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'rubylogo.gif'])[:param] |
|
188 | :path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'rubylogo.gif'])[:param] | |
189 | assert_response :success |
|
189 | assert_response :success | |
190 | assert_equal 'inline; filename="rubylogo.gif"', response.headers['Content-Disposition'] |
|
190 | assert_template 'entry' | |
191 | end |
|
191 | end | |
192 |
|
192 | |||
193 | def test_entry_at_given_revision |
|
193 | def test_entry_at_given_revision | |
194 | assert_equal 0, @repository.changesets.count |
|
194 | assert_equal 0, @repository.changesets.count | |
195 | @repository.fetch_changesets |
|
195 | @repository.fetch_changesets | |
196 | @project.reload |
|
196 | @project.reload | |
197 | assert_equal NUM_REV, @repository.changesets.count |
|
197 | assert_equal NUM_REV, @repository.changesets.count | |
198 | get :entry, :id => PRJ_ID, |
|
198 | get :entry, :id => PRJ_ID, | |
199 | :path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param], |
|
199 | :path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param], | |
200 | :rev => 2 |
|
200 | :rev => 2 | |
201 | assert_response :success |
|
201 | assert_response :success | |
202 | assert_template 'entry' |
|
202 | assert_template 'entry' | |
203 | # this line was removed in r3 and file was moved in r6 |
|
203 | # this line was removed in r3 and file was moved in r6 | |
204 | assert_select 'td.line-code', :text => /Here's the code/ |
|
204 | assert_select 'td.line-code', :text => /Here's the code/ | |
205 | end |
|
205 | end | |
206 |
|
206 | |||
207 | def test_entry_not_found |
|
207 | def test_entry_not_found | |
208 | assert_equal 0, @repository.changesets.count |
|
208 | assert_equal 0, @repository.changesets.count | |
209 | @repository.fetch_changesets |
|
209 | @repository.fetch_changesets | |
210 | @project.reload |
|
210 | @project.reload | |
211 | assert_equal NUM_REV, @repository.changesets.count |
|
211 | assert_equal NUM_REV, @repository.changesets.count | |
212 | get :entry, :id => PRJ_ID, |
|
212 | get :entry, :id => PRJ_ID, | |
213 | :path => repository_path_hash(['subversion_test', 'zzz.c'])[:param] |
|
213 | :path => repository_path_hash(['subversion_test', 'zzz.c'])[:param] | |
214 | assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/ |
|
214 | assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/ | |
215 | end |
|
215 | end | |
216 |
|
216 | |||
217 | def test_entry_download |
|
217 | def test_entry_download | |
218 | assert_equal 0, @repository.changesets.count |
|
218 | assert_equal 0, @repository.changesets.count | |
219 | @repository.fetch_changesets |
|
219 | @repository.fetch_changesets | |
220 | @project.reload |
|
220 | @project.reload | |
221 | assert_equal NUM_REV, @repository.changesets.count |
|
221 | assert_equal NUM_REV, @repository.changesets.count | |
222 | get :raw, :id => PRJ_ID, |
|
222 | get :raw, :id => PRJ_ID, | |
223 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
223 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] | |
224 | assert_response :success |
|
224 | assert_response :success | |
225 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] |
|
225 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | |
226 | end |
|
226 | end | |
227 |
|
227 | |||
228 | def test_directory_entry |
|
228 | def test_directory_entry | |
229 | assert_equal 0, @repository.changesets.count |
|
229 | assert_equal 0, @repository.changesets.count | |
230 | @repository.fetch_changesets |
|
230 | @repository.fetch_changesets | |
231 | @project.reload |
|
231 | @project.reload | |
232 | assert_equal NUM_REV, @repository.changesets.count |
|
232 | assert_equal NUM_REV, @repository.changesets.count | |
233 | get :entry, :id => PRJ_ID, |
|
233 | get :entry, :id => PRJ_ID, | |
234 | :path => repository_path_hash(['subversion_test', 'folder'])[:param] |
|
234 | :path => repository_path_hash(['subversion_test', 'folder'])[:param] | |
235 | assert_response :success |
|
235 | assert_response :success | |
236 | assert_template 'show' |
|
236 | assert_template 'show' | |
237 | assert_not_nil assigns(:entry) |
|
237 | assert_not_nil assigns(:entry) | |
238 | assert_equal 'folder', assigns(:entry).name |
|
238 | assert_equal 'folder', assigns(:entry).name | |
239 | end |
|
239 | end | |
240 |
|
240 | |||
241 | # TODO: this test needs fixtures. |
|
241 | # TODO: this test needs fixtures. | |
242 | def test_revision |
|
242 | def test_revision | |
243 | get :revision, :id => 1, :rev => 2 |
|
243 | get :revision, :id => 1, :rev => 2 | |
244 | assert_response :success |
|
244 | assert_response :success | |
245 | assert_template 'revision' |
|
245 | assert_template 'revision' | |
246 |
|
246 | |||
247 | assert_select 'ul' do |
|
247 | assert_select 'ul' do | |
248 | assert_select 'li' do |
|
248 | assert_select 'li' do | |
249 | # link to the entry at rev 2 |
|
249 | # link to the entry at rev 2 | |
250 | assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo', :text => 'repo' |
|
250 | assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo', :text => 'repo' | |
251 | # link to partial diff |
|
251 | # link to partial diff | |
252 | assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' |
|
252 | assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' | |
253 | end |
|
253 | end | |
254 | end |
|
254 | end | |
255 | end |
|
255 | end | |
256 |
|
256 | |||
257 | def test_invalid_revision |
|
257 | def test_invalid_revision | |
258 | assert_equal 0, @repository.changesets.count |
|
258 | assert_equal 0, @repository.changesets.count | |
259 | @repository.fetch_changesets |
|
259 | @repository.fetch_changesets | |
260 | @project.reload |
|
260 | @project.reload | |
261 | assert_equal NUM_REV, @repository.changesets.count |
|
261 | assert_equal NUM_REV, @repository.changesets.count | |
262 | get :revision, :id => PRJ_ID, :rev => 'something_weird' |
|
262 | get :revision, :id => PRJ_ID, :rev => 'something_weird' | |
263 | assert_response 404 |
|
263 | assert_response 404 | |
264 | assert_select_error /was not found/ |
|
264 | assert_select_error /was not found/ | |
265 | end |
|
265 | end | |
266 |
|
266 | |||
267 | def test_invalid_revision_diff |
|
267 | def test_invalid_revision_diff | |
268 | get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' |
|
268 | get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' | |
269 | assert_response 404 |
|
269 | assert_response 404 | |
270 | assert_select_error /was not found/ |
|
270 | assert_select_error /was not found/ | |
271 | end |
|
271 | end | |
272 |
|
272 | |||
273 | def test_empty_revision |
|
273 | def test_empty_revision | |
274 | assert_equal 0, @repository.changesets.count |
|
274 | assert_equal 0, @repository.changesets.count | |
275 | @repository.fetch_changesets |
|
275 | @repository.fetch_changesets | |
276 | @project.reload |
|
276 | @project.reload | |
277 | assert_equal NUM_REV, @repository.changesets.count |
|
277 | assert_equal NUM_REV, @repository.changesets.count | |
278 | ['', ' ', nil].each do |r| |
|
278 | ['', ' ', nil].each do |r| | |
279 | get :revision, :id => PRJ_ID, :rev => r |
|
279 | get :revision, :id => PRJ_ID, :rev => r | |
280 | assert_response 404 |
|
280 | assert_response 404 | |
281 | assert_select_error /was not found/ |
|
281 | assert_select_error /was not found/ | |
282 | end |
|
282 | end | |
283 | end |
|
283 | end | |
284 |
|
284 | |||
285 | # TODO: this test needs fixtures. |
|
285 | # TODO: this test needs fixtures. | |
286 | def test_revision_with_repository_pointing_to_a_subdirectory |
|
286 | def test_revision_with_repository_pointing_to_a_subdirectory | |
287 | r = Project.find(1).repository |
|
287 | r = Project.find(1).repository | |
288 | # Changes repository url to a subdirectory |
|
288 | # Changes repository url to a subdirectory | |
289 | r.update_attribute :url, (r.url + '/test/some') |
|
289 | r.update_attribute :url, (r.url + '/test/some') | |
290 |
|
290 | |||
291 | get :revision, :id => 1, :rev => 2 |
|
291 | get :revision, :id => 1, :rev => 2 | |
292 | assert_response :success |
|
292 | assert_response :success | |
293 | assert_template 'revision' |
|
293 | assert_template 'revision' | |
294 |
|
294 | |||
295 | assert_select 'ul' do |
|
295 | assert_select 'ul' do | |
296 | assert_select 'li' do |
|
296 | assert_select 'li' do | |
297 | # link to the entry at rev 2 |
|
297 | # link to the entry at rev 2 | |
298 | assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo', :text => 'repo' |
|
298 | assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo', :text => 'repo' | |
299 | # link to partial diff |
|
299 | # link to partial diff | |
300 | assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' |
|
300 | assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' | |
301 | end |
|
301 | end | |
302 | end |
|
302 | end | |
303 | end |
|
303 | end | |
304 |
|
304 | |||
305 | def test_revision_diff |
|
305 | def test_revision_diff | |
306 | assert_equal 0, @repository.changesets.count |
|
306 | assert_equal 0, @repository.changesets.count | |
307 | @repository.fetch_changesets |
|
307 | @repository.fetch_changesets | |
308 | @project.reload |
|
308 | @project.reload | |
309 | assert_equal NUM_REV, @repository.changesets.count |
|
309 | assert_equal NUM_REV, @repository.changesets.count | |
310 | ['inline', 'sbs'].each do |dt| |
|
310 | ['inline', 'sbs'].each do |dt| | |
311 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt |
|
311 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt | |
312 | assert_response :success |
|
312 | assert_response :success | |
313 | assert_template 'diff' |
|
313 | assert_template 'diff' | |
314 | assert_select 'h2', :text => /Revision 3/ |
|
314 | assert_select 'h2', :text => /Revision 3/ | |
315 | assert_select 'th.filename', :text => 'subversion_test/textfile.txt' |
|
315 | assert_select 'th.filename', :text => 'subversion_test/textfile.txt' | |
316 | end |
|
316 | end | |
317 | end |
|
317 | end | |
318 |
|
318 | |||
319 | def test_revision_diff_raw_format |
|
319 | def test_revision_diff_raw_format | |
320 | assert_equal 0, @repository.changesets.count |
|
320 | assert_equal 0, @repository.changesets.count | |
321 | @repository.fetch_changesets |
|
321 | @repository.fetch_changesets | |
322 | @project.reload |
|
322 | @project.reload | |
323 | assert_equal NUM_REV, @repository.changesets.count |
|
323 | assert_equal NUM_REV, @repository.changesets.count | |
324 |
|
324 | |||
325 | get :diff, :id => PRJ_ID, :rev => 5, :format => 'diff' |
|
325 | get :diff, :id => PRJ_ID, :rev => 5, :format => 'diff' | |
326 | assert_response :success |
|
326 | assert_response :success | |
327 | assert_equal 'text/x-patch', @response.content_type |
|
327 | assert_equal 'text/x-patch', @response.content_type | |
328 | assert_equal 'Index: subversion_test/folder/greeter.rb', @response.body.split(/\r?\n/).first |
|
328 | assert_equal 'Index: subversion_test/folder/greeter.rb', @response.body.split(/\r?\n/).first | |
329 | end |
|
329 | end | |
330 |
|
330 | |||
331 | def test_directory_diff |
|
331 | def test_directory_diff | |
332 | assert_equal 0, @repository.changesets.count |
|
332 | assert_equal 0, @repository.changesets.count | |
333 | @repository.fetch_changesets |
|
333 | @repository.fetch_changesets | |
334 | @project.reload |
|
334 | @project.reload | |
335 | assert_equal NUM_REV, @repository.changesets.count |
|
335 | assert_equal NUM_REV, @repository.changesets.count | |
336 | ['inline', 'sbs'].each do |dt| |
|
336 | ['inline', 'sbs'].each do |dt| | |
337 | get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, |
|
337 | get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, | |
338 | :path => repository_path_hash(['subversion_test', 'folder'])[:param], |
|
338 | :path => repository_path_hash(['subversion_test', 'folder'])[:param], | |
339 | :type => dt |
|
339 | :type => dt | |
340 | assert_response :success |
|
340 | assert_response :success | |
341 | assert_template 'diff' |
|
341 | assert_template 'diff' | |
342 |
|
342 | |||
343 | diff = assigns(:diff) |
|
343 | diff = assigns(:diff) | |
344 | assert_not_nil diff |
|
344 | assert_not_nil diff | |
345 | # 2 files modified |
|
345 | # 2 files modified | |
346 | assert_equal 2, Redmine::UnifiedDiff.new(diff).size |
|
346 | assert_equal 2, Redmine::UnifiedDiff.new(diff).size | |
347 | assert_select 'h2', :text => /2:6/ |
|
347 | assert_select 'h2', :text => /2:6/ | |
348 | end |
|
348 | end | |
349 | end |
|
349 | end | |
350 |
|
350 | |||
351 | def test_annotate |
|
351 | def test_annotate | |
352 | assert_equal 0, @repository.changesets.count |
|
352 | assert_equal 0, @repository.changesets.count | |
353 | @repository.fetch_changesets |
|
353 | @repository.fetch_changesets | |
354 | @project.reload |
|
354 | @project.reload | |
355 | assert_equal NUM_REV, @repository.changesets.count |
|
355 | assert_equal NUM_REV, @repository.changesets.count | |
356 | get :annotate, :id => PRJ_ID, |
|
356 | get :annotate, :id => PRJ_ID, | |
357 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
357 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] | |
358 | assert_response :success |
|
358 | assert_response :success | |
359 | assert_template 'annotate' |
|
359 | assert_template 'annotate' | |
360 |
|
360 | |||
361 | assert_select 'tr' do |
|
361 | assert_select 'tr' do | |
362 | assert_select 'th.line-num', :text => '1' |
|
362 | assert_select 'th.line-num', :text => '1' | |
363 | assert_select 'td.revision', :text => '4' |
|
363 | assert_select 'td.revision', :text => '4' | |
364 | assert_select 'td.author', :text => 'jp' |
|
364 | assert_select 'td.author', :text => 'jp' | |
365 | assert_select 'td', :text => /stdio.h/ |
|
365 | assert_select 'td', :text => /stdio.h/ | |
366 | end |
|
366 | end | |
367 | # Same revision |
|
367 | # Same revision | |
368 | assert_select 'tr' do |
|
368 | assert_select 'tr' do | |
369 | assert_select 'th.line-num', :text => '2' |
|
369 | assert_select 'th.line-num', :text => '2' | |
370 | assert_select 'td.revision', :text => '' |
|
370 | assert_select 'td.revision', :text => '' | |
371 | assert_select 'td.author', :text => '' |
|
371 | assert_select 'td.author', :text => '' | |
372 | end |
|
372 | end | |
373 | end |
|
373 | end | |
374 |
|
374 | |||
375 | def test_annotate_at_given_revision |
|
375 | def test_annotate_at_given_revision | |
376 | assert_equal 0, @repository.changesets.count |
|
376 | assert_equal 0, @repository.changesets.count | |
377 | @repository.fetch_changesets |
|
377 | @repository.fetch_changesets | |
378 | @project.reload |
|
378 | @project.reload | |
379 | assert_equal NUM_REV, @repository.changesets.count |
|
379 | assert_equal NUM_REV, @repository.changesets.count | |
380 | get :annotate, :id => PRJ_ID, :rev => 8, |
|
380 | get :annotate, :id => PRJ_ID, :rev => 8, | |
381 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
381 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] | |
382 | assert_response :success |
|
382 | assert_response :success | |
383 | assert_template 'annotate' |
|
383 | assert_template 'annotate' | |
384 | assert_select 'h2', :text => /@ 8/ |
|
384 | assert_select 'h2', :text => /@ 8/ | |
385 | end |
|
385 | end | |
386 |
|
386 | |||
387 | def test_destroy_valid_repository |
|
387 | def test_destroy_valid_repository | |
388 | @request.session[:user_id] = 1 # admin |
|
388 | @request.session[:user_id] = 1 # admin | |
389 | assert_equal 0, @repository.changesets.count |
|
389 | assert_equal 0, @repository.changesets.count | |
390 | @repository.fetch_changesets |
|
390 | @repository.fetch_changesets | |
391 | assert_equal NUM_REV, @repository.changesets.count |
|
391 | assert_equal NUM_REV, @repository.changesets.count | |
392 |
|
392 | |||
393 | assert_difference 'Repository.count', -1 do |
|
393 | assert_difference 'Repository.count', -1 do | |
394 | delete :destroy, :id => @repository.id |
|
394 | delete :destroy, :id => @repository.id | |
395 | end |
|
395 | end | |
396 | assert_response 302 |
|
396 | assert_response 302 | |
397 | @project.reload |
|
397 | @project.reload | |
398 | assert_nil @project.repository |
|
398 | assert_nil @project.repository | |
399 | end |
|
399 | end | |
400 |
|
400 | |||
401 | def test_destroy_invalid_repository |
|
401 | def test_destroy_invalid_repository | |
402 | @request.session[:user_id] = 1 # admin |
|
402 | @request.session[:user_id] = 1 # admin | |
403 | @project.repository.destroy |
|
403 | @project.repository.destroy | |
404 | @repository = Repository::Subversion.create!( |
|
404 | @repository = Repository::Subversion.create!( | |
405 | :project => @project, |
|
405 | :project => @project, | |
406 | :url => "file:///invalid") |
|
406 | :url => "file:///invalid") | |
407 | @repository.fetch_changesets |
|
407 | @repository.fetch_changesets | |
408 | assert_equal 0, @repository.changesets.count |
|
408 | assert_equal 0, @repository.changesets.count | |
409 |
|
409 | |||
410 | assert_difference 'Repository.count', -1 do |
|
410 | assert_difference 'Repository.count', -1 do | |
411 | delete :destroy, :id => @repository.id |
|
411 | delete :destroy, :id => @repository.id | |
412 | end |
|
412 | end | |
413 | assert_response 302 |
|
413 | assert_response 302 | |
414 | @project.reload |
|
414 | @project.reload | |
415 | assert_nil @project.repository |
|
415 | assert_nil @project.repository | |
416 | end |
|
416 | end | |
417 | else |
|
417 | else | |
418 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" |
|
418 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" | |
419 | def test_fake; assert true end |
|
419 | def test_fake; assert true end | |
420 | end |
|
420 | end | |
421 | end |
|
421 | end |
General Comments 0
You need to be logged in to leave comments.
Login now