This project is archived and is in readonly mode.

#2124 ✓invalid
August Lilleaas

Testing "post :destroy" without the default routes.

Reported by August Lilleaas | March 4th, 2009 @ 12:24 PM | in 2.x

Please disregard this ticket. The tests were correct, the destroy wants params[:id], which I didn't provide.

When you leave out the map.connect ':controller/:action/:id' route, functional tests encounters a ActionController::RoutingError when testing post :destroy even though you have map.resources :posts in routes.rb

Here's how I'm producing this error:


leethal@haxxor ~> ruby ~/Code/rails/rails/railties/bin/rails weird_bug
   # ...
leethal@haxxor ~> cd weird_bug
leethal@haxxor ~/weird_bug> git init
leethal@haxxor ~/weird_bug> git submodule add git://github.com/rails/rails.git vendor/rails
  # ...
leethal@haxxor ~/weird_bug> ruby script/generate controller posts

Then, in config/routes.rb:


ActionController::Routing::Routes.draw do |map|
  map.resources :posts
end

In test/functional/posts_controller_test.rb:


require 'test_helper'

class PostsControllerTest < ActionController::TestCase
  test "destroy" do
    post :destroy
  end
end

Back in the terminal.


leethal@haxxor ~/weird_bug> rake test:functionals
(in /Users/leethal/weird_bug)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:test "/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" "test/functional/posts_controller_test.rb" 
Loaded suite /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader
Started
E
Finished in 0.077376 seconds.

  1) Error:
test_destroy(PostsControllerTest):
ActionController::RoutingError: No route matches {:action=>"destroy", :controller=>"posts"}
    /test/functional/posts_controller_test.rb:5:in `test_destroy'

1 tests, 0 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]

(See full trace by running task with --trace)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages