From cc6ce380e988780f9af2b0badc5136f382b341ab Mon Sep 17 00:00:00 2001 From: Ivan Vega Date: Wed, 21 May 2008 18:14:39 -0500 Subject: [PATCH] Customizable path names for RESTful routes --- actionpack/test/controller/resources_test.rb | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index dc86d07..5ebee97 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -798,10 +798,13 @@ class ResourcesTest < Test::Unit::TestCase options[:options] ||= {} options[:options][:controller] = options[:controller] || singleton_name.to_s.pluralize + new_action = options[:path_names] ? options[:path_names][:new] || 'new' : 'new' + edit_action = options[:path_names] ? options[:path_names][:edit] || 'edit' : 'edit' + full_path = "/#{options[:path_prefix]}#{options[:as] || singleton_name}" - new_path = "#{full_path}/new" - edit_path = "#{full_path}/edit" - formatted_edit_path = "#{full_path}/edit.xml" + new_path = "#{full_path}/#{new_action}" + edit_path = "#{full_path}/#{edit_action}" + formatted_edit_path = "#{full_path}/#{edit_action}.xml" with_options options[:options] do |controller| controller.assert_routing full_path, :action => 'show' @@ -843,10 +846,13 @@ class ResourcesTest < Test::Unit::TestCase assert_named_route "#{full_path}", "#{name_prefix}#{singleton_name}_path", options[:options] assert_named_route "#{full_path}.xml", "formatted_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') - assert_named_route "#{full_path}/new", "new_#{name_prefix}#{singleton_name}_path", options[:options] - assert_named_route "#{full_path}/new.xml", "formatted_new_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') - assert_named_route "#{full_path}/edit", "edit_#{name_prefix}#{singleton_name}_path", options[:options] - assert_named_route "#{full_path}/edit.xml", "formatted_edit_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') + new_action = options[:path_names] ? options[:path_names][:new] || 'new' : 'new' + edit_action = options[:path_names] ? options[:path_names][:edit] || 'edit' : 'edit' + + assert_named_route "#{full_path}/#{new_action}", "new_#{name_prefix}#{singleton_name}_path", options[:options] + assert_named_route "#{full_path}/#{new_action}.xml", "formatted_new_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') + assert_named_route "#{full_path}/#{edit_action}", "edit_#{name_prefix}#{singleton_name}_path", options[:options] + assert_named_route "#{full_path}/#{edit_action}.xml", "formatted_edit_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') end def assert_named_route(expected, route, options) -- 1.5.5