카피 바라에서 가입 한 후 스마트 리다이렉션의 특정 흐름을 테스트해야합니다. 실제 구현을 위해카피 바라 이메일이 세션을 재설정합니다.
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. page "42"
를 렌더링하는 컨트롤러에서 나는 내가 세션 redirect_to 성공적으로 수 있어요 개발에 session[:interesting_page] = request.original_url
에 세션 설정 [을 : interesting_page] 내가하려고 할 때
그러나 이메일에있는 확인 링크를 클릭 한 후 유증 확인 중 Cucumber를 사용하여 이것을 테스트하려면 Capybara-email은 이메일 링크를 클릭 할 때 세션을 재설정하는 것으로 보입니다. 따라서 session[:interesting_page]
은 이메일의 링크를 클릭하면 제거됩니다 ...
EDIT When I sign up and I confirm via the link in the email
단계는 기본적으로 등록 컨트롤러를 고안하고 Capybara :: 전자 메일을 사용하여 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 단계 '마지막 단계에서 페이지에 대한 기대치를 확보하는 것이 중요합니다. 실제로로드되었습니다. 이러한 기대치가 없다면 세션 쿠키가 브라우저에 설정되지 않을 수도 있습니다. –
@ThomasWalpole 방금 단계 코드를 추가했습니다. 또한 나는 오이를 통해 전자 메일로 단계 전에 다른 페이지를로드하려고 시도하여 세션을 확인했으며 세션이 실제로 설정되었습니다. –