diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-12-03 19:30:35 +0100 |
---|---|---|
committer | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-12-03 19:30:35 +0100 |
commit | ccb96f2297e8783165cba764e9b5d51e1a15ff87 (patch) | |
tree | 3229e6fdddc42054615514d843c555e341003033 /actionpack/test/controller/url_rewriter_test.rb | |
parent | fb2325e35855d62abd2c76ce03feaa3ca7992e4f (diff) | |
parent | 761a633a9c0a45d76ef3ed10da97e3696c3ded79 (diff) | |
download | rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.tar.gz rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.tar.bz2 rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.zip |
Merge commit 'origin/master' into savepoints
Conflicts:
activerecord/lib/active_record/fixtures.rb
activerecord/test/cases/defaults_test.rb
Diffstat (limited to 'actionpack/test/controller/url_rewriter_test.rb')
-rw-r--r-- | actionpack/test/controller/url_rewriter_test.rb | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index 64e9a085ca..e9d372544e 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -2,7 +2,7 @@ require 'abstract_unit' ActionController::UrlRewriter -class UrlRewriterTests < Test::Unit::TestCase +class UrlRewriterTests < ActionController::TestCase def setup @request = ActionController::TestRequest.new @params = {} @@ -85,8 +85,7 @@ class UrlRewriterTests < Test::Unit::TestCase end end -class UrlWriterTests < Test::Unit::TestCase - +class UrlWriterTests < ActionController::TestCase class W include ActionController::UrlWriter end @@ -302,6 +301,42 @@ class UrlWriterTests < Test::Unit::TestCase assert_generates("/image", :controller=> :image) end + def test_named_routes_with_nil_keys + ActionController::Routing::Routes.clear! + add_host! + ActionController::Routing::Routes.draw do |map| + map.main '', :controller => 'posts' + map.resources :posts + map.connect ':controller/:action/:id' + end + # We need to create a new class in order to install the new named route. + kls = Class.new { include ActionController::UrlWriter } + controller = kls.new + params = {:action => :index, :controller => :posts, :format => :xml} + assert_equal("http://www.basecamphq.com/posts.xml", controller.send(:url_for, params)) + params[:format] = nil + assert_equal("http://www.basecamphq.com/", controller.send(:url_for, params)) + ensure + ActionController::Routing::Routes.load! + end + + def test_formatted_url_methods_are_deprecated + ActionController::Routing::Routes.draw do |map| + map.resources :posts + end + # We need to create a new class in order to install the new named route. + kls = Class.new { include ActionController::UrlWriter } + controller = kls.new + params = {:id => 1, :format => :xml} + assert_deprecated do + assert_equal("/posts/1.xml", controller.send(:formatted_post_path, params)) + end + assert_deprecated do + assert_equal("/posts/1.xml", controller.send(:formatted_post_path, 1, :xml)) + end + ensure + ActionController::Routing::Routes.load! + end private def extract_params(url) url.split('?', 2).last.split('&') |