From 98f77e08278658ec47c9eb2e8f819d781c1eaebf Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Fri, 26 Feb 2010 15:00:33 -0800 Subject: [PATCH] Rename named_url_helpers to url_helpers and url_helpers to url_for --- actionmailer/lib/action_mailer/railtie.rb | 2 +- actionmailer/test/old_base/url_test.rb | 2 +- actionpack/lib/action_controller/metal/url_for.rb | 2 +- .../lib/action_controller/railties/url_helpers.rb | 2 +- actionpack/lib/action_dispatch/routing/route_set.rb | 11 +++++------ .../lib/action_dispatch/testing/assertions/routing.rb | 6 +++--- actionpack/test/abstract_unit.rb | 2 +- .../test/activerecord/polymorphic_routes_test.rb | 6 +++--- actionpack/test/controller/caching_test.rb | 2 +- actionpack/test/controller/integration_test.rb | 8 ++++---- actionpack/test/controller/resources_test.rb | 4 ++-- actionpack/test/controller/routing_test.rb | 4 ++-- actionpack/test/dispatch/routing_test.rb | 2 +- railties/lib/rails/test_help.rb | 2 +- railties/test/rails_info_controller_test.rb | 2 +- 15 files changed, 28 insertions(+), 29 deletions(-) diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 7622a90b17..c5f18c7911 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -6,7 +6,7 @@ module ActionMailer railtie_name :action_mailer initializer "action_mailer.url_for", :before => :load_environment_config do |app| - ActionMailer::Base.send(:include, app.routes.named_url_helpers) + ActionMailer::Base.send(:include, app.routes.url_helpers) end require "action_mailer/railties/log_subscriber" diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb index 0e8917b427..a719248599 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/old_base/url_test.rb @@ -7,7 +7,7 @@ end AppRoutes = ActionDispatch::Routing::RouteSet.new class ActionMailer::Base - include AppRoutes.named_url_helpers + include AppRoutes.url_helpers end class TestMailer < ActionMailer::Base diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb index 013834ddee..6748cb7bd4 100644 --- a/actionpack/lib/action_controller/metal/url_for.rb +++ b/actionpack/lib/action_controller/metal/url_for.rb @@ -15,7 +15,7 @@ module ActionController def _router raise "In order to use #url_for, you must include the helpers of a particular " \ - "router. For instance, `include Rails.application.router.named_url_helpers" + "router. For instance, `include Rails.application.routes.url_helpers" end end end \ No newline at end of file diff --git a/actionpack/lib/action_controller/railties/url_helpers.rb b/actionpack/lib/action_controller/railties/url_helpers.rb index e726535a4f..ad2a8d4ef3 100644 --- a/actionpack/lib/action_controller/railties/url_helpers.rb +++ b/actionpack/lib/action_controller/railties/url_helpers.rb @@ -5,7 +5,7 @@ module ActionController Module.new do define_method(:inherited) do |klass| super(klass) - klass.send(:include, router.named_url_helpers) + klass.send(:include, router.url_helpers) end end end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 7bfe4fa2bf..47320883ac 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -259,9 +259,8 @@ module ActionDispatch named_routes.install(destinations, regenerate_code) end - # ROUTES TODO: Revisit the name of these methods - def url_helpers - @url_helpers ||= begin + def url_for + @url_for ||= begin router = self Module.new do extend ActiveSupport::Concern @@ -272,13 +271,13 @@ module ActionDispatch end end - def named_url_helpers - @named_url_helpers ||= begin + def url_helpers + @url_helpers ||= begin router = self Module.new do extend ActiveSupport::Concern - include router.url_helpers + include router.url_for # ROUTES TODO: install_helpers isn't great... can we make a module with the stuff that # we can include? diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index 5a3ff5a04c..5a9a20cc5b 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -145,14 +145,14 @@ module ActionDispatch old_routes, @router = @router, ActionDispatch::Routing::RouteSet.new old_controller, @controller = @controller, @controller.clone if @controller # ROUTES TODO: Figure out this insanity - silence_warnings { ::ActionController.const_set(:UrlFor, @router.named_url_helpers) } + silence_warnings { ::ActionController.const_set(:UrlFor, @router.url_helpers) } _router = @router - @controller.singleton_class.send(:send, :include, @router.named_url_helpers) if @controller + @controller.singleton_class.send(:send, :include, @router.url_helpers) if @controller yield @router ensure @router = old_routes @controller = old_controller if @controller - silence_warnings { ::ActionController.const_set(:UrlFor, @router.named_url_helpers) } if @router + silence_warnings { ::ActionController.const_set(:UrlFor, @router.url_helpers) } if @router end def method_missing(selector, *args, &block) diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 846ac5f0d7..9960f7af87 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -256,7 +256,7 @@ end # ROUTES TODO: Cleaner way to do this? module ActionController - UrlFor = SharedTestRoutes.named_url_helpers + UrlFor = SharedTestRoutes.url_helpers class Base include UrlFor end diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb index a10bb4473e..6e406ecd15 100644 --- a/actionpack/test/activerecord/polymorphic_routes_test.rb +++ b/actionpack/test/activerecord/polymorphic_routes_test.rb @@ -400,7 +400,7 @@ class PolymorphicRoutesTest < ActionController::TestCase map.resources :series end - self.class.send(:include, @router.named_url_helpers) + self.class.send(:include, @router.url_helpers) yield end end @@ -422,7 +422,7 @@ class PolymorphicRoutesTest < ActionController::TestCase end end - self.class.send(:include, @router.named_url_helpers) + self.class.send(:include, @router.url_helpers) yield end end @@ -441,7 +441,7 @@ class PolymorphicRoutesTest < ActionController::TestCase end end - self.class.send(:include, @router.named_url_helpers) + self.class.send(:include, @router.url_helpers) yield end end diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 98cea945a7..67b6a1d858 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -512,7 +512,7 @@ class ActionCacheTest < ActionController::TestCase @response = ActionController::TestResponse.new @controller = ActionCachingTestController.new # ROUTES TODO: It seems bad to explicitly remix in the class - @controller.singleton_class.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.url_helpers) @request.host = 'hostname.com' end diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 437d26e4ed..5352243734 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -221,7 +221,7 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest end class IntegrationProcessTest < ActionController::IntegrationTest - include SharedTestRoutes.named_url_helpers + include SharedTestRoutes.url_helpers class IntegrationController < ActionController::Base def get @@ -388,7 +388,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest with_routing do |set| controller = ::IntegrationProcessTest::IntegrationController.clone controller.class_eval do - include set.named_url_helpers + include set.url_helpers end set.draw do |map| @@ -396,7 +396,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest get 'get/:action', :to => controller end - self.singleton_class.send(:include, set.named_url_helpers) + self.singleton_class.send(:include, set.url_helpers) yield end @@ -404,7 +404,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest end class MetalIntegrationTest < ActionController::IntegrationTest - include SharedTestRoutes.named_url_helpers + include SharedTestRoutes.url_helpers class Poller def self.call(env) diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index b377e5bbbc..cf0cab3690 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -1231,7 +1231,7 @@ class ResourcesTest < ActionController::TestCase @controller = "#{options[:options][:controller].camelize}Controller".constantize.new # ROUTES TODO: Figure out a way to not extend the routing helpers here - @controller.singleton_class.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new get :index, options[:options] @@ -1301,7 +1301,7 @@ class ResourcesTest < ActionController::TestCase def assert_singleton_named_routes_for(singleton_name, options = {}) (options[:options] ||= {})[:controller] ||= singleton_name.to_s.pluralize @controller = "#{options[:options][:controller].camelize}Controller".constantize.new - @controller.singleton_class.send(:include, @router.named_url_helpers) + @controller.singleton_class.send(:include, @router.url_helpers) @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new get :show, options[:options] diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index f2fccfbcfc..31f86d2dde 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -251,7 +251,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase def setup_for_named_route inst = MockController.clone.new - inst.class.send(:include, rs.named_url_helpers) + inst.class.send(:include, rs.url_helpers) inst end @@ -741,7 +741,7 @@ class RouteSetTest < ActiveSupport::TestCase map.users '/admin/users', :controller => 'admin/users', :action => 'index' end - MockController.clone.new.tap { |inst| inst.class.send(:include, set.named_url_helpers)} + MockController.clone.new.tap { |inst| inst.class.send(:include, set.url_helpers)} end def test_named_route_hash_access_method diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 7cfc6ef3d7..37c2f1421b 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -164,7 +164,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest Routes end - include Routes.named_url_helpers + include Routes.url_helpers def test_logout with_test_routes do diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 5b5ce1dd7b..06270f6c43 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -31,7 +31,7 @@ class ActionController::TestCase end class ActionDispatch::IntegrationTest - include Rails.application.routes.named_url_helpers + include Rails.application.routes.url_helpers end begin diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index 017e51326c..7275755130 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -20,7 +20,7 @@ class InfoControllerTest < ActionController::TestCase @controller.stubs(:consider_all_requests_local? => false, :local_request? => true) @router = Rails.application.routes - Rails::InfoController.send(:include, @router.named_url_helpers) + Rails::InfoController.send(:include, @router.url_helpers) end test "info controller does not allow remote requests" do