Rails 4: testing GET request on a namespaced controller
ruby-on-rails
Solution
I think you need to provide an id to the show action
test "accessing :show action" do
get :show, {:id => 1}
assert_response :success
end
That's the right way prior to rails 4.
Please have a try, and let me know the outcome.
Problem
I have a failing test that I'm struggling to understand. I have a controller `class Users::QueriesController < ApplicationController` at app/controllers/users/queries_controller.rb which has a `show` action, and a corresponding namespaced route: ``` namespace :users do resources :queries end ``` I also have a test at test/controllers/users/queries_controller_test.rb: ``` require 'test_helper' class Users::QueriesControllerTest < ActionController::TestCase test "accessing :show action" do get :show assert_response :success end end ``` Running this test results in `ActionController::UrlGenerationError: No route matches {:controller=>"users/queries", :action=>"show"}`. Running `rake routes` includes this line: `users_query GET /users/queries/:id(.:format) users/queries#show`. What's going wrong here? I'm using Rails 4.0.0.