actionpack 1.13.3 → 1.13.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (47) hide show
  1. data/CHANGELOG +44 -2
  2. data/Rakefile +1 -1
  3. data/lib/action_controller/assertions/dom_assertions.rb +2 -2
  4. data/lib/action_controller/assertions/model_assertions.rb +1 -1
  5. data/lib/action_controller/assertions/response_assertions.rb +2 -0
  6. data/lib/action_controller/assertions/routing_assertions.rb +1 -0
  7. data/lib/action_controller/base.rb +7 -1
  8. data/lib/action_controller/caching.rb +39 -38
  9. data/lib/action_controller/cgi_ext/pstore_performance_fix.rb +30 -0
  10. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +1 -1
  11. data/lib/action_controller/cgi_process.rb +13 -4
  12. data/lib/action_controller/cookies.rb +5 -3
  13. data/lib/action_controller/filters.rb +176 -77
  14. data/lib/action_controller/integration.rb +31 -21
  15. data/lib/action_controller/pagination.rb +7 -1
  16. data/lib/action_controller/resources.rb +117 -32
  17. data/lib/action_controller/routing.rb +41 -1
  18. data/lib/action_controller/test_process.rb +5 -2
  19. data/lib/action_controller/url_rewriter.rb +4 -1
  20. data/lib/action_controller/verification.rb +1 -0
  21. data/lib/action_pack/version.rb +1 -1
  22. data/lib/action_view/base.rb +25 -19
  23. data/lib/action_view/compiled_templates.rb +2 -2
  24. data/lib/action_view/helpers/active_record_helper.rb +18 -18
  25. data/lib/action_view/helpers/debug_helper.rb +10 -0
  26. data/lib/action_view/helpers/deprecated_helper.rb +3 -0
  27. data/lib/action_view/helpers/prototype_helper.rb +33 -17
  28. data/test/activerecord/pagination_test.rb +9 -0
  29. data/test/controller/addresses_render_test.rb +4 -1
  30. data/test/controller/base_test.rb +1 -1
  31. data/test/controller/caching_test.rb +3 -2
  32. data/test/controller/cookie_test.rb +11 -0
  33. data/test/controller/deprecation/deprecated_base_methods_test.rb +18 -0
  34. data/test/controller/filter_params_test.rb +1 -0
  35. data/test/controller/filters_test.rb +149 -26
  36. data/test/controller/integration_test.rb +93 -8
  37. data/test/controller/resources_test.rb +215 -36
  38. data/test/controller/routing_test.rb +1 -1
  39. data/test/controller/test_test.rb +16 -0
  40. data/test/controller/url_rewriter_test.rb +13 -1
  41. data/test/controller/verification_test.rb +15 -0
  42. data/test/fixtures/test/hello_world.rxml +2 -1
  43. data/test/template/asset_tag_helper_test.rb +5 -0
  44. data/test/template/compiled_templates_test.rb +29 -17
  45. data/test/template/number_helper_test.rb +1 -1
  46. data/test/template/prototype_helper_test.rb +2 -2
  47. metadata +84 -83
@@ -11,7 +11,7 @@ require 'stubba'
11
11
  module ActionController
12
12
  module Integration
13
13
  class Session
14
- def process
14
+ def process(*args)
15
15
  end
16
16
 
17
17
  def generic_url_rewriter
@@ -56,8 +56,7 @@ class SessionTest < Test::Unit::TestCase
56
56
 
57
57
  @session.expects(:get).with(path,args)
58
58
 
59
- redirects = [true, true, false]
60
- @session.stubs(:redirect?).returns(lambda { redirects.shift })
59
+ @session.stubs(:redirect?).returns(true).then.returns(true).then.returns(false)
61
60
  @session.expects(:follow_redirect!).times(2)
62
61
 
63
62
  @session.stubs(:status).returns(200)
@@ -69,8 +68,7 @@ class SessionTest < Test::Unit::TestCase
69
68
 
