From 00685ad8fdc9f15d935aebe52597037f3ca93be8 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Wed, 6 Sep 2006 22:21:36 +0000 Subject: Update UrlWriter to support :only_path. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5054 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/url_rewriter_test.rb | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller/url_rewriter_test.rb') diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index f71f79db47..53cd278b6b 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -84,10 +84,32 @@ class UrlWriterTests < Test::Unit::TestCase # We need to create a new class in order to install the new named route. kls = Class.new { include ActionController::UrlWriter } - assert kls.new.respond_to?(:home_url) + controller = kls.new + assert controller.respond_to?(:home_url) assert_equal 'http://www.basecamphq.com/home/sweet/home/again', - kls.new.send(:home_url, :host => 'www.basecamphq.com', :user => 'again') + controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again') + + assert_equal("/home/sweet/home/alabama", controller.send(:home_path, :user => 'alabama', :host => 'unused')) ensure ActionController::Routing::Routes.load! end + + def test_only_path + ActionController::Routing::Routes.draw do |map| + map.home '/home/sweet/home/:user' + 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 + assert controller.respond_to?(:home_url) + assert_equal '/brave/new/world', + controller.send(:url_for, :controller => 'brave', :action => 'new', :id => 'world', :only_path => true) + + assert_equal("/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'unused', :only_path => true)) + ensure + ActionController::Routing::Routes.load! + end + end -- cgit v1.2.3