@@ -1,381 +1,379 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 | require 'repositories_controller' |
|
19 | require 'repositories_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class RepositoriesController; def rescue_action(e) raise e end; end |
|
22 | class RepositoriesController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class RepositoriesSubversionControllerTest < ActionController::TestCase |
|
24 | class RepositoriesSubversionControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, |
|
25 | fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, | |
26 | :repositories, :issues, :issue_statuses, :changesets, :changes, |
|
26 | :repositories, :issues, :issue_statuses, :changesets, :changes, | |
27 | :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers |
|
27 | :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |
28 |
|
28 | |||
29 | PRJ_ID = 3 |
|
29 | PRJ_ID = 3 | |
30 | NUM_REV = 11 |
|
30 | NUM_REV = 11 | |
31 |
|
31 | |||
32 | def setup |
|
32 | def setup | |
33 | @controller = RepositoriesController.new |
|
33 | @controller = RepositoriesController.new | |
34 | @request = ActionController::TestRequest.new |
|
34 | @request = ActionController::TestRequest.new | |
35 | @response = ActionController::TestResponse.new |
|
35 | @response = ActionController::TestResponse.new | |
36 | Setting.default_language = 'en' |
|
36 | Setting.default_language = 'en' | |
37 | User.current = nil |
|
37 | User.current = nil | |
38 |
|
38 | |||
39 | @project = Project.find(PRJ_ID) |
|
39 | @project = Project.find(PRJ_ID) | |
40 | @repository = Repository::Subversion.create(:project => @project, |
|
40 | @repository = Repository::Subversion.create(:project => @project, | |
41 | :url => self.class.subversion_repository_url) |
|
41 | :url => self.class.subversion_repository_url) | |
42 | assert @repository |
|
42 | assert @repository | |
43 | end |
|
43 | end | |
44 |
|
44 | |||
45 | if repository_configured?('subversion') |
|
45 | if repository_configured?('subversion') | |
46 | def test_show |
|
46 | def test_show | |
47 | assert_equal 0, @repository.changesets.count |
|
47 | assert_equal 0, @repository.changesets.count | |
48 | @repository.fetch_changesets |
|
48 | @repository.fetch_changesets | |
49 | @project.reload |
|
49 | @project.reload | |
50 | assert_equal NUM_REV, @repository.changesets.count |
|
50 | assert_equal NUM_REV, @repository.changesets.count | |
51 | get :show, :id => PRJ_ID |
|
51 | get :show, :id => PRJ_ID | |
52 | assert_response :success |
|
52 | assert_response :success | |
53 | assert_template 'show' |
|
53 | assert_template 'show' | |
54 | assert_not_nil assigns(:entries) |
|
54 | assert_not_nil assigns(:entries) | |
55 | assert_not_nil assigns(:changesets) |
|
55 | assert_not_nil assigns(:changesets) | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def test_browse_root |
|
58 | def test_browse_root | |
59 | assert_equal 0, @repository.changesets.count |
|
59 | assert_equal 0, @repository.changesets.count | |
60 | @repository.fetch_changesets |
|
60 | @repository.fetch_changesets | |
61 | @project.reload |
|
61 | @project.reload | |
62 | assert_equal NUM_REV, @repository.changesets.count |
|
62 | assert_equal NUM_REV, @repository.changesets.count | |
63 | get :show, :id => PRJ_ID |
|
63 | get :show, :id => PRJ_ID | |
64 | assert_response :success |
|
64 | assert_response :success | |
65 | assert_template 'show' |
|
65 | assert_template 'show' | |
66 | assert_not_nil assigns(:entries) |
|
66 | assert_not_nil assigns(:entries) | |
67 | entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} |
|
67 | entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} | |
68 | assert_equal 'dir', entry.kind |
|
68 | assert_equal 'dir', entry.kind | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | def test_browse_directory |
|
71 | def test_browse_directory | |
72 | assert_equal 0, @repository.changesets.count |
|
72 | assert_equal 0, @repository.changesets.count | |
73 | @repository.fetch_changesets |
|
73 | @repository.fetch_changesets | |
74 | @project.reload |
|
74 | @project.reload | |
75 | assert_equal NUM_REV, @repository.changesets.count |
|
75 | assert_equal NUM_REV, @repository.changesets.count | |
76 | get :show, :id => PRJ_ID, :path => ['subversion_test'] |
|
76 | get :show, :id => PRJ_ID, :path => ['subversion_test'] | |
77 | assert_response :success |
|
77 | assert_response :success | |
78 | assert_template 'show' |
|
78 | assert_template 'show' | |
79 | assert_not_nil assigns(:entries) |
|
79 | assert_not_nil assigns(:entries) | |
80 | assert_equal [ |
|
80 | assert_equal [ | |
81 | '[folder_with_brackets]', 'folder', '.project', |
|
81 | '[folder_with_brackets]', 'folder', '.project', | |
82 | 'helloworld.c', 'textfile.txt' |
|
82 | 'helloworld.c', 'textfile.txt' | |
83 | ], |
|
83 | ], | |
84 | assigns(:entries).collect(&:name) |
|
84 | assigns(:entries).collect(&:name) | |
85 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} |
|
85 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} | |
86 | assert_equal 'file', entry.kind |
|
86 | assert_equal 'file', entry.kind | |
87 | assert_equal 'subversion_test/helloworld.c', entry.path |
|
87 | assert_equal 'subversion_test/helloworld.c', entry.path | |
88 | assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } |
|
88 | assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } | |
89 | end |
|
89 | end | |
90 |
|
90 | |||
91 | def test_browse_at_given_revision |
|
91 | def test_browse_at_given_revision | |
92 | assert_equal 0, @repository.changesets.count |
|
92 | assert_equal 0, @repository.changesets.count | |
93 | @repository.fetch_changesets |
|
93 | @repository.fetch_changesets | |
94 | @project.reload |
|
94 | @project.reload | |
95 | assert_equal NUM_REV, @repository.changesets.count |
|
95 | assert_equal NUM_REV, @repository.changesets.count | |
96 | get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4 |
|
96 | get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4 | |
97 | assert_response :success |
|
97 | assert_response :success | |
98 | assert_template 'show' |
|
98 | assert_template 'show' | |
99 | assert_not_nil assigns(:entries) |
|
99 | assert_not_nil assigns(:entries) | |
100 | assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], |
|
100 | assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], | |
101 | assigns(:entries).collect(&:name) |
|
101 | assigns(:entries).collect(&:name) | |
102 | end |
|
102 | end | |
103 |
|
103 | |||
104 | def test_file_changes |
|
104 | def test_file_changes | |
105 | assert_equal 0, @repository.changesets.count |
|
105 | assert_equal 0, @repository.changesets.count | |
106 | @repository.fetch_changesets |
|
106 | @repository.fetch_changesets | |
107 | @project.reload |
|
107 | @project.reload | |
108 | assert_equal NUM_REV, @repository.changesets.count |
|
108 | assert_equal NUM_REV, @repository.changesets.count | |
109 | get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ] |
|
109 | get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ] | |
110 | assert_response :success |
|
110 | assert_response :success | |
111 | assert_template 'changes' |
|
111 | assert_template 'changes' | |
112 |
|
112 | |||
113 | changesets = assigns(:changesets) |
|
113 | changesets = assigns(:changesets) | |
114 | assert_not_nil changesets |
|
114 | assert_not_nil changesets | |
115 | assert_equal %w(6 3 2), changesets.collect(&:revision) |
|
115 | assert_equal %w(6 3 2), changesets.collect(&:revision) | |
116 |
|
116 | |||
117 | # svn properties displayed with svn >= 1.5 only |
|
117 | # svn properties displayed with svn >= 1.5 only | |
118 | if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) |
|
118 | if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) | |
119 | assert_not_nil assigns(:properties) |
|
119 | assert_not_nil assigns(:properties) | |
120 | assert_equal 'native', assigns(:properties)['svn:eol-style'] |
|
120 | assert_equal 'native', assigns(:properties)['svn:eol-style'] | |
121 | assert_tag :ul, |
|
121 | assert_tag :ul, | |
122 | :child => { :tag => 'li', |
|
122 | :child => { :tag => 'li', | |
123 | :child => { :tag => 'b', :content => 'svn:eol-style' }, |
|
123 | :child => { :tag => 'b', :content => 'svn:eol-style' }, | |
124 | :child => { :tag => 'span', :content => 'native' } } |
|
124 | :child => { :tag => 'span', :content => 'native' } } | |
125 | end |
|
125 | end | |
126 | end |
|
126 | end | |
127 |
|
127 | |||
128 | def test_directory_changes |
|
128 | def test_directory_changes | |
129 | assert_equal 0, @repository.changesets.count |
|
129 | assert_equal 0, @repository.changesets.count | |
130 | @repository.fetch_changesets |
|
130 | @repository.fetch_changesets | |
131 | @project.reload |
|
131 | @project.reload | |
132 | assert_equal NUM_REV, @repository.changesets.count |
|
132 | assert_equal NUM_REV, @repository.changesets.count | |
133 | get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ] |
|
133 | get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ] | |
134 | assert_response :success |
|
134 | assert_response :success | |
135 | assert_template 'changes' |
|
135 | assert_template 'changes' | |
136 |
|
136 | |||
137 | changesets = assigns(:changesets) |
|
137 | changesets = assigns(:changesets) | |
138 | assert_not_nil changesets |
|
138 | assert_not_nil changesets | |
139 | assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) |
|
139 | assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) | |
140 | end |
|
140 | end | |
141 |
|
141 | |||
142 | def test_entry |
|
142 | def test_entry | |
143 | assert_equal 0, @repository.changesets.count |
|
143 | assert_equal 0, @repository.changesets.count | |
144 | @repository.fetch_changesets |
|
144 | @repository.fetch_changesets | |
145 | @project.reload |
|
145 | @project.reload | |
146 | assert_equal NUM_REV, @repository.changesets.count |
|
146 | assert_equal NUM_REV, @repository.changesets.count | |
147 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
|
147 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | |
148 | assert_response :success |
|
148 | assert_response :success | |
149 | assert_template 'entry' |
|
149 | assert_template 'entry' | |
150 | end |
|
150 | end | |
151 |
|
151 | |||
152 | def test_entry_should_send_if_too_big |
|
152 | def test_entry_should_send_if_too_big | |
153 | assert_equal 0, @repository.changesets.count |
|
153 | assert_equal 0, @repository.changesets.count | |
154 | @repository.fetch_changesets |
|
154 | @repository.fetch_changesets | |
155 | @project.reload |
|
155 | @project.reload | |
156 | assert_equal NUM_REV, @repository.changesets.count |
|
156 | assert_equal NUM_REV, @repository.changesets.count | |
157 | # no files in the test repo is larger than 1KB... |
|
157 | # no files in the test repo is larger than 1KB... | |
158 | with_settings :file_max_size_displayed => 0 do |
|
158 | with_settings :file_max_size_displayed => 0 do | |
159 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
|
159 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | |
160 | assert_response :success |
|
160 | assert_response :success | |
161 | assert_template '' |
|
161 | assert_template '' | |
162 | assert_equal 'attachment; filename="helloworld.c"', |
|
162 | assert_equal 'attachment; filename="helloworld.c"', | |
163 | @response.headers['Content-Disposition'] |
|
163 | @response.headers['Content-Disposition'] | |
164 | end |
|
164 | end | |
165 | end |
|
165 | end | |
166 |
|
166 | |||
167 | def test_entry_at_given_revision |
|
167 | def test_entry_at_given_revision | |
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 :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 |
|
172 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 | |
173 | assert_response :success |
|
173 | assert_response :success | |
174 | assert_template 'entry' |
|
174 | assert_template 'entry' | |
175 | # this line was removed in r3 and file was moved in r6 |
|
175 | # this line was removed in r3 and file was moved in r6 | |
176 | assert_tag :tag => 'td', :attributes => { :class => /line-code/}, |
|
176 | assert_tag :tag => 'td', :attributes => { :class => /line-code/}, | |
177 | :content => /Here's the code/ |
|
177 | :content => /Here's the code/ | |
178 | end |
|
178 | end | |
179 |
|
179 | |||
180 | def test_entry_not_found |
|
180 | def test_entry_not_found | |
181 | assert_equal 0, @repository.changesets.count |
|
181 | assert_equal 0, @repository.changesets.count | |
182 | @repository.fetch_changesets |
|
182 | @repository.fetch_changesets | |
183 | @project.reload |
|
183 | @project.reload | |
184 | assert_equal NUM_REV, @repository.changesets.count |
|
184 | assert_equal NUM_REV, @repository.changesets.count | |
185 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c'] |
|
185 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c'] | |
186 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
186 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
187 | :content => /The entry or revision was not found in the repository/ |
|
187 | :content => /The entry or revision was not found in the repository/ | |
188 | end |
|
188 | end | |
189 |
|
189 | |||
190 | def test_entry_download |
|
190 | def test_entry_download | |
191 | assert_equal 0, @repository.changesets.count |
|
191 | assert_equal 0, @repository.changesets.count | |
192 | @repository.fetch_changesets |
|
192 | @repository.fetch_changesets | |
193 | @project.reload |
|
193 | @project.reload | |
194 | assert_equal NUM_REV, @repository.changesets.count |
|
194 | assert_equal NUM_REV, @repository.changesets.count | |
195 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' |
|
195 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' | |
196 | assert_response :success |
|
196 | assert_response :success | |
197 | assert_template '' |
|
197 | assert_template '' | |
198 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] |
|
198 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | |
199 | end |
|
199 | end | |
200 |
|
200 | |||
201 | def test_directory_entry |
|
201 | def test_directory_entry | |
202 | assert_equal 0, @repository.changesets.count |
|
202 | assert_equal 0, @repository.changesets.count | |
203 | @repository.fetch_changesets |
|
203 | @repository.fetch_changesets | |
204 | @project.reload |
|
204 | @project.reload | |
205 | assert_equal NUM_REV, @repository.changesets.count |
|
205 | assert_equal NUM_REV, @repository.changesets.count | |
206 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder'] |
|
206 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder'] | |
207 | assert_response :success |
|
207 | assert_response :success | |
208 | assert_template 'show' |
|
208 | assert_template 'show' | |
209 | assert_not_nil assigns(:entry) |
|
209 | assert_not_nil assigns(:entry) | |
210 | assert_equal 'folder', assigns(:entry).name |
|
210 | assert_equal 'folder', assigns(:entry).name | |
211 | end |
|
211 | end | |
212 |
|
212 | |||
213 | # TODO: this test needs fixtures. |
|
213 | # TODO: this test needs fixtures. | |
214 | def test_revision |
|
214 | def test_revision | |
215 | @repository.fetch_changesets |
|
|||
216 | @repository.reload |
|
|||
217 | get :revision, :id => 1, :rev => 2 |
|
215 | get :revision, :id => 1, :rev => 2 | |
218 | assert_response :success |
|
216 | assert_response :success | |
219 | assert_template 'revision' |
|
217 | assert_template 'revision' | |
220 | assert_tag :tag => 'ul', |
|
218 | assert_tag :tag => 'ul', | |
221 | :child => { :tag => 'li', |
|
219 | :child => { :tag => 'li', | |
222 | # link to the entry at rev 2 |
|
220 | # link to the entry at rev 2 | |
223 | :child => { :tag => 'a', |
|
221 | :child => { :tag => 'a', | |
224 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'}, |
|
222 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'}, | |
225 | :content => 'repo', |
|
223 | :content => 'repo', | |
226 | # link to partial diff |
|
224 | # link to partial diff | |
227 | :sibling => { :tag => 'a', |
|
225 | :sibling => { :tag => 'a', | |
228 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' } |
|
226 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' } | |
229 | } |
|
227 | } | |
230 | } |
|
228 | } | |
231 | } |
|
229 | } | |
232 | end |
|
230 | end | |
233 |
|
231 | |||
234 | def test_invalid_revision |
|
232 | def test_invalid_revision | |
235 | assert_equal 0, @repository.changesets.count |
|
233 | assert_equal 0, @repository.changesets.count | |
236 | @repository.fetch_changesets |
|
234 | @repository.fetch_changesets | |
237 | @project.reload |
|
235 | @project.reload | |
238 | assert_equal NUM_REV, @repository.changesets.count |
|
236 | assert_equal NUM_REV, @repository.changesets.count | |
239 | get :revision, :id => PRJ_ID, :rev => 'something_weird' |
|
237 | get :revision, :id => PRJ_ID, :rev => 'something_weird' | |
240 | assert_response 404 |
|
238 | assert_response 404 | |
241 | assert_error_tag :content => /was not found/ |
|
239 | assert_error_tag :content => /was not found/ | |
242 | end |
|
240 | end | |
243 |
|
241 | |||
244 | def test_invalid_revision_diff |
|
242 | def test_invalid_revision_diff | |
245 | get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' |
|
243 | get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' | |
246 | assert_response 404 |
|
244 | assert_response 404 | |
247 | assert_error_tag :content => /was not found/ |
|
245 | assert_error_tag :content => /was not found/ | |
248 | end |
|
246 | end | |
249 |
|
247 | |||
250 | def test_empty_revision |
|
248 | def test_empty_revision | |
251 | assert_equal 0, @repository.changesets.count |
|
249 | assert_equal 0, @repository.changesets.count | |
252 | @repository.fetch_changesets |
|
250 | @repository.fetch_changesets | |
253 | @project.reload |
|
251 | @project.reload | |
254 | assert_equal NUM_REV, @repository.changesets.count |
|
252 | assert_equal NUM_REV, @repository.changesets.count | |
255 | ['', ' ', nil].each do |r| |
|
253 | ['', ' ', nil].each do |r| | |
256 | get :revision, :id => PRJ_ID, :rev => r |
|
254 | get :revision, :id => PRJ_ID, :rev => r | |
257 | assert_response 404 |
|
255 | assert_response 404 | |
258 | assert_error_tag :content => /was not found/ |
|
256 | assert_error_tag :content => /was not found/ | |
259 | end |
|
257 | end | |
260 | end |
|
258 | end | |
261 |
|
259 | |||
262 | # TODO: this test needs fixtures. |
|
260 | # TODO: this test needs fixtures. | |
263 | def test_revision_with_repository_pointing_to_a_subdirectory |
|
261 | def test_revision_with_repository_pointing_to_a_subdirectory | |
264 | r = Project.find(1).repository |
|
262 | r = Project.find(1).repository | |
265 | # Changes repository url to a subdirectory |
|
263 | # Changes repository url to a subdirectory | |
266 | r.update_attribute :url, (r.url + '/test/some') |
|
264 | r.update_attribute :url, (r.url + '/test/some') | |
267 |
|
265 | |||
268 | get :revision, :id => 1, :rev => 2 |
|
266 | get :revision, :id => 1, :rev => 2 | |
269 | assert_response :success |
|
267 | assert_response :success | |
270 | assert_template 'revision' |
|
268 | assert_template 'revision' | |
271 | assert_tag :tag => 'ul', |
|
269 | assert_tag :tag => 'ul', | |
272 | :child => { :tag => 'li', |
|
270 | :child => { :tag => 'li', | |
273 | # link to the entry at rev 2 |
|
271 | # link to the entry at rev 2 | |
274 | :child => { :tag => 'a', |
|
272 | :child => { :tag => 'a', | |
275 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'}, |
|
273 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'}, | |
276 | :content => 'repo', |
|
274 | :content => 'repo', | |
277 | # link to partial diff |
|
275 | # link to partial diff | |
278 | :sibling => { :tag => 'a', |
|
276 | :sibling => { :tag => 'a', | |
279 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' } |
|
277 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' } | |
280 | } |
|
278 | } | |
281 | } |
|
279 | } | |
282 | } |
|
280 | } | |
283 | end |
|
281 | end | |
284 |
|
282 | |||
285 | def test_revision_diff |
|
283 | def test_revision_diff | |
286 | assert_equal 0, @repository.changesets.count |
|
284 | assert_equal 0, @repository.changesets.count | |
287 | @repository.fetch_changesets |
|
285 | @repository.fetch_changesets | |
288 | @project.reload |
|
286 | @project.reload | |
289 | assert_equal NUM_REV, @repository.changesets.count |
|
287 | assert_equal NUM_REV, @repository.changesets.count | |
290 | ['inline', 'sbs'].each do |dt| |
|
288 | ['inline', 'sbs'].each do |dt| | |
291 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt |
|
289 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt | |
292 | assert_response :success |
|
290 | assert_response :success | |
293 | assert_template 'diff' |
|
291 | assert_template 'diff' | |
294 | assert_tag :tag => 'h2', |
|
292 | assert_tag :tag => 'h2', | |
295 | :content => / 3/ |
|
293 | :content => / 3/ | |
296 | end |
|
294 | end | |
297 | end |
|
295 | end | |
298 |
|
296 | |||
299 | def test_directory_diff |
|
297 | def test_directory_diff | |
300 | assert_equal 0, @repository.changesets.count |
|
298 | assert_equal 0, @repository.changesets.count | |
301 | @repository.fetch_changesets |
|
299 | @repository.fetch_changesets | |
302 | @project.reload |
|
300 | @project.reload | |
303 | assert_equal NUM_REV, @repository.changesets.count |
|
301 | assert_equal NUM_REV, @repository.changesets.count | |
304 | ['inline', 'sbs'].each do |dt| |
|
302 | ['inline', 'sbs'].each do |dt| | |
305 | get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, |
|
303 | get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, | |
306 | :path => ['subversion_test', 'folder'], :type => dt |
|
304 | :path => ['subversion_test', 'folder'], :type => dt | |
307 | assert_response :success |
|
305 | assert_response :success | |
308 | assert_template 'diff' |
|
306 | assert_template 'diff' | |
309 |
|
307 | |||
310 | diff = assigns(:diff) |
|
308 | diff = assigns(:diff) | |
311 | assert_not_nil diff |
|
309 | assert_not_nil diff | |
312 | # 2 files modified |
|
310 | # 2 files modified | |
313 | assert_equal 2, Redmine::UnifiedDiff.new(diff).size |
|
311 | assert_equal 2, Redmine::UnifiedDiff.new(diff).size | |
314 | assert_tag :tag => 'h2', :content => /2:6/ |
|
312 | assert_tag :tag => 'h2', :content => /2:6/ | |
315 | end |
|
313 | end | |
316 | end |
|
314 | end | |
317 |
|
315 | |||
318 | def test_annotate |
|
316 | def test_annotate | |
319 | assert_equal 0, @repository.changesets.count |
|
317 | assert_equal 0, @repository.changesets.count | |
320 | @repository.fetch_changesets |
|
318 | @repository.fetch_changesets | |
321 | @project.reload |
|
319 | @project.reload | |
322 | assert_equal NUM_REV, @repository.changesets.count |
|
320 | assert_equal NUM_REV, @repository.changesets.count | |
323 | get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
|
321 | get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | |
324 | assert_response :success |
|
322 | assert_response :success | |
325 | assert_template 'annotate' |
|
323 | assert_template 'annotate' | |
326 | end |
|
324 | end | |
327 |
|
325 | |||
328 | def test_annotate_at_given_revision |
|
326 | def test_annotate_at_given_revision | |
329 | assert_equal 0, @repository.changesets.count |
|
327 | assert_equal 0, @repository.changesets.count | |
330 | @repository.fetch_changesets |
|
328 | @repository.fetch_changesets | |
331 | @project.reload |
|
329 | @project.reload | |
332 | assert_equal NUM_REV, @repository.changesets.count |
|
330 | assert_equal NUM_REV, @repository.changesets.count | |
333 | get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c'] |
|
331 | get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c'] | |
334 | assert_response :success |
|
332 | assert_response :success | |
335 | assert_template 'annotate' |
|
333 | assert_template 'annotate' | |
336 | assert_tag :tag => 'h2', :content => /@ 8/ |
|
334 | assert_tag :tag => 'h2', :content => /@ 8/ | |
337 | end |
|
335 | end | |
338 |
|
336 | |||
339 | def test_destroy_valid_repository |
|
337 | def test_destroy_valid_repository | |
340 | @request.session[:user_id] = 1 # admin |
|
338 | @request.session[:user_id] = 1 # admin | |
341 | assert_equal 0, @repository.changesets.count |
|
339 | assert_equal 0, @repository.changesets.count | |
342 | @repository.fetch_changesets |
|
340 | @repository.fetch_changesets | |
343 | @project.reload |
|
341 | @project.reload | |
344 | assert_equal NUM_REV, @repository.changesets.count |
|
342 | assert_equal NUM_REV, @repository.changesets.count | |
345 |
|
343 | |||
346 | get :destroy, :id => PRJ_ID |
|
344 | get :destroy, :id => PRJ_ID | |
347 | assert_response 302 |
|
345 | assert_response 302 | |
348 | @project.reload |
|
346 | @project.reload | |
349 | assert_nil @project.repository |
|
347 | assert_nil @project.repository | |
350 | end |
|
348 | end | |
351 |
|
349 | |||
352 | def test_destroy_invalid_repository |
|
350 | def test_destroy_invalid_repository | |
353 | @request.session[:user_id] = 1 # admin |
|
351 | @request.session[:user_id] = 1 # admin | |
354 | assert_equal 0, @repository.changesets.count |
|
352 | assert_equal 0, @repository.changesets.count | |
355 | @repository.fetch_changesets |
|
353 | @repository.fetch_changesets | |
356 | @project.reload |
|
354 | @project.reload | |
357 | assert_equal NUM_REV, @repository.changesets.count |
|
355 | assert_equal NUM_REV, @repository.changesets.count | |
358 |
|
356 | |||
359 | get :destroy, :id => PRJ_ID |
|
357 | get :destroy, :id => PRJ_ID | |
360 | assert_response 302 |
|
358 | assert_response 302 | |
361 | @project.reload |
|
359 | @project.reload | |
362 | assert_nil @project.repository |
|
360 | assert_nil @project.repository | |
363 |
|
361 | |||
364 | @repository = Repository::Subversion.create( |
|
362 | @repository = Repository::Subversion.create( | |
365 | :project => @project, |
|
363 | :project => @project, | |
366 | :url => "file:///invalid") |
|
364 | :url => "file:///invalid") | |
367 | assert @repository |
|
365 | assert @repository | |
368 | @repository.fetch_changesets |
|
366 | @repository.fetch_changesets | |
369 | @project.reload |
|
367 | @project.reload | |
370 | assert_equal 0, @repository.changesets.count |
|
368 | assert_equal 0, @repository.changesets.count | |
371 |
|
369 | |||
372 | get :destroy, :id => PRJ_ID |
|
370 | get :destroy, :id => PRJ_ID | |
373 | assert_response 302 |
|
371 | assert_response 302 | |
374 | @project.reload |
|
372 | @project.reload | |
375 | assert_nil @project.repository |
|
373 | assert_nil @project.repository | |
376 | end |
|
374 | end | |
377 | else |
|
375 | else | |
378 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" |
|
376 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" | |
379 | def test_fake; assert true end |
|
377 | def test_fake; assert true end | |
380 | end |
|
378 | end | |
381 | end |
|
379 | end |
General Comments 0
You need to be logged in to leave comments.
Login now