70
69
  @session.expects(:post).with(path,args)
71
70
 
72
- redirects = [true, true, false]
73
- @session.stubs(:redirect?).returns(lambda { redirects.shift })
71
+ @session.stubs(:redirect?).returns(true).then.returns(true).then.returns(false)
74
72
  @session.expects(:follow_redirect!).times(2)
75
73
 
76
74
  @session.stubs(:status).returns(200)
@@ -134,15 +132,102 @@ class SessionTest < Test::Unit::TestCase
134
132
  @session.head(path,params,headers)
135
133
  end
136
134
 
137
- def test_xml_http_request
135
+ def test_xml_http_request_deprecated_call
138
136
  path = "/index"; params = "blah"; headers = {:location => 'blah'}
139
137
  headers_after_xhr = headers.merge(
140
138
  "X-Requested-With" => "XMLHttpRequest",
141
139
  "Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
142
140
  )
143
- @session.expects(:post).with(path,params,headers_after_xhr)
144
- @session.xml_http_request(path,params,headers)
141
+ @session.expects(:process).with(:post,path,params,headers_after_xhr)
142
+ assert_deprecated { @session.xml_http_request(path,params,headers) }
145
143
  end
144
+
145
+ def test_xml_http_request_get
146
+ path = "/index"; params = "blah"; headers = {:location => 'blah'}
147
+ headers_after_xhr = headers.merge(
148
+ "X-Requested-With" => "XMLHttpRequest",
149
+ "Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
150
+ )
151
+ @session.expects(:process).with(:get,path,params,headers_after_xhr)
152
+ @session.xml_http_request(:get,path,params,headers)
153
+ end
154
+
155
+ def test_xml_http_request_post
156
+ path = "/index"; params = "blah"; headers = {:location => 'blah'}
157
+ headers_after_xhr = headers.merge(
158
+ "X-Requested-With" => "XMLHttpRequest",
159
+ "Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
160
+ )
161
+ @session.expects(:process).with(:post,path,params,headers_after_xhr)
162
+ @session.xml_http_request(:post,path,params,headers)
163
+ end
164
+
165
+ def test_xml_http_request_put
166
+ path = "/index"; params = "blah"; headers = {:location => 'blah'}
167
+ headers_after_xhr = headers.merge(
168
+ "X-Requested-With" => "XMLHttpRequest",
169
+ "Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
170
+ )
171
+ @session.expects(:process).with(:put,path,params,headers_after_xhr)
172
+ @session.xml_http_request(:put,path,params,headers)
173
+ end
174
+
175
+ def test_xml_http_request_delete
176
+ path = "/index"; params = "blah"; headers = {:location => 'blah'}
177
+ headers_after_xhr = headers.merge(
178
+ "X-Requested-With" => "XMLHttpRequest",
179
+ "Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
180
+ )
181
+ @session.expects(:process).with(:delete,path,params,headers_after_xhr)
182
+ @session.xml_http_request(:delete,path,params,headers)
183
+ end
184
+
185
+ def test_xml_http_request_head
186
+ path = "/index"; params = "blah"; headers = {:location => 'blah'}
187
+ headers_after_xhr = headers.merge(
188
+ "X-Requested-With" => "XMLHttpRequest",
189
+ "Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
190
+ )
191
+ @session.expects(:process).with(:head,path,params,headers_after_xhr)
192
+ @session.xml_http_request(:head,path,params,headers)
193
+ end
194
+ end
195
+
196
+ class IntegrationTestTest < Test::Unit::TestCase
197
+
198
+ def setup
199
+ @test = ::ActionController::IntegrationTest.new(:default_test)
200
+ @test.class.stubs(:fixture_table_names).returns([])
201
+ @session = @test.open_session
202
+ end
203
+
204
+ def test_opens_new_session
205
+ @test.class.expects(:fixture_table_names).times(2).returns(['foo'])
206
+
207
+ session1 = @test.open_session { |sess| }
208
+ session2 = @test.open_session # implicit session
209
+
210
+ assert_equal ::ActionController::Integration::Session, session1.class
211
+ assert_equal ::ActionController::Integration::Session, session2.class
212
+ assert_not_equal session1, session2
213
+ end
214
+
215
+ end
216
+
217
+ # Tests that integration tests don't call Controller test methods for processing.
218
+ # Integration tests have their own setup and teardown.
219
+ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
220
+
221
+ def self.fixture_table_names
222
+ []
223
+ end
224
+
225
+ def test_integration_methods_called
226
+ %w( get post head put delete ).each do |verb|
227
+ assert_nothing_raised("'#{verb}' should use integration test methods") { send(verb, '/') }
228
+ end
229
+ end
230
+
146
231
  end
