aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorCheah Chu Yeow <chuyeow@gmail.com>2008-04-20 12:57:36 +0800
committerMichael Koziarski <michael@koziarski.com>2008-05-04 12:49:44 +1200
commit6a6b4392c16c665eb713705f2b38e959a658eeef (patch)
treee5769a86f89bcfb084726be42bad07d365dee5ac /actionpack/test/controller
parent437f918646fd141fd57350f55a8890b18ebfb148 (diff)
downloadrails-6a6b4392c16c665eb713705f2b38e959a658eeef.tar.gz
rails-6a6b4392c16c665eb713705f2b38e959a658eeef.tar.bz2
rails-6a6b4392c16c665eb713705f2b38e959a658eeef.zip
Ensure that default_url_options, if defined, are used in named routes.
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#22 state:resolved]
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/base_test.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 1a8bd6dfe9..8416754c1e 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -48,6 +48,15 @@ protected
end
+class DefaultUrlOptionsController < ActionController::Base
+ def default_url_options_action
+ end
+
+ def default_url_options(options)
+ { :host => 'www.override.com', :action => 'new', :bacon => 'chunky' }
+ end
+end
+
class ControllerClassTests < Test::Unit::TestCase
def test_controller_path
assert_equal 'empty', EmptyController.controller_path
@@ -134,3 +143,28 @@ class PerformActionTest < Test::Unit::TestCase
assert_response 404
end
end
+
+class DefaultUrlOptionsTest < Test::Unit::TestCase
+ def setup
+ @controller = DefaultUrlOptionsController.new
+
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+
+ @request.host = 'www.example.com'
+ end
+
+ def test_default_url_options_are_used_if_set
+ ActionController::Routing::Routes.draw do |map|
+ map.default_url_options 'default_url_options', :controller => 'default_url_options'
+ map.connect ':controller/:action/:id'
+ end
+
+ get :default_url_options_action # Make a dummy request so that the controller is initialized properly.
+
+ assert_equal 'http://www.override.com/default_url_options/new?bacon=chunky', @controller.url_for(:controller => 'default_url_options')
+ assert_equal 'http://www.override.com/default_url_options?bacon=chunky', @controller.send(:default_url_options_url)
+ ensure
+ ActionController::Routing::Routes.load!
+ end
+end \ No newline at end of file