Skip to content
This repository

Failing Test Case for Issue #1692 Routes not found in TestRequest#assign_parameters #1693

Closed
wants to merge 1 commit into from

2 participants

Jan Varwig Andrew White
Jan Varwig
janv commented June 14, 2011

I have encountered (probably) the following problem in a 2.3.12 app:

We have a route with :method => :post

In our controller test, calling post action, … fails unless I explicity set a :format => :post parameter although that should have been inferred by the assign_parameters method.

The reason for this is, as far as I figured out:
assign_parameters calls Route#extra_keys
_extra_keys calls RouteSet#generate_extras
__which in turn calls route_generate_raw
__which doesn't return a path
_which causes RouteSet#generate to raise a RoutingError

I'm not sure where exactly to fix this problem.
I'd simply add a line or two to assign_parameters that adds the :format to the options but I'm happy to implement other suggestions.

See issue #1692

Andrew White
Owner

You're not defining the route correctly - this test passes:

  def test_routing_with_method
    with_routing do |set|
      set.draw { |map| map.connect 'testmethod', :controller => 'test_test/test', :action => 'create', :conditions => { :method => :post } }
      assert_nothing_raised {
        post :create
      }
    end
  end
Andrew White pixeltrix closed this June 14, 2011
Jan Varwig
janv commented June 14, 2011

Ooops, you're right. Sorry.

Jake Varghese jake3030 referenced this pull request from a commit in jake3030/rails June 21, 2009
Pratik Add expiry support File cache store [#1693 state:resolved] [Roman Sht…
…erenzon, Pratik Naik]
b5775c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 14, 2011
Jan Varwig Added failing test for issue #1692 062b290
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. 9  actionpack/test/controller/test_test.rb
9  actionpack/test/controller/test_test.rb
@@ -439,6 +439,15 @@ def test_assert_routing_with_method
439 439
       assert_routing({ :method => 'post', :path => 'content' }, { :controller => 'content', :action => 'create' })
440 440
     end
441 441
   end
  442
+  
  443
+  def test_routing_with_method
  444
+    with_routing do |set|
  445
+      set.draw { |map| map.route 'testmethod', :controller => 'test_test/test', :action => 'create', :method => :post }
  446
+      assert_nothing_raised {
  447
+        post :create
  448
+      }
  449
+    end
  450
+  end
442 451
 
443 452
   def test_assert_routing_in_module
444 453
     assert_routing 'admin/user', :controller => 'admin/user', :action => 'index'
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.