147
232
 
148
233
  # TODO
@@ -10,8 +10,9 @@ class ThreadsController < ResourcesController; end
10
10
  class MessagesController < ResourcesController; end
11
11
  class CommentsController < ResourcesController; end
12
12
 
13
- class AccountController < ResourcesController; end
14
- class AdminController < ResourcesController; end
13
+ class AccountController < ResourcesController; end
14
+ class AdminController < ResourcesController; end
15
+ class ProductsController < ResourcesController; end
15
16
 
16
17
  class ResourcesTest < Test::Unit::TestCase
17
18
  def test_should_arrange_actions
@@ -63,13 +64,13 @@ class ResourcesTest < Test::Unit::TestCase
63
64
  end
64
65
  end
65
66
 
66
- def test_multile_with_path_prefix
67
+ def test_multiple_with_path_prefix
67
68
  with_restful_routing :messages, :comments, :path_prefix => '/thread/:thread_id' do
68
69
  assert_simply_restful_for :messages, :path_prefix => 'thread/5/', :options => { :thread_id => '5' }
69
70
  assert_simply_restful_for :comments, :path_prefix => 'thread/5/', :options => { :thread_id => '5' }
70
71
  end
71
72
  end
72
-
73
+
73
74
  def test_with_name_prefix
74
75
  with_restful_routing :messages, :name_prefix => 'post_' do
75
76
  assert_simply_restful_for :messages, :name_prefix => 'post_'
@@ -78,7 +79,7 @@ class ResourcesTest < Test::Unit::TestCase
78
79
 
79
80
  def test_with_collection_action
80
81
  rss_options = {:action => 'rss'}
81
- rss_path = "/messages;rss"
82
+ rss_path = "/messages/rss"
82
83
  actions = { 'a' => :put, 'b' => :post, 'c' => :delete }
83
84
 
84
85
  with_restful_routing :messages, :collection => { :rss => :get }.merge(actions) do
@@ -86,14 +87,14 @@ class ResourcesTest < Test::Unit::TestCase
86
87
  assert_routing rss_path, options.merge(rss_options)
87
88
 
88
89
  actions.each do |action, method|
89
- assert_recognizes(options.merge(:action => action), :path => "/messages;#{action}", :method => method)
90
+ assert_recognizes(options.merge(:action => action), :path => "/messages/#{action}", :method => method)
90
91
  end
91
92
  end
92
93
 
93
94
  assert_restful_named_routes_for :messages do |options|
94
95
  assert_named_route rss_path, :rss_messages_path, rss_options
95
96
  actions.keys.each do |action|
96
- assert_named_route "/messages;#{action}", "#{action}_messages_path", :action => action
97
+ assert_named_route "/messages/#{action}", "#{action}_messages_path", :action => action
97
98
  end
98
99
  end
99
100
  end
@@ -103,7 +104,7 @@ class ResourcesTest < Test::Unit::TestCase
103
104
  [:put, :post].each do |method|
104
105
  with_restful_routing :messages, :member => { :mark => method } do
105
106
  mark_options = {:action => 'mark', :id => '1'}
