diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-03-30 14:05:42 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-03-30 14:05:42 -0500 |
commit | cdf8c35ffdfb39f4de4b030576b1abb06c482668 (patch) | |
tree | 16f3973a7f844aa3e55c72c26ba9266c24a6fa72 /actionpack/lib | |
parent | 17f0c1e9e8a5bfa7c4d2e1632c3b8b91f4678f03 (diff) | |
download | rails-cdf8c35ffdfb39f4de4b030576b1abb06c482668.tar.gz rails-cdf8c35ffdfb39f4de4b030576b1abb06c482668.tar.bz2 rails-cdf8c35ffdfb39f4de4b030576b1abb06c482668.zip |
Consistent routing language
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/railties/url_helpers.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/routing.rb | 20 |
3 files changed, 18 insertions, 18 deletions
diff --git a/actionpack/lib/action_controller/railties/url_helpers.rb b/actionpack/lib/action_controller/railties/url_helpers.rb index 5f95e1c621..9df5665542 100644 --- a/actionpack/lib/action_controller/railties/url_helpers.rb +++ b/actionpack/lib/action_controller/railties/url_helpers.rb @@ -1,14 +1,14 @@ module ActionController module Railties module UrlHelpers - def self.with(router) + def self.with(routes) Module.new do define_method(:inherited) do |klass| super(klass) - klass.send(:include, router.url_helpers) + klass.send(:include, routes.url_helpers) end end end end end -end
\ No newline at end of file +end diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 306db4a431..2d4cf2fafb 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -118,9 +118,9 @@ module ActionController end end - def assign_parameters(router, controller_path, action, parameters = {}) + def assign_parameters(routes, controller_path, action, parameters = {}) parameters = parameters.symbolize_keys.merge(:controller => controller_path, :action => action) - extra_keys = router.extra_keys(parameters) + extra_keys = routes.extra_keys(parameters) non_path_parameters = get? ? query_parameters : request_parameters parameters.each do |key, value| if value.is_a? Fixnum @@ -322,7 +322,7 @@ module ActionController def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET') # Sanity check for required instance variables so we can give an # understandable error message. - %w(@router @controller @request @response).each do |iv_name| + %w(@routes @controller @request @response).each do |iv_name| if !(instance_variable_names.include?(iv_name) || instance_variable_names.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil? raise "#{iv_name} is nil: make sure you set it in your test's setup method." end @@ -338,7 +338,7 @@ module ActionController @request.env['REQUEST_METHOD'] = http_method parameters ||= {} - @request.assign_parameters(@router, @controller.class.name.underscore.sub(/_controller$/, ''), action.to_s, parameters) + @request.assign_parameters(@routes, @controller.class.name.underscore.sub(/_controller$/, ''), action.to_s, parameters) @request.session = ActionController::TestSession.new(session) unless session.nil? @request.session["flash"] = @request.flash.update(flash || {}) @@ -447,7 +447,7 @@ module ActionController :relative_url_root => nil, :_path_segments => @request.symbolized_path_parameters) - url, query_string = @router.url_for(options).split("?", 2) + url, query_string = @routes.url_for(options).split("?", 2) @request.env["SCRIPT_NAME"] = @controller.config.relative_url_root @request.env["PATH_INFO"] = url diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index 08f3d90e18..b7e9b0c95a 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -80,7 +80,7 @@ module ActionDispatch expected_path = "/#{expected_path}" unless expected_path[0] == ?/ # Load routes.rb if it hasn't been loaded. - generated_path, extra_keys = @router.generate_extras(options, defaults) + generated_path, extra_keys = @routes.generate_extras(options, defaults) found_extras = options.reject {|k, v| ! extra_keys.include? k} msg = build_message(message, "found extras <?>, not <?>", found_extras, extras) @@ -125,7 +125,7 @@ module ActionDispatch end # A helper to make it easier to test different route configurations. - # This method temporarily replaces @router + # This method temporarily replaces @routes # with a new RouteSet instance. # # The new instance is yielded to the passed block. Typically the block @@ -142,9 +142,9 @@ module ActionDispatch # end # def with_routing - old_routes, @router = @router, ActionDispatch::Routing::RouteSet.new + old_routes, @routes = @routes, ActionDispatch::Routing::RouteSet.new old_controller, @controller = @controller, @controller.clone if @controller - _router = @router + _routes = @routes # Unfortunately, there is currently an abstraction leak between AC::Base # and AV::Base which requires having the URL helpers in both AC and AV. @@ -153,14 +153,14 @@ module ActionDispatch # # TODO: Make this unnecessary if @controller - @controller.singleton_class.send(:include, _router.url_helpers) + @controller.singleton_class.send(:include, _routes.url_helpers) @controller.view_context_class = Class.new(@controller.view_context_class) do - include _router.url_helpers + include _routes.url_helpers end end - yield @router + yield @routes ensure - @router = old_routes + @routes = old_routes if @controller @controller = old_controller end @@ -168,7 +168,7 @@ module ActionDispatch # ROUTES TODO: These assertions should really work in an integration context def method_missing(selector, *args, &block) - if @controller && @router && @router.named_routes.helpers.include?(selector) + if @controller && @routes && @routes.named_routes.helpers.include?(selector) @controller.send(selector, *args, &block) else super @@ -185,7 +185,7 @@ module ActionDispatch request.env["REQUEST_METHOD"] = request_method.to_s.upcase if request_method request.path = path - params = @router.recognize_path(path, { :method => request.method }) + params = @routes.recognize_path(path, { :method => request.method }) request.path_parameters = params.with_indifferent_access request |