前提・実現したいこと
railsチュートリアルの11章・リスト11.33「ユーザー登録のテストにアカウント有効化を追加する(test/integration/users_signup_test.rb)」
の
(有効化していない状態でログインしてみる)
log_in_as(user)
assert_not is_logged_in?
が理解できません。
発生している問題・エラーメッセージ
# 有効化していない状態でログインしてみる log_in_as(user) assert_not is_logged_in?
test/integration/users_signup_test.rb
test "valid signup information with account activation" do get signup_path assert_difference 'User.count', 1 do post users_path, params: { user: { name: "Example User", email: "user@example.com", password: "password", password_confirmation: "password" } } end assert_equal 1, ActionMailer::Base.deliveries.size user = assigns(:user) assert_not user.activated? # 有効化していない状態でログインしてみる log_in_as(user) assert_not is_logged_in? # 有効化トークンが不正な場合 get edit_account_activation_path("invalid token", email: user.email) assert_not is_logged_in? # トークンは正しいがメールアドレスが無効な場合 get edit_account_activation_path(user.activation_token, email: 'wrong') assert_not is_logged_in? # 有効化トークンが正しい場合 get edit_account_activation_path(user.activation_token, email: user.email) assert user.reload.activated? follow_redirect! assert_template 'users/show' assert is_logged_in? end
試したこと
疑問なのが、log_in_as(user)で
session[:user_id]=user_idからセッションを形成しているのにも関わらず、
テストヘルパーのis_logged_id? で!session[:user_id].nil? よりセッションがあるかどうか確認している場面で、
テストではassert_not is_logged_id?でセッションが形成されてないとなっていますが、
どこでsessionの形成が阻止されているのでしょうか?
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。