106
- mark_path = "/messages/1;mark"
107
+ mark_path = "/messages/1/mark"
107
108
  assert_restful_routes_for :messages do |options|
108
109
  assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method)
109
110
  end
@@ -120,7 +121,7 @@ class ResourcesTest < Test::Unit::TestCase
120
121
  with_restful_routing :messages, :member => { :mark => method, :unmark => method } do
121
122
  %w(mark unmark).each do |action|
122
123
  action_options = {:action => action, :id => '1'}
123
- action_path = "/messages/1;#{action}"
124
+ action_path = "/messages/1/#{action}"
124
125
  assert_restful_routes_for :messages do |options|
125
126
  assert_recognizes(options.merge(action_options), :path => action_path, :method => method)
126
127
  end
@@ -136,7 +137,7 @@ class ResourcesTest < Test::Unit::TestCase
136
137
  def test_with_new_action
137
138
  with_restful_routing :messages, :new => { :preview => :post } do
138
139
  preview_options = {:action => 'preview'}
139
- preview_path = "/messages/new;preview"
140
+ preview_path = "/messages/new/preview"
140
141
  assert_restful_routes_for :messages do |options|
141
142
  assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post)
142
143
  end
@@ -178,9 +179,11 @@ class ResourcesTest < Test::Unit::TestCase
178
179
  assert_simply_restful_for :threads
179
180
  assert_simply_restful_for :messages,
180
181
  :path_prefix => 'threads/1/',
182
+ :name_prefix => 'thread_',
181
183
  :options => { :thread_id => '1' }
182
184
  assert_simply_restful_for :comments,
183
185
  :path_prefix => 'threads/1/messages/2/',
186
+ :name_prefix => 'thread_message_',
184
187
  :options => { :thread_id => '1', :message_id => '2' }
185
188
  end
186
189
  end
@@ -217,9 +220,9 @@ class ResourcesTest < Test::Unit::TestCase
217
220
  admin.resource :account
218
221
  end
219
222
  end
220
-
223
+
221
224
  assert_singleton_restful_for :admin
222
- assert_singleton_restful_for :account, :path_prefix => 'admin/'
225
+ assert_singleton_restful_for :account, :path_prefix => 'admin/', :name_prefix => 'admin_'
223
226
  end
224
227
  end
225
228
 
@@ -227,7 +230,7 @@ class ResourcesTest < Test::Unit::TestCase
227
230
  [:put, :post].each do |method|
228
231
  with_singleton_resources :account, :member => { :reset => method } do
229
232
  reset_options = {:action => 'reset'}
230
- reset_path = "/account;reset"
233
+ reset_path = "/account/reset"
231
234
  assert_singleton_routes_for :account do |options|
232
235
  assert_recognizes(options.merge(reset_options), :path => reset_path, :method => method)
233
236
  end
@@ -244,7 +247,7 @@ class ResourcesTest < Test::Unit::TestCase
244
247
  with_singleton_resources :account, :member => { :reset => method, :disable => method } do
245
248
  %w(reset disable).each do |action|
246
249
  action_options = {:action => action}
247
- action_path = "/account;#{action}"
250
+ action_path = "/account/#{action}"
248
251
  assert_singleton_routes_for :account do |options|
249
252
  assert_recognizes(options.merge(action_options), :path => action_path, :method => method)
250
253
  end
@@ -264,9 +267,9 @@ class ResourcesTest < Test::Unit::TestCase
264
267
  account.resources :messages
265
268
  end
266
269
  end
267
-
270
+
268
271
  assert_singleton_restful_for :account
269
- assert_simply_restful_for :messages, :path_prefix => 'account/'
272
+ assert_simply_restful_for :messages, :path_prefix => 'account/', :name_prefix => 'account_'
270
273
  end
271
274
  end
272
275
 
@@ -279,10 +282,10 @@ class ResourcesTest < Test::Unit::TestCase
279
282
  end
280
283
 
