Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/repositories_subversion_controller_test.rb.svn-base @ 245:051f544170fe
* Update to SVN trunk revision 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 11:42:28 +0000 |
parents | 0579821a129a |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
244:8972b600f4fb | 245:051f544170fe |
---|---|
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 | |
30 | |
29 def setup | 31 def setup |
30 @controller = RepositoriesController.new | 32 @controller = RepositoriesController.new |
31 @request = ActionController::TestRequest.new | 33 @request = ActionController::TestRequest.new |
32 @response = ActionController::TestResponse.new | 34 @response = ActionController::TestResponse.new |
33 Setting.default_language = 'en' | 35 Setting.default_language = 'en' |
34 User.current = nil | 36 User.current = nil |
37 | |
38 @project = Project.find(PRJ_ID) | |
39 @repository = Repository::Subversion.create(:project => @project, | |
40 :url => "file://#{self.class.repository_path('subversion')}") | |
41 assert @repository | |
35 end | 42 end |
36 | 43 |
37 if repository_configured?('subversion') | 44 if repository_configured?('subversion') |
38 def test_show | 45 def test_show |
39 get :show, :id => 1 | 46 @repository.fetch_changesets |
47 @repository.reload | |
48 get :show, :id => PRJ_ID | |
40 assert_response :success | 49 assert_response :success |
41 assert_template 'show' | 50 assert_template 'show' |
42 assert_not_nil assigns(:entries) | 51 assert_not_nil assigns(:entries) |
43 assert_not_nil assigns(:changesets) | 52 assert_not_nil assigns(:changesets) |
44 end | 53 end |
45 | 54 |
46 def test_browse_root | 55 def test_browse_root |
47 get :show, :id => 1 | 56 @repository.fetch_changesets |
57 @repository.reload | |
58 get :show, :id => PRJ_ID | |
48 assert_response :success | 59 assert_response :success |
49 assert_template 'show' | 60 assert_template 'show' |
50 assert_not_nil assigns(:entries) | 61 assert_not_nil assigns(:entries) |
51 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} | 62 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} |
52 assert_equal 'dir', entry.kind | 63 assert_equal 'dir', entry.kind |
53 end | 64 end |
54 | 65 |
55 def test_browse_directory | 66 def test_browse_directory |
56 get :show, :id => 1, :path => ['subversion_test'] | 67 @repository.fetch_changesets |
68 @repository.reload | |
69 get :show, :id => PRJ_ID, :path => ['subversion_test'] | |
57 assert_response :success | 70 assert_response :success |
58 assert_template 'show' | 71 assert_template 'show' |
59 assert_not_nil assigns(:entries) | 72 assert_not_nil assigns(:entries) |
60 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'], assigns(:entries).collect(&:name) |
61 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} | 74 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} |
63 assert_equal 'subversion_test/helloworld.c', entry.path | 76 assert_equal 'subversion_test/helloworld.c', entry.path |
64 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } | 77 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } |
65 end | 78 end |
66 | 79 |
67 def test_browse_at_given_revision | 80 def test_browse_at_given_revision |
68 get :show, :id => 1, :path => ['subversion_test'], :rev => 4 | 81 @repository.fetch_changesets |
82 @repository.reload | |
83 get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4 | |
69 assert_response :success | 84 assert_response :success |
70 assert_template 'show' | 85 assert_template 'show' |
71 assert_not_nil assigns(:entries) | 86 assert_not_nil assigns(:entries) |
72 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], assigns(:entries).collect(&:name) | 87 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], assigns(:entries).collect(&:name) |
73 end | 88 end |
74 | 89 |
75 def test_file_changes | 90 def test_file_changes |
76 get :changes, :id => 1, :path => ['subversion_test', 'folder', 'helloworld.rb' ] | 91 @repository.fetch_changesets |
92 @repository.reload | |
93 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ] | |
77 assert_response :success | 94 assert_response :success |
78 assert_template 'changes' | 95 assert_template 'changes' |
79 | 96 |
80 changesets = assigns(:changesets) | 97 changesets = assigns(:changesets) |
81 assert_not_nil changesets | 98 assert_not_nil changesets |
91 :child => { :tag => 'span', :content => 'native' } } | 108 :child => { :tag => 'span', :content => 'native' } } |
92 end | 109 end |
93 end | 110 end |
94 | 111 |
95 def test_directory_changes | 112 def test_directory_changes |
96 get :changes, :id => 1, :path => ['subversion_test', 'folder' ] | 113 @repository.fetch_changesets |
114 @repository.reload | |
115 get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ] | |
97 assert_response :success | 116 assert_response :success |
98 assert_template 'changes' | 117 assert_template 'changes' |
99 | 118 |
100 changesets = assigns(:changesets) | 119 changesets = assigns(:changesets) |
101 assert_not_nil changesets | 120 assert_not_nil changesets |
102 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) | 121 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) |
103 end | 122 end |
104 | 123 |
105 def test_entry | 124 def test_entry |
106 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'] | 125 @repository.fetch_changesets |
126 @repository.reload | |
127 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | |
107 assert_response :success | 128 assert_response :success |
108 assert_template 'entry' | 129 assert_template 'entry' |
109 end | 130 end |
110 | 131 |
111 def test_entry_should_send_if_too_big | 132 def test_entry_should_send_if_too_big |
133 @repository.fetch_changesets | |
134 @repository.reload | |
112 # no files in the test repo is larger than 1KB... | 135 # no files in the test repo is larger than 1KB... |
113 with_settings :file_max_size_displayed => 0 do | 136 with_settings :file_max_size_displayed => 0 do |
114 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'] | 137 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] |
115 assert_response :success | 138 assert_response :success |
116 assert_template '' | 139 assert_template '' |
117 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | 140 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] |
118 end | 141 end |
119 end | 142 end |
120 | 143 |
121 def test_entry_at_given_revision | 144 def test_entry_at_given_revision |
122 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 | 145 @repository.fetch_changesets |
146 @repository.reload | |
147 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2 | |
123 assert_response :success | 148 assert_response :success |
124 assert_template 'entry' | 149 assert_template 'entry' |
125 # this line was removed in r3 and file was moved in r6 | 150 # this line was removed in r3 and file was moved in r6 |
126 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, | 151 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, |
127 :content => /Here's the code/ | 152 :content => /Here's the code/ |
128 end | 153 end |
129 | 154 |
130 def test_entry_not_found | 155 def test_entry_not_found |
131 get :entry, :id => 1, :path => ['subversion_test', 'zzz.c'] | 156 @repository.fetch_changesets |
157 @repository.reload | |
158 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c'] | |
132 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | 159 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
133 :content => /The entry or revision was not found in the repository/ | 160 :content => /The entry or revision was not found in the repository/ |
134 end | 161 end |
135 | 162 |
136 def test_entry_download | 163 def test_entry_download |
137 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' | 164 @repository.fetch_changesets |
165 @repository.reload | |
166 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' | |
138 assert_response :success | 167 assert_response :success |
139 assert_template '' | 168 assert_template '' |
140 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] | 169 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] |
141 end | 170 end |
142 | 171 |
143 def test_directory_entry | 172 def test_directory_entry |
144 get :entry, :id => 1, :path => ['subversion_test', 'folder'] | 173 @repository.fetch_changesets |
174 @repository.reload | |
175 get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder'] | |
145 assert_response :success | 176 assert_response :success |
146 assert_template 'show' | 177 assert_template 'show' |
147 assert_not_nil assigns(:entry) | 178 assert_not_nil assigns(:entry) |
148 assert_equal 'folder', assigns(:entry).name | 179 assert_equal 'folder', assigns(:entry).name |
149 end | 180 end |
150 | 181 |
182 # TODO: this test needs fixtures. | |
151 def test_revision | 183 def test_revision |
184 @repository.fetch_changesets | |
185 @repository.reload | |
152 get :revision, :id => 1, :rev => 2 | 186 get :revision, :id => 1, :rev => 2 |
153 assert_response :success | 187 assert_response :success |
154 assert_template 'revision' | 188 assert_template 'revision' |
155 assert_tag :tag => 'ul', | 189 assert_tag :tag => 'ul', |
156 :child => { :tag => 'li', | 190 :child => { :tag => 'li', |
165 } | 199 } |
166 } | 200 } |
167 end | 201 end |
168 | 202 |
169 def test_invalid_revision | 203 def test_invalid_revision |
170 get :revision, :id => 1, :rev => 'something_weird' | 204 @repository.fetch_changesets |
205 @repository.reload | |
206 get :revision, :id => PRJ_ID, :rev => 'something_weird' | |
171 assert_response 404 | 207 assert_response 404 |
172 assert_error_tag :content => /was not found/ | 208 assert_error_tag :content => /was not found/ |
173 end | 209 end |
174 | 210 |
211 def test_invalid_revision_diff | |
212 get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' | |
213 assert_response 404 | |
214 assert_error_tag :content => /was not found/ | |
215 end | |
216 | |
175 def test_empty_revision | 217 def test_empty_revision |
218 @repository.fetch_changesets | |
219 @repository.reload | |
176 ['', ' ', nil].each do |r| | 220 ['', ' ', nil].each do |r| |
177 get :revision, :id => 1, :rev => r | 221 get :revision, :id => PRJ_ID, :rev => r |
178 assert_response 404 | 222 assert_response 404 |
179 assert_error_tag :content => /was not found/ | 223 assert_error_tag :content => /was not found/ |
180 end | 224 end |
181 end | 225 end |
182 | 226 |
227 # TODO: this test needs fixtures. | |
183 def test_revision_with_repository_pointing_to_a_subdirectory | 228 def test_revision_with_repository_pointing_to_a_subdirectory |
184 r = Project.find(1).repository | 229 r = Project.find(1).repository |
185 # Changes repository url to a subdirectory | 230 # Changes repository url to a subdirectory |
186 r.update_attribute :url, (r.url + '/test/some') | 231 r.update_attribute :url, (r.url + '/test/some') |
187 | 232 |
201 } | 246 } |
202 } | 247 } |
203 end | 248 end |
204 | 249 |
205 def test_revision_diff | 250 def test_revision_diff |
206 get :diff, :id => 1, :rev => 3 | 251 @repository.fetch_changesets |
252 @repository.reload | |
253 get :diff, :id => PRJ_ID, :rev => 3 | |
207 assert_response :success | 254 assert_response :success |
208 assert_template 'diff' | 255 assert_template 'diff' |
209 | 256 |
210 assert_tag :tag => 'h2', :content => /3/ | 257 assert_tag :tag => 'h2', :content => /3/ |
211 end | 258 end |
212 | 259 |
213 def test_directory_diff | 260 def test_directory_diff |
214 get :diff, :id => 1, :rev => 6, :rev_to => 2, :path => ['subversion_test', 'folder'] | 261 @repository.fetch_changesets |
262 @repository.reload | |
263 get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, :path => ['subversion_test', 'folder'] | |
215 assert_response :success | 264 assert_response :success |
216 assert_template 'diff' | 265 assert_template 'diff' |
217 | 266 |
218 diff = assigns(:diff) | 267 diff = assigns(:diff) |
219 assert_not_nil diff | 268 assert_not_nil diff |
222 | 271 |
223 assert_tag :tag => 'h2', :content => /2:6/ | 272 assert_tag :tag => 'h2', :content => /2:6/ |
224 end | 273 end |
225 | 274 |
226 def test_annotate | 275 def test_annotate |
227 get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c'] | 276 @repository.fetch_changesets |
277 @repository.reload | |
278 get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'] | |
228 assert_response :success | 279 assert_response :success |
229 assert_template 'annotate' | 280 assert_template 'annotate' |
230 end | 281 end |
231 | 282 |
232 def test_annotate_at_given_revision | 283 def test_annotate_at_given_revision |
233 get :annotate, :id => 1, :rev => 8, :path => ['subversion_test', 'helloworld.c'] | 284 @repository.fetch_changesets |
285 @repository.reload | |
286 get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c'] | |
234 assert_response :success | 287 assert_response :success |
235 assert_template 'annotate' | 288 assert_template 'annotate' |
236 assert_tag :tag => 'h2', :content => /@ 8/ | 289 assert_tag :tag => 'h2', :content => /@ 8/ |
237 end | 290 end |
238 else | 291 else |