From 068fc6ce4962ef4c9432455f88a83400316cd321 Mon Sep 17 00:00:00 2001 From: Tom Lea Date: Tue, 28 Oct 2008 15:52:36 +0000 Subject: [PATCH] Added failing test case --- actionpack/test/template/url_helper_test.rb | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 797b74e..c3286ad 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -375,6 +375,19 @@ class UrlHelperWithControllerTest < ActionView::TestCase get :nil_url_for assert_equal '/url_helper_with_controller/nil_url_for', @response.body end + + def test_named_route_should_show_host_and_path_using_controller_default_url_options + class << @controller + def default_url_options(options = nil) + {:host => 'testtwo.host'} + end + end + + with_url_helper_routing do + get :show_named_route, :kind => 'url' + assert_equal 'http://testtwo.host/url_helper_with_controller/show_named_route', @response.body + end + end protected def with_url_helper_routing -- 1.6.0.1 From e6e1f76fb8028d1d431dca4648bad0de7a74f4e1 Mon Sep 17 00:00:00 2001 From: Tom Lea Date: Tue, 28 Oct 2008 16:02:46 +0000 Subject: [PATCH] Added a second test case that passes. This one uses the controller explicitly. --- actionpack/test/template/url_helper_test.rb | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index c3286ad..745ac38 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -340,6 +340,10 @@ class UrlHelperWithControllerTest < ActionView::TestCase def nil_url_for render :inline => '<%= url_for(nil) %>' end + + def show_named_route_from_controller + render :text => self.send("show_named_route_#{params[:kind]}") + end def rescue_action(e) raise e end end @@ -389,11 +393,26 @@ class UrlHelperWithControllerTest < ActionView::TestCase end end + def test_named_route_should_show_host_and_path_using_controller_default_url_options_from_controller + class << @controller + def default_url_options(options = nil) + {:host => 'testtwo.host'} + end + end + + with_url_helper_routing do + get :show_named_route_from_controller, :kind => 'url' + assert_equal 'http://testtwo.host/url_helper_with_controller/show_named_route', @response.body + end + end + + protected def with_url_helper_routing with_routing do |set| set.draw do |map| map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper_with_controller', :action => 'show_named_route' + map.show_named_route_from_controller 'url_helper_with_controller/show_named_route_from_controller', :controller => 'url_helper_with_controller', :action => 'show_named_route_from_controller' end yield end -- 1.6.0.1 From 75dbffbeb26b860744913770f623e20c90737a3b Mon Sep 17 00:00:00 2001 From: Tom Lea Date: Thu, 30 Oct 2008 17:53:09 +0000 Subject: [PATCH] We can't optomise routes for urls because we don't know enough about the environment. --- .../lib/action_controller/routing/optimisations.rb | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/actionpack/lib/action_controller/routing/optimisations.rb b/actionpack/lib/action_controller/routing/optimisations.rb index 894d410..9193d2f 100644 --- a/actionpack/lib/action_controller/routing/optimisations.rb +++ b/actionpack/lib/action_controller/routing/optimisations.rb @@ -92,6 +92,10 @@ module ActionController end %("#{elements * ''}") end + + def applicable? + kind != :url + end end # This case is mostly the same as the positional arguments case -- 1.6.0.1