281
284
  assert_singleton_restful_for :account, :path_prefix => '7/', :options => { :site_id => '7' }
282
- assert_simply_restful_for :messages, :path_prefix => '7/account/', :options => { :site_id => '7' }
285
+ assert_simply_restful_for :messages, :path_prefix => '7/account/', :name_prefix => 'account_', :options => { :site_id => '7' }
283
286
  end
284
287
  end
285
-
288
+
286
289
  def test_should_nest_singleton_resource_in_resources
287
290
  with_routing do |set|
288
291
  set.draw do |map|
@@ -290,9 +293,9 @@ class ResourcesTest < Test::Unit::TestCase
290
293
  thread.resource :admin
291
294
  end
292
295
  end
293
-
296
+
294
297
  assert_simply_restful_for :threads
295
- assert_singleton_restful_for :admin, :path_prefix => 'threads/5/', :options => { :thread_id => '5' }
298
+ assert_singleton_restful_for :admin, :path_prefix => 'threads/5/', :name_prefix => 'thread_', :options => { :thread_id => '5' }
296
299
  end
297
300
  end
298
301
 
@@ -312,6 +315,181 @@ class ResourcesTest < Test::Unit::TestCase
312
315
  end
313
316
  end
314
317
 
318
+ def test_resource_action_separator
319
+ with_routing do |set|
320
+ set.draw do |map|
321
+ map.resources :messages, :collection => {:search => :get}, :new => {:preview => :any}, :name_prefix => 'thread_', :path_prefix => '/threads/:thread_id'
322
+ map.resource :account, :member => {:login => :get}, :new => {:preview => :any}, :name_prefix => 'admin_', :path_prefix => '/admin'
323
+ end
324
+
325
+ action_separator = ActionController::Base.resource_action_separator
326
+
327
+ assert_simply_restful_for :messages, :name_prefix => 'thread_', :path_prefix => 'threads/1/', :options => { :thread_id => '1' }
328
+ assert_named_route "/threads/1/messages#{action_separator}search", "search_thread_messages_path", {}
329
+ assert_named_route "/threads/1/messages/new", "new_thread_message_path", {}
330
+ assert_named_route "/threads/1/messages/new#{action_separator}preview", "preview_new_thread_message_path", {}
331
+ assert_singleton_restful_for :account, :name_prefix => 'admin_', :path_prefix => 'admin/'
332
+ assert_named_route "/admin/account#{action_separator}login", "login_admin_account_path", {}
333
+ assert_named_route "/admin/account/new", "new_admin_account_path", {}
334
+ assert_named_route "/admin/account/new#{action_separator}preview", "preview_new_admin_account_path", {}
335
+ end
336
+ end
337
+
338
+ def test_new_style_named_routes_for_resource
339
+ with_routing do |set|
340
+ set.draw do |map|
341
+ map.resources :messages, :collection => {:search => :get}, :new => {:preview => :any}, :name_prefix => 'thread_', :path_prefix => '/threads/:thread_id'
342
+ end
343
+ assert_simply_restful_for :messages, :name_prefix => 'thread_', :path_prefix => 'threads/1/', :options => { :thread_id => '1' }
344
+ assert_named_route "/threads/1/messages/search", "search_thread_messages_path", {}
345
+ assert_named_route "/threads/1/messages/new", "new_thread_message_path", {}
346
+ assert_named_route "/threads/1/messages/new/preview", "preview_new_thread_message_path", {}
347
+ end
348
+ end
349
+
350
+ def test_new_style_named_routes_for_singleton_resource
351
+ with_routing do |set|
352
+ set.draw do |map|
353
+ map.resource :account, :member => {:login => :get}, :new => {:preview => :any}, :name_prefix => 'admin_', :path_prefix => '/admin'
354
+ end
355
+ assert_singleton_restful_for :account, :name_prefix => 'admin_', :path_prefix => 'admin/'
356
+ assert_named_route "/admin/account/login", "login_admin_account_path", {}
357
+ assert_named_route "/admin/account/new", "new_admin_account_path", {}
358
+ assert_named_route "/admin/account/new/preview", "preview_new_admin_account_path", {}
359
+ end
360
+ end
361
+
362
+ def test_should_add_deprecated_named_routes_for_resource
363
+ with_routing do |set|
364
+ set.draw do |map|
365
+ map.resources :messages, :collection => {:search => :get}, :new => {:preview => :any}, :name_prefix => 'thread_', :path_prefix => '/threads/:thread_id'
366
+ end
367
+ assert_simply_restful_for :messages, :name_prefix => 'thread_', :path_prefix => 'threads/1/', :options => { :thread_id => '1' }
368
+ assert_deprecated do
369
+ assert_named_route "/threads/1/messages/search", "thread_search_messages_path", {}
370
+ assert_named_route "/threads/1/messages/new", "thread_new_message_path", {}
371
+ assert_named_route "/threads/1/messages/new/preview", "thread_preview_new_message_path", {}
372
+ end
373
+ end
374
+ end
375
+
376
+ def test_should_add_deprecated_named_routes_for_singleton_resource
377
+ with_routing do |set|
378
+ set.draw do |map|
379
+ map.resource :account, :member => {:login => :get}, :new => {:preview => :any}, :name_prefix => 'admin_', :path_prefix => '/admin'
380
+ end
381
+ assert_singleton_restful_for :account, :name_prefix => 'admin_', :path_prefix => 'admin/'
382
+ assert_deprecated do
383
+ assert_named_route "/admin/account/login", "admin_login_account_path", {}
384
+ assert_named_route "/admin/account/new", "admin_new_account_path", {}
385
+ assert_named_route "/admin/account/new/preview", "admin_preview_new_account_path", {}
386
+ end
387
+ end
388
+ end
389
+
390
+ def test_should_add_deprecated_named_routes_for_nested_resources
391
+ with_routing do |set|
392
+ set.draw do |map|
393
+ map.resources :threads do |map|
394
+ map.resources :messages do |map|
395
+ map.resources :comments
396
+ end
397
+ end
398
+ end
399
+
400
+ assert_simply_restful_for :threads
401
+ assert_simply_restful_for :messages,
402
+ :path_prefix => 'threads/1/',
403
+ :name_prefix => 'thread_',
404
+ :options => { :thread_id => '1' }
405
+ assert_simply_restful_for :comments,
406
+ :path_prefix => 'threads/1/messages/2/',
407
+ :name_prefix => 'thread_message_',
408
+ :options => { :thread_id => '1', :message_id => '2' }
409
+
410
+ assert_deprecated do
411
+ assert_named_route "/threads/1/messages", "messages_path", {}
412
+ assert_named_route "/threads/1/messages/1", "message_path", {:thread_id => '1', :id => '1'}
413
+ assert_named_route "/threads/1/messages/new", "new_message_path", {:thread_id => '1'}
414
+ assert_named_route "/threads/1/messages/1/edit", "edit_message_path", {:thread_id => '1', :id => '1'}
415
+ end
416
+ end
417
+ end
418
+
419
+ def test_should_add_deprecated_named_routes_for_nested_singleton_resources
420
+ with_routing do |set|
421
+ set.draw do |map|
422
+ map.resource :admin do |admin|
423
+ admin.resource :account
424
+ end
425
+ end
426
+
427
+ assert_singleton_restful_for :admin
428
+ assert_singleton_restful_for :account, :path_prefix => 'admin/', :name_prefix => 'admin_'
429
+
430
+ assert_deprecated do
431
+ assert_named_route "/admin/account", "account_path", {}
432
+ assert_named_route "/admin/account/new", "new_account_path", {}
433
+ assert_named_route "/admin/account/edit", "edit_account_path", {}
434
+ end
435
+ end
436
+ end
437
+
438
+ def test_should_add_deprecated_named_routes_for_nested_resources_in_singleton_resource
439
+ with_routing do |set|
440
+ set.draw do |map|
441
+ map.resource :account do |account|
442
+ account.resources :messages
443
+ end
444
+ end
445
+
446
+ assert_singleton_restful_for :account
447
+ assert_simply_restful_for :messages, :path_prefix => 'account/', :name_prefix => 'account_'
448
+
449
+ assert_deprecated do
450
+ assert_named_route "/account/messages", "messages_path", {}
451
+ assert_named_route "/account/messages/1", "message_path", {:id => '1'}
452
+ assert_named_route "/account/messages/new", "new_message_path", {}
453
+ assert_named_route "/account/messages/1/edit", "edit_message_path", {:id => '1'}
454
+ end
455
+ end
456
+ end
457
+
458
+ def test_should_add_deprecated_named_routes_for_nested_singleton_resource_in_resources
459
+ with_routing do |set|
460
+ set.draw do |map|
461
+ map.resources :threads do |thread|
462
+ thread.resource :admin
463
+ end
464
+ end
465
+
466
+ assert_simply_restful_for :threads
467
+ assert_singleton_restful_for :admin, :path_prefix => 'threads/5/', :name_prefix => 'thread_', :options => { :thread_id => '5' }
468
+
469
+ assert_deprecated do
470
+ assert_named_route "/threads/5/admin", "admin_path", {}
471
+ assert_named_route "/threads/5/admin/new", "new_admin_path", {}
472
+ assert_named_route "/threads/5/admin/edit", "edit_admin_path", {}
473
+ end
474
+ end
475
+ end
476
+
477
+ def test_should_add_deprecated_formatted_routes
478
+ with_routing do |set|
479
+ set.draw do |map|
480
+ map.resources :products, :collection => { :specials => :get }, :member => { :thumbnail => :get }
481
+ map.resource :account, :member => { :icon => :get }
482
+ end
483
+ assert_restful_routes_for :products do |options|
484
+ assert_recognizes options.merge({ :action => 'specials', :format => 'xml' }), :path => '/products.xml;specials', :method => :get
485
+ assert_recognizes options.merge({ :action => 'thumbnail', :format => 'jpg', :id => '1' }), :path => '/products/1.jpg;thumbnail', :method => :get
486
+ end
487
+ assert_singleton_restful_for :account do |options|
488
+ assert_recognizes options.merge({ :action => 'icon', :format => 'jpg' }), :path => '/account.jpg;icon', :method => :get
489
+ end
490
+ end
491
+ end
492
+
315
493
  protected
