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