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