316
494
  def with_restful_routing(*args)
317
495
  with_routing do |set|
@@ -319,7 +497,7 @@ class ResourcesTest < Test::Unit::TestCase
319
497
  yield
320
498
  end
321
499
  end
322
-
500
+
323
501
  def with_singleton_resources(*args)
324
502
  with_routing do |set|
325
503
  set.draw { |map| map.resource(*args) }
@@ -344,8 +522,8 @@ class ResourcesTest < Test::Unit::TestCase
344
522
  collection_path = "/#{options[:path_prefix]}#{controller_name}"
345
523
  member_path = "#{collection_path}/1"
346
524
  new_path = "#{collection_path}/new"
347
- edit_member_path = "#{member_path};edit"
348
- formatted_edit_member_path = "#{member_path}.xml;edit"
525
+ edit_member_path = "#{member_path}/edit"
526
+ formatted_edit_member_path = "#{member_path}/edit.xml"
349
527
 
350
528
  with_options(options[:options]) do |controller|
351
529
  controller.assert_routing collection_path, :action => 'index'
@@ -395,13 +573,13 @@ class ResourcesTest < Test::Unit::TestCase
395
573
  name_prefix = options[:name_prefix]
396
574
 
397
575
  assert_named_route "#{full_prefix}", "#{name_prefix}#{controller_name}_path", options[:options]
