Note that there are some explanatory texts on larger screens.

plurals
  1. PORails functional tests, routing error
    primarykey
    data
    text
    <p>I'm new to testing, and I'm having some difficulties trying to run a functional test.</p> <p>I've a messages_controller, and a user_controller here. in the routes, I've defined that the users resources has_many message resources.</p> <p>Now I'm trying to run a simple test in the messages controller:</p> <pre><code>def test_index get :index, { :user_id =&gt; 1 } assert_template 'index' end </code></pre> <p>But get a routing error from rails, that he cant find a route to messages. I don't want to include a route to messages only because of the tests. How can I tell the test that he must access from the /users/messages url?</p> <p>the full routes.rb:</p> <pre><code>ActionController::Routing::Routes.draw do |map| map.login 'login', :controller =&gt; :user_sessions, :action =&gt; :new map.logout 'logout', :controller =&gt; :user_sessions, :action =&gt; :destroy map.signin 'signin', :controller =&gt; :users, :action =&gt; :new map.connect 'search/:action/:word', :controller =&gt; :search map.connect 'search/:word', :controller =&gt; :search, :action =&gt; :index map.resources :forums do |forums| forums.resources :forum_posts, :collection =&gt; {:preview =&gt; :post }, :as =&gt; :posts do |post| post.resources :forum_posts, :as =&gt; :reply post.resources :reports end end map.resources :newsitems, :as =&gt; :news do |news| news.resources :comments do |comment| comment.resources :reports end end map.resource :user_sessions map.resources :users, :as =&gt; :profiles, :controller =&gt; :profiles, :has_many =&gt; [ :messages ] map.resource :profiles map.resource :me, :controller =&gt; :me, :has_many =&gt; [ :messages ] map.resources :comments, :has_many =&gt; [ :reports ] map.resources :forum_posts, :has_many =&gt; [ :reports ] map.resources :reports map.home '/', :controller =&gt; :home map.root :controller =&gt; :home map.namespace :admin do |admin| admin.namespace :forum do |forum| forum.resources :categories forum.resources :posts forum.resources :forums forum.root :controller =&gt; :home end admin.resources :notices admin.resources :users admin.workflow 'workflow/:action', :controller =&gt; :workflow admin.resources :newsitems admin.resources :reports admin.resources :comments admin.root :controller =&gt; :home end map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' end </code></pre> <p><strong>UPDATE</strong></p> <p>I've noticed that every functional test get a routing error. Even the simpliests ones like newsitem. I've no idea why.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload