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