Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/repositories_subversion_controller_test.rb.svn-base @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 051f544170fe |
children |
comparison
equal
deleted
inserted
replaced
245:051f544170fe | 441:cbce1fd3b1b7 |
---|---|
1 # redMine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2008 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__) |
35 Setting.default_language = 'en' | 35 Setting.default_language = 'en' |
36 User.current = nil | 36 User.current = nil |
37 | 37 |
38 @project = Project.find(PRJ_ID) | 38 @project = Project.find(PRJ_ID) |
39 @repository = Repository::Subversion.create(:project => @project, | 39 @repository = Repository::Subversion.create(:project => @project, |
40 :url => "file://#{self.class.repository_path('subversion')}") | 40 :url => self.class.subversion_repository_url) |
41 assert @repository | 41 assert @repository |
42 end | 42 end |
43 | 43 |
44 if repository_configured?('subversion') | 44 if repository_configured?('subversion') |
45 def test_show | 45 def test_show |
49 assert_response :success | 49 assert_response :success |
50 assert_template 'show' | 50 assert_template 'show' |
51 assert_not_nil assigns(:entries) | 51 assert_not_nil assigns(:entries) |
52 assert_not_nil assigns(:changesets) | 52 assert_not_nil assigns(:changesets) |
53 end | 53 end |
54 | 54 |
55 def test_browse_root | 55 def test_browse_root |
56 @repository.fetch_changesets | 56 @repository.fetch_changesets |
57 @repository.reload | 57 @repository.reload |
58 get :show, :id => PRJ_ID | 58 get :show, :id => PRJ_ID |
59 assert_response :success | 59 assert_response :success |
60 assert_template 'show' | 60 assert_template 'show' |
61 assert_not_nil assigns(:entries) | 61 assert_not_nil assigns(:entries) |
62 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} | 62 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} |
63 assert_equal 'dir', entry.kind | 63 assert_equal 'dir', entry.kind |
64 end | 64 end |
65 | 65 |
66 def test_browse_directory | 66 def test_browse_directory |
67 @repository.fetch_changesets | 67 @repository.fetch_changesets |
68 @repository.reload | 68 @repository.reload |
69 get :show, :id => PRJ_ID, :path => ['subversion_test'] | 69 get :show, :id => PRJ_ID, :path => ['subversion_test'] |
70 assert_response :success | 70 assert_response :success |
71 assert_template 'show' | 71 assert_template 'show' |
72 assert_not_nil assigns(:entries) | 72 assert_not_nil assigns(:entries) |
73 assert_equal ['[folder_with_brackets]', 'folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name) | 73 assert_equal ['[folder_with_brackets]', 'folder', '.project', 'helloworld.c', 'textfile.txt'], |
74 assigns(:entries).collect(&:name) | |
74 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} | 75 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} |
75 assert_equal 'file', entry.kind | 76 assert_equal 'file', entry.kind |
76 assert_equal 'subversion_test/helloworld.c', entry.path | 77 assert_equal 'subversion_test/helloworld.c', entry.path |
77 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } | 78 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } |
78 end | 79 end |
82 @repository.reload | 83 @repository.reload |
83 get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4 | 84 get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4 |
84 assert_response :success | 85 assert_response :success |
85 assert_template 'show' | 86 assert_template 'show' |
86 assert_not_nil assigns(:entries) | 87 assert_not_nil assigns(:entries) |
87 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], assigns(:entries).collect(&:name) | 88 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], |
88 end | 89 assigns(:entries).collect(&:name) |
89 | 90 end |
91 | |
90 def test_file_changes | 92 def test_file_changes |
91 @repository.fetch_changesets | 93 @repository.fetch_changesets |
92 @repository.reload | 94 @repository.reload |
93 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ] | 95 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ] |
94 assert_response :success | 96 assert_response :success |
95 assert_template 'changes' | 97 assert_template 'changes' |
96 | 98 |
97 changesets = assigns(:changesets) | 99 changesets = assigns(:changesets) |
98 assert_not_nil changesets | 100 assert_not_nil changesets |
99 assert_equal %w(6 3 2), changesets.collect(&:revision) | 101 assert_equal %w(6 3 2), changesets.collect(&:revision) |
100 | 102 |
101 # svn properties displayed with svn >= 1.5 only | 103 # svn properties displayed with svn >= 1.5 only |
102 if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) | 104 if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) |
103 assert_not_nil assigns(:properties) | 105 assert_not_nil assigns(:properties) |
104 assert_equal 'native', assigns(:properties)['svn:eol-style'] | 106 assert_equal 'native', assigns(:properties)['svn:eol-style'] |
105 assert_tag :ul, | 107 assert_tag :ul, |
113 @repository.fetch_changesets | 115 @repository.fetch_changesets |
114 @repository.reload | 116 @repository.reload |
115 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ] | 117 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ] |
116 assert_response :success | 118 assert_response :success |
117 assert_template 'changes' | 119 assert_template 'changes' |
118 | 120 |
119 changesets = assigns(:changesets) | 121 changesets = assigns(:changesets) |
120 assert_not_nil changesets | 122 assert_not_nil changesets |
121 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) | 123 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) |
122 end | 124 end |
123 | 125 |
124 def test_entry | 126 def test_entry |
125 @repository.fetch_changesets | 127 @repository.fetch_changesets |
126 @repository.reload | 128 @repository.reload |
127 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | 129 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
128 assert_response :success | 130 assert_response :success |
129 assert_template 'entry' | 131 assert_template 'entry' |
130 end | 132 end |
131 | 133 |
132 def test_entry_should_send_if_too_big | 134 def test_entry_should_send_if_too_big |
133 @repository.fetch_changesets | 135 @repository.fetch_changesets |
134 @repository.reload | 136 @repository.reload |
135 # no files in the test repo is larger than 1KB... | 137 # no files in the test repo is larger than 1KB... |
136 with_settings :file_max_size_displayed => 0 do | 138 with_settings :file_max_size_displayed => 0 do |
138 assert_response :success | 140 assert_response :success |
139 assert_template '' | 141 assert_template '' |
140 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | 142 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] |
141 end | 143 end |
142 end | 144 end |
143 | 145 |
144 def test_entry_at_given_revision | 146 def test_entry_at_given_revision |
145 @repository.fetch_changesets | 147 @repository.fetch_changesets |
146 @repository.reload | 148 @repository.reload |
147 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 | 149 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 |
148 assert_response :success | 150 assert_response :success |
149 assert_template 'entry' | 151 assert_template 'entry' |
150 # this line was removed in r3 and file was moved in r6 | 152 # this line was removed in r3 and file was moved in r6 |
151 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, | 153 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, |
152 :content => /Here's the code/ | 154 :content => /Here's the code/ |
153 end | 155 end |
154 | 156 |
155 def test_entry_not_found | 157 def test_entry_not_found |
156 @repository.fetch_changesets | 158 @repository.fetch_changesets |
157 @repository.reload | 159 @repository.reload |
158 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c'] | 160 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c'] |
159 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | 161 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
160 :content => /The entry or revision was not found in the repository/ | 162 :content => /The entry or revision was not found in the repository/ |
161 end | 163 end |
162 | 164 |
163 def test_entry_download | 165 def test_entry_download |
164 @repository.fetch_changesets | 166 @repository.fetch_changesets |
165 @repository.reload | 167 @repository.reload |
166 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' | 168 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' |
167 assert_response :success | 169 assert_response :success |
168 assert_template '' | 170 assert_template '' |
169 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | 171 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] |
170 end | 172 end |
171 | 173 |
172 def test_directory_entry | 174 def test_directory_entry |
173 @repository.fetch_changesets | 175 @repository.fetch_changesets |
174 @repository.reload | 176 @repository.reload |
175 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder'] | 177 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder'] |
176 assert_response :success | 178 assert_response :success |
177 assert_template 'show' | 179 assert_template 'show' |
178 assert_not_nil assigns(:entry) | 180 assert_not_nil assigns(:entry) |
179 assert_equal 'folder', assigns(:entry).name | 181 assert_equal 'folder', assigns(:entry).name |
180 end | 182 end |
181 | 183 |
182 # TODO: this test needs fixtures. | 184 # TODO: this test needs fixtures. |
183 def test_revision | 185 def test_revision |
184 @repository.fetch_changesets | 186 @repository.fetch_changesets |
185 @repository.reload | 187 @repository.reload |
186 get :revision, :id => 1, :rev => 2 | 188 get :revision, :id => 1, :rev => 2 |
187 assert_response :success | 189 assert_response :success |
188 assert_template 'revision' | 190 assert_template 'revision' |
189 assert_tag :tag => 'ul', | 191 assert_tag :tag => 'ul', |
190 :child => { :tag => 'li', | 192 :child => { :tag => 'li', |
191 # link to the entry at rev 2 | 193 # link to the entry at rev 2 |
192 :child => { :tag => 'a', | 194 :child => { :tag => 'a', |
193 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'}, | 195 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'}, |
194 :content => 'repo', | 196 :content => 'repo', |
195 # link to partial diff | 197 # link to partial diff |
196 :sibling => { :tag => 'a', | 198 :sibling => { :tag => 'a', |
197 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' } | 199 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' } |
198 } | 200 } |
199 } | 201 } |
200 } | 202 } |
201 end | 203 end |
202 | 204 |
203 def test_invalid_revision | 205 def test_invalid_revision |
204 @repository.fetch_changesets | 206 @repository.fetch_changesets |
205 @repository.reload | 207 @repository.reload |
206 get :revision, :id => PRJ_ID, :rev => 'something_weird' | 208 get :revision, :id => PRJ_ID, :rev => 'something_weird' |
207 assert_response 404 | 209 assert_response 404 |
227 # TODO: this test needs fixtures. | 229 # TODO: this test needs fixtures. |
228 def test_revision_with_repository_pointing_to_a_subdirectory | 230 def test_revision_with_repository_pointing_to_a_subdirectory |
229 r = Project.find(1).repository | 231 r = Project.find(1).repository |
230 # Changes repository url to a subdirectory | 232 # Changes repository url to a subdirectory |
231 r.update_attribute :url, (r.url + '/test/some') | 233 r.update_attribute :url, (r.url + '/test/some') |
232 | 234 |
233 get :revision, :id => 1, :rev => 2 | 235 get :revision, :id => 1, :rev => 2 |
234 assert_response :success | 236 assert_response :success |
235 assert_template 'revision' | 237 assert_template 'revision' |
236 assert_tag :tag => 'ul', | 238 assert_tag :tag => 'ul', |
237 :child => { :tag => 'li', | 239 :child => { :tag => 'li', |
238 # link to the entry at rev 2 | 240 # link to the entry at rev 2 |
239 :child => { :tag => 'a', | 241 :child => { :tag => 'a', |
240 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'}, | 242 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'}, |
241 :content => 'repo', | 243 :content => 'repo', |
242 # link to partial diff | 244 # link to partial diff |
243 :sibling => { :tag => 'a', | 245 :sibling => { :tag => 'a', |
244 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' } | 246 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' } |
245 } | 247 } |
246 } | 248 } |
247 } | 249 } |
248 end | 250 end |
249 | 251 |
250 def test_revision_diff | 252 def test_revision_diff |
251 @repository.fetch_changesets | 253 @repository.fetch_changesets |
252 @repository.reload | 254 @repository.reload |
253 get :diff, :id => PRJ_ID, :rev => 3 | 255 get :diff, :id => PRJ_ID, :rev => 3 |
254 assert_response :success | 256 assert_response :success |
261 @repository.fetch_changesets | 263 @repository.fetch_changesets |
262 @repository.reload | 264 @repository.reload |
263 get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, :path => ['subversion_test', 'folder'] | 265 get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, :path => ['subversion_test', 'folder'] |
264 assert_response :success | 266 assert_response :success |
265 assert_template 'diff' | 267 assert_template 'diff' |
266 | 268 |
267 diff = assigns(:diff) | 269 diff = assigns(:diff) |
268 assert_not_nil diff | 270 assert_not_nil diff |
269 # 2 files modified | 271 # 2 files modified |
270 assert_equal 2, Redmine::UnifiedDiff.new(diff).size | 272 assert_equal 2, Redmine::UnifiedDiff.new(diff).size |
271 | 273 |
272 assert_tag :tag => 'h2', :content => /2:6/ | 274 assert_tag :tag => 'h2', :content => /2:6/ |
273 end | 275 end |
274 | 276 |
275 def test_annotate | 277 def test_annotate |
276 @repository.fetch_changesets | 278 @repository.fetch_changesets |
277 @repository.reload | 279 @repository.reload |
278 get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | 280 get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
279 assert_response :success | 281 assert_response :success |