前提・実現したいこと
テストが通りません。
railsチュートリアル完走後、
railsチュートリアルを参考にしながら新たにdeviseによるログイン実装しました。
正常に可動するのですが、railsチュートリアルのリスト(8.23)のassert_redirected_toのところがうまくできません。
発生している問題・エラーメッセージ
(test/integration/users_login_test.rb)
require 'test_helper' class UsersLoginTest < ActionDispatch::IntegrationTest def setup @user = users(:michael) end test "login with invalid information" do get new_user_session_path post new_user_session_path, params:{ session: {email: @user.email, password: 'password'}} assert_redirected_to root_url follow_redirect! assert_template 'sessions/new' post new_user_session_path, params: { session: { email: "", password: "" } } assert_template 'sessions/new' assert_not flash.empty? get root_path assert flash.empty? end end
テスト結果 エラーメッセージ
1) Failure:UsersLoginTest#test_login_with_invalid_information [/home/ec2-user/environment/instagram/test/integration/users_login_test.rb:13]:Expected response to be a <3XX: redirect>, but was a <200: OK>
該当のソースコード
(controllers/users/registrations_controller.rb)
, , def after_sign_in_path_for(resource) admin_root_path end , ,
現状のルーティング
Cloud9User:~/environment/instagram (develop) $ rails routes Prefix Verb URI Pattern Controller#Action new_user_session GET /users/sign_in(.:format) users/sessions#new user_session POST /users/sign_in(.:format) users/sessions#create destroy_user_session DELETE /users/sign_out(.:format) users/sessions#destroy user_facebook_omniauth_authorize GET|POST /users/auth/facebook(.:format) users/omniauth_callbacks#passthru user_facebook_omniauth_callback GET|POST /users/auth/facebook/callback(.:format) users/omniauth_callbacks#facebook new_user_password GET /users/password/new(.:format) devise/passwords#new edit_user_password GET /users/password/edit(.:format) devise/passwords#edit user_password PATCH /users/password(.:format) devise/passwords#update PUT /users/password(.:format) devise/passwords#update POST /users/password(.:format) devise/passwords#create cancel_user_registration GET /users/cancel(.:format) users/registrations#cancel new_user_registration GET /users/sign_up(.:format) users/registrations#new edit_user_registration GET /users/edit(.:format) users/registrations#edit user_registration PATCH /users(.:format) users/registrations#update PUT /users(.:format) users/registrations#update DELETE /users(.:format) users/registrations#destroy POST /users(.:format) users/registrations#create profile_edit GET /profile_edit(.:format) users/registrations#profile_edit profile_update PATCH /profile_update(.:format) users/registrations#profile_update root GET / home#index show GET /show(.:format) users#show book GET /book(.:format) home#book users GET /users(.:format) users#index user GET /users/:id(.:format) users#show DELETE /users/:id(.:format) users#destroy following_user GET /users/:id/following(.:format) users#following followers_user GET /users/:id/followers(.:format) users#followers GET /users(.:format) users#index POST /users(.:format) users#create new_user GET /users/new(.:format) users#new edit_user GET /users/:id/edit(.:format) users#edit GET /users/:id(.:format) users#show PATCH /users/:id(.:format) users#update PUT /users/:id(.:format) users#update DELETE /users/:id(.:format) users#destroy relationships POST /relationships(.:format) relationships#create relationship DELETE /relationships/:id(.:format) relationships#destroy micropost_comments GET /microposts/:micropost_id/comments(.:format) comments#index POST /microposts/:micropost_id/comments(.:format) comments#create new_micropost_comment GET /microposts/:micropost_id/comments/new(.:format) comments#new edit_micropost_comment GET /microposts/:micropost_id/comments/:id/edit(.:format) comments#edit micropost_comment GET /microposts/:micropost_id/comments/:id(.:format) comments#show PATCH /microposts/:micropost_id/comments/:id(.:format) comments#update PUT /microposts/:micropost_id/comments/:id(.:format) comments#update DELETE /microposts/:micropost_id/comments/:id(.:format) comments#destroy microposts POST /microposts(.:format) microposts#create new_micropost GET /microposts/new(.:format) microposts#new micropost GET /microposts/:id(.:format) microposts#show DELETE /microposts/:id(.:format) microposts#destroy
試したこと
redirectを正しく理解していないようで、試行錯誤したがうまく行きませんでした。
その他必要な情報等あれば、追加投稿いたしいます。
よろしくお願いいたします。
あなたの回答
tips
プレビュー