public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Make sure member names aren't mistakenly set to nil when providing 
:path_names

[#19 state:resolved]

Signed-off-by: Michael Koziarski <michael@koziarski.com>
Eugene Pimenov (author)
Fri Apr 18 04:45:33 -0700 2008
NZKoz (committer)
Wed Apr 23 01:19:22 -0700 2008
commit  e6a3ce3392812f707b78d64ffb04ee52f4517d20
tree    17cac338027788a877e79314354a4c8777025af6
parent  b6aa0e13b4e590b82550a6464924f431e57229df
...
527
528
529
530
 
531
532
533
...
527
528
529
 
530
531
532
533
0
@@ -527,7 +527,7 @@
0
             action_path = action
0
             if resource.options[:path_names]
0
               action_path = resource.options[:path_names][action]
0
- action_path ||= Base.resources_path_names[action]
0
+ action_path ||= Base.resources_path_names[action] || action
0
             end
0
 
0
             map.named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action_path}", action_options)
...
209
210
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
213
214
215
...
674
675
676
 
 
 
 
 
 
 
677
678
679
680
681
 
 
 
682
683
684
685
...
730
731
732
 
 
 
 
 
 
 
733
734
735
736
737
738
739
740
741
 
 
 
 
742
743
744
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
...
691
692
693
694
695
696
697
698
699
700
701
702
 
 
 
703
704
705
706
707
708
709
...
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
 
 
 
 
769
770
771
772
773
774
775
0
@@ -209,6 +209,23 @@
0
     end
0
   end
0
 
0
+ def test_member_when_override_paths_for_default_restful_actions_with
0
+ [:put, :post].each do |method|
0
+ with_restful_routing :messages, :member => { :mark => method }, :path_names => {:new => 'nuevo'} do
0
+ mark_options = {:action => 'mark', :id => '1', :controller => "messages"}
0
+ mark_path = "/messages/1/mark"
0
+
0
+ assert_restful_routes_for :messages, :path_names => {:new => 'nuevo'} do |options|
0
+ assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method)
0
+ end
0
+
0
+ assert_restful_named_routes_for :messages, :path_names => {:new => 'nuevo'} do |options|
0
+ assert_named_route mark_path, :mark_message_path, mark_options
0
+ end
0
+ end
0
+ end
0
+ end
0
+
0
   def test_with_two_member_actions_with_same_method
0
     [:put, :post].each do |method|
0
       with_restful_routing :messages, :member => { :mark => method, :unmark => method } do
0
0
@@ -674,11 +691,18 @@
0
       options[:options] ||= {}
0
       options[:options][:controller] = options[:controller] || controller_name.to_s
0
 
0
+ new_action = "new"
0
+ edit_action = "edit"
0
+ if options[:path_names]
0
+ new_action = options[:path_names][:new] || "new"
0
+ edit_action = options[:path_names][:edit] || "edit"
0
+ end
0
+
0
       collection_path = "/#{options[:path_prefix]}#{options[:as] || controller_name}"
0
       member_path = "#{collection_path}/1"
0
- new_path = "#{collection_path}/new"
0
- edit_member_path = "#{member_path}/edit"
0
- formatted_edit_member_path = "#{member_path}/edit.xml"
0
+ new_path = "#{collection_path}/#{new_action}"
0
+ edit_member_path = "#{member_path}/#{edit_action}"
0
+ formatted_edit_member_path = "#{member_path}/#{edit_action}.xml"
0
 
0
       with_options(options[:options]) do |controller|
0
         controller.assert_routing collection_path, :action => 'index'
0
0
@@ -730,15 +754,22 @@
0
       full_prefix = "/#{options[:path_prefix]}#{options[:as] || controller_name}"
0
       name_prefix = options[:name_prefix]
0
 
0
+ new_action = "new"
0
+ edit_action = "edit"
0
+ if options[:path_names]
0
+ new_action = options[:path_names][:new] || "new"
0
+ edit_action = options[:path_names][:edit] || "edit"
0
+ end
0
+
0
       assert_named_route "#{full_prefix}", "#{name_prefix}#{controller_name}_path", options[:options]
0
       assert_named_route "#{full_prefix}.xml", "formatted_#{name_prefix}#{controller_name}_path", options[:options].merge( :format => 'xml')
0
       assert_named_route "#{full_prefix}/1", "#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1')
0
       assert_named_route "#{full_prefix}/1.xml", "formatted_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
0
 
0
- assert_named_route "#{full_prefix}/new", "new_#{name_prefix}#{singular_name}_path", options[:options]
0
- assert_named_route "#{full_prefix}/new.xml", "formatted_new_#{name_prefix}#{singular_name}_path", options[:options].merge( :format => 'xml')
0
- assert_named_route "#{full_prefix}/1/edit", "edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1')
0
- assert_named_route "#{full_prefix}/1/edit.xml", "formatted_edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
0
+ assert_named_route "#{full_prefix}/#{new_action}", "new_#{name_prefix}#{singular_name}_path", options[:options]
0
+ assert_named_route "#{full_prefix}/#{new_action}.xml", "formatted_new_#{name_prefix}#{singular_name}_path", options[:options].merge( :format => 'xml')
0
+ assert_named_route "#{full_prefix}/1/#{edit_action}", "edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1')
0
+ assert_named_route "#{full_prefix}/1/#{edit_action}.xml", "formatted_edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
0
 
0
       yield options[:options] if block_given?
0
     end

Comments

    No one has commented yet.