@@ -1,363 +1,365 | |||||
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 | @repository.fetch_changesets |
|
73 | @repository.fetch_changesets | |
73 |
@ |
|
74 | @project.reload | |
|
75 | assert_equal NUM_REV, @repository.changesets.count | |||
74 | get :show, :id => PRJ_ID, :path => ['subversion_test'] |
|
76 | get :show, :id => PRJ_ID, :path => ['subversion_test'] | |
75 | assert_response :success |
|
77 | assert_response :success | |
76 | assert_template 'show' |
|
78 | assert_template 'show' | |
77 | assert_not_nil assigns(:entries) |
|
79 | assert_not_nil assigns(:entries) | |
78 | assert_equal [ |
|
80 | assert_equal [ | |
79 | '[folder_with_brackets]', 'folder', '.project', |
|
81 | '[folder_with_brackets]', 'folder', '.project', | |
80 | 'helloworld.c', 'textfile.txt' |
|
82 | 'helloworld.c', 'textfile.txt' | |
81 | ], |
|
83 | ], | |
82 | assigns(:entries).collect(&:name) |
|
84 | assigns(:entries).collect(&:name) | |
83 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} |
|
85 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} | |
84 | assert_equal 'file', entry.kind |
|
86 | assert_equal 'file', entry.kind | |
85 | assert_equal 'subversion_test/helloworld.c', entry.path |
|
87 | assert_equal 'subversion_test/helloworld.c', entry.path | |
86 | assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } |
|
88 | assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } | |
87 | end |
|
89 | end | |
88 |
|
90 | |||
89 | def test_browse_at_given_revision |
|
91 | def test_browse_at_given_revision | |
90 | @repository.fetch_changesets |
|
92 | @repository.fetch_changesets | |
91 | @repository.reload |
|
93 | @repository.reload | |
92 | get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4 |
|
94 | get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4 | |
93 | assert_response :success |
|
95 | assert_response :success | |
94 | assert_template 'show' |
|
96 | assert_template 'show' | |
95 | assert_not_nil assigns(:entries) |
|
97 | assert_not_nil assigns(:entries) | |
96 | assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], |
|
98 | assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], | |
97 | assigns(:entries).collect(&:name) |
|
99 | assigns(:entries).collect(&:name) | |
98 | end |
|
100 | end | |
99 |
|
101 | |||
100 | def test_file_changes |
|
102 | def test_file_changes | |
101 | @repository.fetch_changesets |
|
103 | @repository.fetch_changesets | |
102 | @repository.reload |
|
104 | @repository.reload | |
103 | get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ] |
|
105 | get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ] | |
104 | assert_response :success |
|
106 | assert_response :success | |
105 | assert_template 'changes' |
|
107 | assert_template 'changes' | |
106 |
|
108 | |||
107 | changesets = assigns(:changesets) |
|
109 | changesets = assigns(:changesets) | |
108 | assert_not_nil changesets |
|
110 | assert_not_nil changesets | |
109 | assert_equal %w(6 3 2), changesets.collect(&:revision) |
|
111 | assert_equal %w(6 3 2), changesets.collect(&:revision) | |
110 |
|
112 | |||
111 | # svn properties displayed with svn >= 1.5 only |
|
113 | # svn properties displayed with svn >= 1.5 only | |
112 | if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) |
|
114 | if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) | |
113 | assert_not_nil assigns(:properties) |
|
115 | assert_not_nil assigns(:properties) | |
114 | assert_equal 'native', assigns(:properties)['svn:eol-style'] |
|
116 | assert_equal 'native', assigns(:properties)['svn:eol-style'] | |
115 | assert_tag :ul, |
|
117 | assert_tag :ul, | |
116 | :child => { :tag => 'li', |
|
118 | :child => { :tag => 'li', | |
117 | :child => { :tag => 'b', :content => 'svn:eol-style' }, |
|
119 | :child => { :tag => 'b', :content => 'svn:eol-style' }, | |
118 | :child => { :tag => 'span', :content => 'native' } } |
|
120 | :child => { :tag => 'span', :content => 'native' } } | |
119 | end |
|
121 | end | |
120 | end |
|
122 | end | |
121 |
|
123 | |||
122 | def test_directory_changes |
|
124 | def test_directory_changes | |
123 | @repository.fetch_changesets |
|
125 | @repository.fetch_changesets | |
124 | @repository.reload |
|
126 | @repository.reload | |
125 | get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ] |
|
127 | get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ] | |
126 | assert_response :success |
|
128 | assert_response :success | |
127 | assert_template 'changes' |
|
129 | assert_template 'changes' | |
128 |
|
130 | |||
129 | changesets = assigns(:changesets) |
|
131 | changesets = assigns(:changesets) | |
130 | assert_not_nil changesets |
|
132 | assert_not_nil changesets | |
131 | assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) |
|
133 | assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) | |
132 | end |
|
134 | end | |
133 |
|
135 | |||
134 | def test_entry |
|
136 | def test_entry | |
135 | @repository.fetch_changesets |
|
137 | @repository.fetch_changesets | |
136 | @repository.reload |
|
138 | @repository.reload | |
137 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
|
139 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | |
138 | assert_response :success |
|
140 | assert_response :success | |
139 | assert_template 'entry' |
|
141 | assert_template 'entry' | |
140 | end |
|
142 | end | |
141 |
|
143 | |||
142 | def test_entry_should_send_if_too_big |
|
144 | def test_entry_should_send_if_too_big | |
143 | @repository.fetch_changesets |
|
145 | @repository.fetch_changesets | |
144 | @repository.reload |
|
146 | @repository.reload | |
145 | # no files in the test repo is larger than 1KB... |
|
147 | # no files in the test repo is larger than 1KB... | |
146 | with_settings :file_max_size_displayed => 0 do |
|
148 | with_settings :file_max_size_displayed => 0 do | |
147 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
|
149 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | |
148 | assert_response :success |
|
150 | assert_response :success | |
149 | assert_template '' |
|
151 | assert_template '' | |
150 | assert_equal 'attachment; filename="helloworld.c"', |
|
152 | assert_equal 'attachment; filename="helloworld.c"', | |
151 | @response.headers['Content-Disposition'] |
|
153 | @response.headers['Content-Disposition'] | |
152 | end |
|
154 | end | |
153 | end |
|
155 | end | |
154 |
|
156 | |||
155 | def test_entry_at_given_revision |
|
157 | def test_entry_at_given_revision | |
156 | @repository.fetch_changesets |
|
158 | @repository.fetch_changesets | |
157 | @repository.reload |
|
159 | @repository.reload | |
158 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 |
|
160 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 | |
159 | assert_response :success |
|
161 | assert_response :success | |
160 | assert_template 'entry' |
|
162 | assert_template 'entry' | |
161 | # this line was removed in r3 and file was moved in r6 |
|
163 | # this line was removed in r3 and file was moved in r6 | |
162 | assert_tag :tag => 'td', :attributes => { :class => /line-code/}, |
|
164 | assert_tag :tag => 'td', :attributes => { :class => /line-code/}, | |
163 | :content => /Here's the code/ |
|
165 | :content => /Here's the code/ | |
164 | end |
|
166 | end | |
165 |
|
167 | |||
166 | def test_entry_not_found |
|
168 | def test_entry_not_found | |
167 | @repository.fetch_changesets |
|
169 | @repository.fetch_changesets | |
168 | @repository.reload |
|
170 | @repository.reload | |
169 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c'] |
|
171 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c'] | |
170 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
172 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
171 | :content => /The entry or revision was not found in the repository/ |
|
173 | :content => /The entry or revision was not found in the repository/ | |
172 | end |
|
174 | end | |
173 |
|
175 | |||
174 | def test_entry_download |
|
176 | def test_entry_download | |
175 | @repository.fetch_changesets |
|
177 | @repository.fetch_changesets | |
176 | @repository.reload |
|
178 | @repository.reload | |
177 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' |
|
179 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' | |
178 | assert_response :success |
|
180 | assert_response :success | |
179 | assert_template '' |
|
181 | assert_template '' | |
180 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] |
|
182 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | |
181 | end |
|
183 | end | |
182 |
|
184 | |||
183 | def test_directory_entry |
|
185 | def test_directory_entry | |
184 | assert_equal 0, @repository.changesets.count |
|
186 | assert_equal 0, @repository.changesets.count | |
185 | @repository.fetch_changesets |
|
187 | @repository.fetch_changesets | |
186 | @project.reload |
|
188 | @project.reload | |
187 | assert_equal NUM_REV, @repository.changesets.count |
|
189 | assert_equal NUM_REV, @repository.changesets.count | |
188 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder'] |
|
190 | get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder'] | |
189 | assert_response :success |
|
191 | assert_response :success | |
190 | assert_template 'show' |
|
192 | assert_template 'show' | |
191 | assert_not_nil assigns(:entry) |
|
193 | assert_not_nil assigns(:entry) | |
192 | assert_equal 'folder', assigns(:entry).name |
|
194 | assert_equal 'folder', assigns(:entry).name | |
193 | end |
|
195 | end | |
194 |
|
196 | |||
195 | # TODO: this test needs fixtures. |
|
197 | # TODO: this test needs fixtures. | |
196 | def test_revision |
|
198 | def test_revision | |
197 | @repository.fetch_changesets |
|
199 | @repository.fetch_changesets | |
198 | @repository.reload |
|
200 | @repository.reload | |
199 | get :revision, :id => 1, :rev => 2 |
|
201 | get :revision, :id => 1, :rev => 2 | |
200 | assert_response :success |
|
202 | assert_response :success | |
201 | assert_template 'revision' |
|
203 | assert_template 'revision' | |
202 | assert_tag :tag => 'ul', |
|
204 | assert_tag :tag => 'ul', | |
203 | :child => { :tag => 'li', |
|
205 | :child => { :tag => 'li', | |
204 | # link to the entry at rev 2 |
|
206 | # link to the entry at rev 2 | |
205 | :child => { :tag => 'a', |
|
207 | :child => { :tag => 'a', | |
206 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'}, |
|
208 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'}, | |
207 | :content => 'repo', |
|
209 | :content => 'repo', | |
208 | # link to partial diff |
|
210 | # link to partial diff | |
209 | :sibling => { :tag => 'a', |
|
211 | :sibling => { :tag => 'a', | |
210 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' } |
|
212 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' } | |
211 | } |
|
213 | } | |
212 | } |
|
214 | } | |
213 | } |
|
215 | } | |
214 | end |
|
216 | end | |
215 |
|
217 | |||
216 | def test_invalid_revision |
|
218 | def test_invalid_revision | |
217 | assert_equal 0, @repository.changesets.count |
|
219 | assert_equal 0, @repository.changesets.count | |
218 | @repository.fetch_changesets |
|
220 | @repository.fetch_changesets | |
219 | @project.reload |
|
221 | @project.reload | |
220 | assert_equal NUM_REV, @repository.changesets.count |
|
222 | assert_equal NUM_REV, @repository.changesets.count | |
221 | get :revision, :id => PRJ_ID, :rev => 'something_weird' |
|
223 | get :revision, :id => PRJ_ID, :rev => 'something_weird' | |
222 | assert_response 404 |
|
224 | assert_response 404 | |
223 | assert_error_tag :content => /was not found/ |
|
225 | assert_error_tag :content => /was not found/ | |
224 | end |
|
226 | end | |
225 |
|
227 | |||
226 | def test_invalid_revision_diff |
|
228 | def test_invalid_revision_diff | |
227 | get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' |
|
229 | get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' | |
228 | assert_response 404 |
|
230 | assert_response 404 | |
229 | assert_error_tag :content => /was not found/ |
|
231 | assert_error_tag :content => /was not found/ | |
230 | end |
|
232 | end | |
231 |
|
233 | |||
232 | def test_empty_revision |
|
234 | def test_empty_revision | |
233 | assert_equal 0, @repository.changesets.count |
|
235 | assert_equal 0, @repository.changesets.count | |
234 | @repository.fetch_changesets |
|
236 | @repository.fetch_changesets | |
235 | @project.reload |
|
237 | @project.reload | |
236 | assert_equal NUM_REV, @repository.changesets.count |
|
238 | assert_equal NUM_REV, @repository.changesets.count | |
237 | ['', ' ', nil].each do |r| |
|
239 | ['', ' ', nil].each do |r| | |
238 | get :revision, :id => PRJ_ID, :rev => r |
|
240 | get :revision, :id => PRJ_ID, :rev => r | |
239 | assert_response 404 |
|
241 | assert_response 404 | |
240 | assert_error_tag :content => /was not found/ |
|
242 | assert_error_tag :content => /was not found/ | |
241 | end |
|
243 | end | |
242 | end |
|
244 | end | |
243 |
|
245 | |||
244 | # TODO: this test needs fixtures. |
|
246 | # TODO: this test needs fixtures. | |
245 | def test_revision_with_repository_pointing_to_a_subdirectory |
|
247 | def test_revision_with_repository_pointing_to_a_subdirectory | |
246 | r = Project.find(1).repository |
|
248 | r = Project.find(1).repository | |
247 | # Changes repository url to a subdirectory |
|
249 | # Changes repository url to a subdirectory | |
248 | r.update_attribute :url, (r.url + '/test/some') |
|
250 | r.update_attribute :url, (r.url + '/test/some') | |
249 |
|
251 | |||
250 | get :revision, :id => 1, :rev => 2 |
|
252 | get :revision, :id => 1, :rev => 2 | |
251 | assert_response :success |
|
253 | assert_response :success | |
252 | assert_template 'revision' |
|
254 | assert_template 'revision' | |
253 | assert_tag :tag => 'ul', |
|
255 | assert_tag :tag => 'ul', | |
254 | :child => { :tag => 'li', |
|
256 | :child => { :tag => 'li', | |
255 | # link to the entry at rev 2 |
|
257 | # link to the entry at rev 2 | |
256 | :child => { :tag => 'a', |
|
258 | :child => { :tag => 'a', | |
257 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'}, |
|
259 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'}, | |
258 | :content => 'repo', |
|
260 | :content => 'repo', | |
259 | # link to partial diff |
|
261 | # link to partial diff | |
260 | :sibling => { :tag => 'a', |
|
262 | :sibling => { :tag => 'a', | |
261 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' } |
|
263 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' } | |
262 | } |
|
264 | } | |
263 | } |
|
265 | } | |
264 | } |
|
266 | } | |
265 | end |
|
267 | end | |
266 |
|
268 | |||
267 | def test_revision_diff |
|
269 | def test_revision_diff | |
268 | assert_equal 0, @repository.changesets.count |
|
270 | assert_equal 0, @repository.changesets.count | |
269 | @repository.fetch_changesets |
|
271 | @repository.fetch_changesets | |
270 | @project.reload |
|
272 | @project.reload | |
271 | assert_equal NUM_REV, @repository.changesets.count |
|
273 | assert_equal NUM_REV, @repository.changesets.count | |
272 | ['inline', 'sbs'].each do |dt| |
|
274 | ['inline', 'sbs'].each do |dt| | |
273 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt |
|
275 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt | |
274 | assert_response :success |
|
276 | assert_response :success | |
275 | assert_template 'diff' |
|
277 | assert_template 'diff' | |
276 | assert_tag :tag => 'h2', |
|
278 | assert_tag :tag => 'h2', | |
277 | :content => / 3/ |
|
279 | :content => / 3/ | |
278 | end |
|
280 | end | |
279 | end |
|
281 | end | |
280 |
|
282 | |||
281 | def test_directory_diff |
|
283 | def test_directory_diff | |
282 | assert_equal 0, @repository.changesets.count |
|
284 | assert_equal 0, @repository.changesets.count | |
283 | @repository.fetch_changesets |
|
285 | @repository.fetch_changesets | |
284 | @project.reload |
|
286 | @project.reload | |
285 | assert_equal NUM_REV, @repository.changesets.count |
|
287 | assert_equal NUM_REV, @repository.changesets.count | |
286 | ['inline', 'sbs'].each do |dt| |
|
288 | ['inline', 'sbs'].each do |dt| | |
287 | get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, |
|
289 | get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, | |
288 | :path => ['subversion_test', 'folder'], :type => dt |
|
290 | :path => ['subversion_test', 'folder'], :type => dt | |
289 | assert_response :success |
|
291 | assert_response :success | |
290 | assert_template 'diff' |
|
292 | assert_template 'diff' | |
291 |
|
293 | |||
292 | diff = assigns(:diff) |
|
294 | diff = assigns(:diff) | |
293 | assert_not_nil diff |
|
295 | assert_not_nil diff | |
294 | # 2 files modified |
|
296 | # 2 files modified | |
295 | assert_equal 2, Redmine::UnifiedDiff.new(diff).size |
|
297 | assert_equal 2, Redmine::UnifiedDiff.new(diff).size | |
296 | assert_tag :tag => 'h2', :content => /2:6/ |
|
298 | assert_tag :tag => 'h2', :content => /2:6/ | |
297 | end |
|
299 | end | |
298 | end |
|
300 | end | |
299 |
|
301 | |||
300 | def test_annotate |
|
302 | def test_annotate | |
301 | assert_equal 0, @repository.changesets.count |
|
303 | assert_equal 0, @repository.changesets.count | |
302 | @repository.fetch_changesets |
|
304 | @repository.fetch_changesets | |
303 | @project.reload |
|
305 | @project.reload | |
304 | assert_equal NUM_REV, @repository.changesets.count |
|
306 | assert_equal NUM_REV, @repository.changesets.count | |
305 | get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
|
307 | get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | |
306 | assert_response :success |
|
308 | assert_response :success | |
307 | assert_template 'annotate' |
|
309 | assert_template 'annotate' | |
308 | end |
|
310 | end | |
309 |
|
311 | |||
310 | def test_annotate_at_given_revision |
|
312 | def test_annotate_at_given_revision | |
311 | assert_equal 0, @repository.changesets.count |
|
313 | assert_equal 0, @repository.changesets.count | |
312 | @repository.fetch_changesets |
|
314 | @repository.fetch_changesets | |
313 | @project.reload |
|
315 | @project.reload | |
314 | assert_equal NUM_REV, @repository.changesets.count |
|
316 | assert_equal NUM_REV, @repository.changesets.count | |
315 | get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c'] |
|
317 | get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c'] | |
316 | assert_response :success |
|
318 | assert_response :success | |
317 | assert_template 'annotate' |
|
319 | assert_template 'annotate' | |
318 | assert_tag :tag => 'h2', :content => /@ 8/ |
|
320 | assert_tag :tag => 'h2', :content => /@ 8/ | |
319 | end |
|
321 | end | |
320 |
|
322 | |||
321 | def test_destroy_valid_repository |
|
323 | def test_destroy_valid_repository | |
322 | @request.session[:user_id] = 1 # admin |
|
324 | @request.session[:user_id] = 1 # admin | |
323 | assert_equal 0, @repository.changesets.count |
|
325 | assert_equal 0, @repository.changesets.count | |
324 | @repository.fetch_changesets |
|
326 | @repository.fetch_changesets | |
325 | @project.reload |
|
327 | @project.reload | |
326 | assert_equal NUM_REV, @repository.changesets.count |
|
328 | assert_equal NUM_REV, @repository.changesets.count | |
327 |
|
329 | |||
328 | get :destroy, :id => PRJ_ID |
|
330 | get :destroy, :id => PRJ_ID | |
329 | assert_response 302 |
|
331 | assert_response 302 | |
330 | @project.reload |
|
332 | @project.reload | |
331 | assert_nil @project.repository |
|
333 | assert_nil @project.repository | |
332 | end |
|
334 | end | |
333 |
|
335 | |||
334 | def test_destroy_invalid_repository |
|
336 | def test_destroy_invalid_repository | |
335 | @request.session[:user_id] = 1 # admin |
|
337 | @request.session[:user_id] = 1 # admin | |
336 | assert_equal 0, @repository.changesets.count |
|
338 | assert_equal 0, @repository.changesets.count | |
337 | @repository.fetch_changesets |
|
339 | @repository.fetch_changesets | |
338 | @project.reload |
|
340 | @project.reload | |
339 | assert_equal NUM_REV, @repository.changesets.count |
|
341 | assert_equal NUM_REV, @repository.changesets.count | |
340 |
|
342 | |||
341 | get :destroy, :id => PRJ_ID |
|
343 | get :destroy, :id => PRJ_ID | |
342 | assert_response 302 |
|
344 | assert_response 302 | |
343 | @project.reload |
|
345 | @project.reload | |
344 | assert_nil @project.repository |
|
346 | assert_nil @project.repository | |
345 |
|
347 | |||
346 | @repository = Repository::Subversion.create( |
|
348 | @repository = Repository::Subversion.create( | |
347 | :project => @project, |
|
349 | :project => @project, | |
348 | :url => "file:///invalid") |
|
350 | :url => "file:///invalid") | |
349 | assert @repository |
|
351 | assert @repository | |
350 | @repository.fetch_changesets |
|
352 | @repository.fetch_changesets | |
351 | @project.reload |
|
353 | @project.reload | |
352 | assert_equal 0, @repository.changesets.count |
|
354 | assert_equal 0, @repository.changesets.count | |
353 |
|
355 | |||
354 | get :destroy, :id => PRJ_ID |
|
356 | get :destroy, :id => PRJ_ID | |
355 | assert_response 302 |
|
357 | assert_response 302 | |
356 | @project.reload |
|
358 | @project.reload | |
357 | assert_nil @project.repository |
|
359 | assert_nil @project.repository | |
358 | end |
|
360 | end | |
359 | else |
|
361 | else | |
360 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" |
|
362 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" | |
361 | def test_fake; assert true end |
|
363 | def test_fake; assert true end | |
362 | end |
|
364 | end | |
363 | end |
|
365 | end |
General Comments 0
You need to be logged in to leave comments.
Login now