Capybaraでサインアップした後、スマートリダイレクトの具体的な流れをテストする必要があります。実際の実装のためにCapybaraのメールでセッションがリセットされる
When I visit the interesting page "42"
And I visit a couple uninteresting pages
# Note during the visit to other pages, session[:interesting_page] is correctly set to the url of page "42"
When I sign up and I confirm via the link in the email
# At this point I have lost the session[:interesting_page]
Then I should be confirmed and redirected to the last visited interesting page "42"
、私はcontroller.session[]=
を選ぶことにしました:私は私のウェブサイトでは、いくつかのinteresting_pages
があると、私は小シナリオは
登録確認後の最後の訪問興味深いページにユーザーをリダイレクトしますsuggested in this answerとなります。 [:interesting_page] page "42"
をレンダリングするコントローラでは、私は成功したセッションredirect_toすることができる午前開発でsession[:interesting_page] = request.original_url
にセッションを設定する工夫確認時にメールで確認リンクに
をクリックした後、しかし、私がしようとするとキュウリ、カピバラ、電子メールを使ってこれをテストするためには、私は再接続する電子メール内のリンクをクリックしたときにそうsession[:interesting_page]
が削除される、電子メールのリンクをクリックしたときにセッションをリセットするようだ...
EDIT When I sign up and I confirm via the link in the email
ステップは、基本的に通過します登録コントローラを作成し、私はカピバラ::電子メールを使用して、confiをクリックしますメッセージメール
# Nested steps for "When I sign up and I confirm via the link in the email"
I fill in "email" with ...
...
I click "Sign up !"
Then I should see "Please confirm your account via the link !"
# At this stage session[:interesting_page] still exists and points to page "42"
And an email should have been sent to "#{user.email}"
And in the current mail I click "Je finalise mon inscription"
# The RegistrationController code I use is similar to devise and returns a pending_confirmation page
# respond_with resource, location: pending_confirmation_path
# Associated step implementations
Then(/an email should have been sent to "([^"]*)"/) do |address|
open_email(address)
expect(current_email).to be
end
When(/in the current mail I click "([^"]*)"$/) do |link|
current_email.click_link link
end
「あなたがサインアップしたときに電子メールのリンクを介して確認する」ステップ –
「興味深いページを訪問するときに」42 "'ステップ - 最後にこれらのステップが期待しているページを確実にすることが重要です実際にロードされています。これらの期待値が存在しない場合、セッションCookieがブラウザに決して設定されない可能性があります。 –
@ThomasWalpole私はちょうどステップコードを追加しました。また、私はキュウリを介して、電子メールのステップの前に他のページをロードしようとしてチェックし、セッションが実際に設定されました。 –