From 2ae4f65087fc346fc22ce925fea646c7486617fe Mon Sep 17 00:00:00 2001 From: Denis Odorcic Date: Tue, 16 Mar 2010 01:27:26 -0400 Subject: [PATCH] Add tests to url_for for when script_name is set by controller vs when its passed into url_for --- actionpack/test/controller/url_for_test.rb | 30 ++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index fc7773d..410e2e2 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -256,6 +256,36 @@ module AbstractController assert_equal first_class.default_url_options[:host], first_host assert_equal second_class.default_url_options[:host], second_host end + + def test_with_script_name_not_set_by_url_for + with_routing do |set| + set.draw do |map| + get 'foo/bar' + end + + kls = Class.new { include set.url_helpers } + kls.default_url_options[:script_name] = '/foo/baz' + + controller = kls.new + params = {:use_route => "foo_bar", :controller => "foo", :only_path => true, :action => "bar"} + assert_equal("/foo/bar", controller.send(:url_for, params)) + end + end + + def test_with_script_name_when_set_by_url_for + with_routing do |set| + set.draw do |map| + get 'foo/bar' + end + + kls = Class.new { include set.url_helpers } + kls.default_url_options[:script_name] = '/foo/baz' + + controller = kls.new + params = {:use_route => "foo_bar", :controller => "foo", :only_path => true, :action => "bar", :script_name => "/foobar"} + assert_equal("/foobar/foo/bar", controller.send(:url_for, params)) + end + end private def extract_params(url) -- 1.6.0.6