vendor/rails/actionpack/test/controller/resources_test.rb
# test named routes like foo_path and foos_path map to the correct options.
test named routes like foo_path and foos_path map to the correct options.
test named routes like foo_path and foos_path map to the correct options .
def assert_restful_named_routes_for(controller_name, singular_name = nil, options = {})
      if singular_name.is_a?(Hash)
        options       = singular_name
        singular_name = nil
      end
      singular_name ||= controller_name.to_s.singularize
      (options[:options] ||= {})[:controller] = controller_name.to_s
      @controller = "#{controller_name.to_s.camelize}Controller".constantize.new
      @request    = ActionController::TestRequest.new
      @response   = ActionController::TestResponse.new
      get :index, options[:options]
      options[:options].delete :action
      full_prefix = "/#{options[:path_prefix]}#{controller_name}"
      name_prefix = options[:name_prefix]
      assert_named_route "#{full_prefix}",            "#{name_prefix}#{controller_name}_path",              options[:options]
      assert_named_route "#{full_prefix}/new",        "new_#{name_prefix}#{singular_name}_path",            options[:options]
      assert_named_route "#{full_prefix}/1",          "#{name_prefix}#{singular_name}_path",                options[:options].merge(:id => '1')
      assert_named_route "#{full_prefix}/1/edit",     "edit_#{name_prefix}#{singular_name}_path",           options[:options].merge(:id => '1')
      assert_named_route "#{full_prefix}.xml",        "formatted_#{name_prefix}#{controller_name}_path",    options[:options].merge(            :format => 'xml')
      assert_named_route "#{full_prefix}/new.xml",    "formatted_new_#{name_prefix}#{singular_name}_path",  options[:options].merge(            :format => 'xml')
      assert_named_route "#{full_prefix}/1.xml",      "formatted_#{name_prefix}#{singular_name}_path",      options[:options].merge(:id => '1', :format => 'xml')
      assert_named_route "#{full_prefix}/1/edit.xml", "formatted_edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
      yield options[:options] if block_given?
    end
def assert_restful_named_routes_for ( controller_name , singular_name = nil , options = { } ) if singular_name . is_a? ( Hash ) options = singular_name singular_name = nil end singular_name ||= controller_name . to_s . singularize ( options [ :options ] ||= { } ) [ :controller ] = controller_name . to_s @controller = "#{controller_name.to_s.camelize}Controller" . constantize . new @request = ActionController :: TestRequest . new @response = ActionController :: TestResponse . new get :index , options [ :options ] options [ :options ] . delete :action full_prefix = "/#{options[:path_prefix]}#{controller_name}" name_prefix = options [ :name_prefix ] assert_named_route "#{full_prefix}" , "#{name_prefix}#{controller_name}_path" , options [ :options ] assert_named_route "#{full_prefix}/new" , "new_#{name_prefix}#{singular_name}_path" , options [ :options ] assert_named_route "#{full_prefix}/1" , "#{name_prefix}#{singular_name}_path" , options [ :options ] . merge ( :id => '1' ) assert_named_route "#{full_prefix}/1/edit" , "edit_#{name_prefix}#{singular_name}_path" , options [ :options ] . merge ( :id => '1' ) assert_named_route "#{full_prefix}.xml" , "formatted_#{name_prefix}#{controller_name}_path" , options [ :options ] . merge ( :format => 'xml' ) assert_named_route "#{full_prefix}/new.xml" , "formatted_new_#{name_prefix}#{singular_name}_path" , options [ :options ] . merge ( :format => 'xml' ) assert_named_route "#{full_prefix}/1.xml" , "formatted_#{name_prefix}#{singular_name}_path" , options [ :options ] . merge ( :id => '1' , :format => 'xml' ) assert_named_route "#{full_prefix}/1/edit.xml" , "formatted_edit_#{name_prefix}#{singular_name}_path" , options [ :options ] . merge ( :id => '1' , :format => 'xml' ) yield options [ :options ] if block_given? end
test named routes like foo_path and foos_path map to the correct options.
test named routes like foo_path and foos_path map to the correct options .
controller_name
singular_name
options