Skip to content
This repository
Browse code

Failing test for routes with member & requirement [#2054 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
commit 5b7527ca44521edf9782b3d7f449bf09a29267f2 1 parent b1c989f
Mike Gunderloy authored March 05, 2009 josh committed March 05, 2009
7  actionpack/lib/action_controller/resources.rb
@@ -670,7 +670,12 @@ def action_options_for(action, resource, method = nil)
670 670
           when "show", "edit"; default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements(require_id))
671 671
           when "update";       default_options.merge(add_conditions_for(resource.conditions, method || :put)).merge(resource.requirements(require_id))
672 672
           when "destroy";      default_options.merge(add_conditions_for(resource.conditions, method || :delete)).merge(resource.requirements(require_id))
673  
-          else                  default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)
  673
+          else
  674
+              if method.nil? || resource.member_methods.nil? || resource.member_methods[method.to_sym].nil?
  675
+                default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)
  676
+              else                 
  677
+                resource.member_methods[method.to_sym].include?(action) ? default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements(require_id)) : default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)
  678
+              end
674 679
         end
675 680
       end
676 681
   end
8  actionpack/test/controller/resources_test.rb
@@ -209,6 +209,14 @@ def test_with_member_action
209 209
     end
210 210
   end
211 211
 
  212
+  def test_with_member_action_and_requirement
  213
+    expected_options = {:controller => 'messages', :action => 'mark', :id => '1.1.1'}
  214
+
  215
+    with_restful_routing(:messages, :requirements => {:id => /[0-9]\.[0-9]\.[0-9]/}, :member => { :mark => :get }) do
  216
+      assert_recognizes(expected_options, :path => 'messages/1.1.1/mark', :method => :get)
  217
+    end
  218
+  end
  219
+
212 220
   def test_member_when_override_paths_for_default_restful_actions_with
213 221
     [:put, :post].each do |method|
214 222
       with_restful_routing :messages, :member => { :mark => method }, :path_names => {:new => 'nuevo'} do

0 notes on commit 5b7527c

Please sign in to comment.
Something went wrong with that request. Please try again.