Railsチュートリアルに従っていますが、テストでいくつかの問題がありましたが、特定のエラーの1つは次のとおりです。
1) UsersController following pages when not signed in should protect 'following'
Failure/Error: get :following, :id => 1
ActionController::RoutingError:
No route matches {:id=>1, :controller=>"users", :action=>"following"}
# ./spec/controllers/users_controller_spec.rb:10:in `block (4 levels) in <top (required)>'
これが自分のroutes.rbにある場合、なぜそれが起こっているのかわかりません
resources :users do
member do
get :following, :followers
end
end
私のコントローラーはこれです:
class UsersController < ApplicationController
before_filter :authenticate, :except => [:show, :new, :create]
def followers
@title = "Followers"
@user = User.find(params[:id])
@users = @user.followers.paginate(:page => params[:page])
render 'show_follow'
end
def following
@title = "Following"
@user = User.find(params[:id])
@users = @user.following.paginate(:page => params[:page])
render 'show_follow'
end
end
ここに私のrspecがあります:
it "should protect 'following'" do
get :following, :id => 1
response.should redirecto_to (new_selector_session_en_path)
end
私のルートも:
following_user_en GET /users/:id/following(.:format) {:action=>"following", :controller=>"users"}
following_user_es GET /es/usuarios/:id/following(.:format) {:action=>"following", :controller=>"users"}
followers_user_en GET /users/:id/followers(.:format) {:action=>"followers", :controller=>"users"}
followers_user_es GET /es/usuarios/:id/followers(.:format) {:action=>"followers", :controller=>"users"}