398
- assert_named_route "#{full_prefix}/new", "#{name_prefix}new_#{singular_name}_path", options[:options]
576
+ assert_named_route "#{full_prefix}/new", "new_#{name_prefix}#{singular_name}_path", options[:options]
399
577
  assert_named_route "#{full_prefix}/1", "#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1')
400
- assert_named_route "#{full_prefix}/1;edit", "#{name_prefix}edit_#{singular_name}_path", options[:options].merge(:id => '1')
578
+ assert_named_route "#{full_prefix}/1/edit", "edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1')
401
579
  assert_named_route "#{full_prefix}.xml", "formatted_#{name_prefix}#{controller_name}_path", options[:options].merge( :format => 'xml')
402
- assert_named_route "#{full_prefix}/new.xml", "formatted_#{name_prefix}new_#{singular_name}_path", options[:options].merge( :format => 'xml')
580
+ assert_named_route "#{full_prefix}/new.xml", "formatted_new_#{name_prefix}#{singular_name}_path", options[:options].merge( :format => 'xml')
403
581
  assert_named_route "#{full_prefix}/1.xml", "formatted_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
404
- assert_named_route "#{full_prefix}/1.xml;edit", "formatted_#{name_prefix}edit_#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
582
+ assert_named_route "#{full_prefix}/1/edit.xml", "formatted_edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
405
583
  yield options[:options] if block_given?
406
584
  end
407
585
 
@@ -410,8 +588,8 @@ class ResourcesTest < Test::Unit::TestCase
410
588
 
411
589
  full_path = "/#{options[:path_prefix]}#{singleton_name}"
412
590
  new_path = "#{full_path}/new"
413
- edit_path = "#{full_path};edit"
414
- formatted_edit_path = "#{full_path}.xml;edit"
591
+ edit_path = "#{full_path}/edit"
592
+ formatted_edit_path = "#{full_path}/edit.xml"
415
593
 
416
594
  with_options options[:options] do |controller|
417
595
  controller.assert_routing full_path, :action => 'show'
@@ -448,13 +626,14 @@ class ResourcesTest < Test::Unit::TestCase
448
626
  options[:options].delete :action
449
627
 
450
628
  full_path = "/#{options[:path_prefix]}#{singleton_name}"
451
-
452
- assert_named_route "#{full_path}", "#{singleton_name}_path", options[:options]
453
- assert_named_route "#{full_path}/new", "new_#{singleton_name}_path", options[:options]
454
- assert_named_route "#{full_path};edit", "edit_#{singleton_name}_path", options[:options]
455
- assert_named_route "#{full_path}.xml", "formatted_#{singleton_name}_path", options[:options].merge(:format => 'xml')
456
- assert_named_route "#{full_path}/new.xml", "formatted_new_#{singleton_name}_path", options[:options].merge(:format => 'xml')
457
- assert_named_route "#{full_path}.xml;edit", "formatted_edit_#{singleton_name}_path", options[:options].merge(:format => 'xml')
629
+ full_name = "#{options[:name_prefix]}#{singleton_name}"
630
+
631
+ assert_named_route "#{full_path}", "#{full_name}_path", options[:options]
632
+ assert_named_route "#{full_path}/new", "new_#{full_name}_path", options[:options]
633
+ assert_named_route "#{full_path}/edit", "edit_#{full_name}_path", options[:options]
634
+ assert_named_route "#{full_path}.xml", "formatted_#{full_name}_path", options[:options].merge(:format => 'xml')
635
+ assert_named_route "#{full_path}/new.xml", "formatted_new_#{full_name}_path", options[:options].merge(:format => 'xml')
636
+ assert_named_route "#{full_path}/edit.xml", "formatted_edit_#{full_name}_path", options[:options].merge(:format => 'xml')
458
637
  end
459
638
 
460
639
  def assert_named_route(expected, route, options)