aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/url_rewriter_test.rb
diff options
context:
space:
mode:
authorNathan de Vries <nathan@atnan.com>2009-01-28 19:31:48 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-01-28 19:31:48 +0000
commit32eeb3e5211a4a7bfc7a1d0aa0cab1486bed3581 (patch)
tree541f742c2d89e8a90346723ea43d969a70c7c832 /actionpack/test/controller/url_rewriter_test.rb
parent74871961eccdb455f18e8ef66716041f2f828ba8 (diff)
downloadrails-32eeb3e5211a4a7bfc7a1d0aa0cab1486bed3581.tar.gz
rails-32eeb3e5211a4a7bfc7a1d0aa0cab1486bed3581.tar.bz2
rails-32eeb3e5211a4a7bfc7a1d0aa0cab1486bed3581.zip
Ensure that when UrlWriter is included in multiple classes, the default_url_options of one don't affect the other. [#1277 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/test/controller/url_rewriter_test.rb')
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index e9d372544e..09a8356fec 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -303,7 +303,6 @@ class UrlWriterTests < ActionController::TestCase
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
@@ -311,6 +310,8 @@ class UrlWriterTests < ActionController::TestCase
end
# We need to create a new class in order to install the new named route.
kls = Class.new { include ActionController::UrlWriter }
+ kls.default_url_options[:host] = 'www.basecamphq.com'
+
controller = kls.new
params = {:action => :index, :controller => :posts, :format => :xml}
assert_equal("http://www.basecamphq.com/posts.xml", controller.send(:url_for, params))
@@ -337,6 +338,20 @@ class UrlWriterTests < ActionController::TestCase
ensure
ActionController::Routing::Routes.load!
end
+
+ def test_multiple_includes_maintain_distinct_options
+ first_class = Class.new { include ActionController::UrlWriter }
+ second_class = Class.new { include ActionController::UrlWriter }
+
+ first_host, second_host = 'firsthost.com', 'secondhost.com'
+
+ first_class.default_url_options[:host] = first_host
+ second_class.default_url_options[:host] = second_host
+
+ assert_equal first_class.default_url_options[:host], first_host
+ assert_equal second_class.default_url_options[:host], second_host
+ end
+
private
def extract_params(url)
url.split('?', 2).last.split('&')