Permalink
Browse files

Rename named_url_helpers to url_helpers and url_helpers to url_for

  • Loading branch information...
Carlhuda
Carlhuda committed Feb 26, 2010
1 parent f10a019 commit 98f77e08278658ec47c9eb2e8f819d781c1eaebf
@@ -6,7 +6,7 @@ class Railtie < Rails::Railtie
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"
@@ -7,7 +7,7 @@ class WelcomeController < ActionController::Base
AppRoutes = ActionDispatch::Routing::RouteSet.new
class ActionMailer::Base
- include AppRoutes.named_url_helpers
+ include AppRoutes.url_helpers
end
class TestMailer < ActionMailer::Base
@@ -15,7 +15,7 @@ def merge_options(options)
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
@@ -5,7 +5,7 @@ def self.with(router)
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
@@ -259,9 +259,8 @@ def install_helpers(destinations = [ActionController::Base, ActionView::Base], r
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 @@ def url_helpers
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?
@@ -145,14 +145,14 @@ def with_routing
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)
@@ -256,7 +256,7 @@ def assert_template(options = {}, message = nil)
# ROUTES TODO: Cleaner way to do this?
module ActionController
- UrlFor = SharedTestRoutes.named_url_helpers
+ UrlFor = SharedTestRoutes.url_helpers
class Base
include UrlFor
end
@@ -400,7 +400,7 @@ def with_test_routes(options = {})
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 @@ def with_admin_test_routes(options = {})
end
end
- self.class.send(:include, @router.named_url_helpers)
+ self.class.send(:include, @router.url_helpers)
yield
end
end
@@ -441,7 +441,7 @@ def with_admin_and_site_test_routes(options = {})
end
end
- self.class.send(:include, @router.named_url_helpers)
+ self.class.send(:include, @router.url_helpers)
yield
end
end
@@ -512,7 +512,7 @@ def reset!
@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
@@ -221,7 +221,7 @@ def test_integration_methods_called
end
class IntegrationProcessTest < ActionController::IntegrationTest
- include SharedTestRoutes.named_url_helpers
+ include SharedTestRoutes.url_helpers
class IntegrationController < ActionController::Base
def get
@@ -388,23 +388,23 @@ def with_test_route_set
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|
match ':action', :to => controller
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
end
end
class MetalIntegrationTest < ActionController::IntegrationTest
- include SharedTestRoutes.named_url_helpers
+ include SharedTestRoutes.url_helpers
class Poller
def self.call(env)
@@ -1231,7 +1231,7 @@ def assert_restful_named_routes_for(controller_name, singular_name = nil, option
@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 @@ def assert_singleton_routes_for(singleton_name, options = {})
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]
@@ -251,7 +251,7 @@ def test_optimised_named_route_with_host
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 @@ def setup_named_route_test
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
@@ -164,7 +164,7 @@ def app
Routes
end
- include Routes.named_url_helpers
+ include Routes.url_helpers
def test_logout
with_test_routes do
@@ -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
@@ -20,7 +20,7 @@ def setup
@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

2 comments on commit 98f77e0

@josh

This comment has been minimized.

Show comment Hide comment
@josh

josh Feb 27, 2010

Member

I'd go with "routes.helper"

Member

josh replied Feb 27, 2010

I'd go with "routes.helper"

@carllerche

This comment has been minimized.

Show comment Hide comment
@carllerche

carllerche Feb 27, 2010

Contributor

Seems better

Contributor

carllerche replied Feb 27, 2010

Seems better

Please sign in to comment.