我在 rails 3.2 上使用capybara/rspec/selenium/devise_invitable
请参阅此规范,它邀请用户并通过邮件发送邀请 url。我从电子邮件正文中提取了invitation_token 并尝试访问接受邀请的网址,如下所示。('/users/invitation/accept?' + inv_token )
仅供参考:如果我不设置它会起作用:js => true
require 'spec_helper'
describe "LoginSpec" do
it "Click enquiries tabs", :js => true do
build(:user) do |user|
user.invite!
last_email.to.should include(user.email)
inv_url = Capybara.string(last_email.body.encoded).first(".inbox > a")[:href]
inv_token = inv_url.split("?")[1]
inv_url_final = '/users/invitation/accept?' + inv_token
visit inv_url_final
end
end
end
但这一直重定向到“/users/sign_in”。这是测试日志。
Started GET "/users/invitation/accept?invitation_token=Ww-y2QbgsswZCgovAzWx" for 127.0.0.1 at 2014-01-30 04:47:14 +0530
Processing by Users::InvitationsController#edit as HTML
Parameters: {"invitation_token"=>"Ww-y2QbgsswZCgovAzWx"}
[1m[36mUser Load (0.7ms)[0m [1mSELECT `users`.* FROM `users` WHERE `users`.`invitation_token` = 'e75e32adac5414243930d19e927c8a6275c404b8296757e77dc4a49b2593882a' LIMIT 1[0m
[1m[35mUser Load (0.6ms)[0m SELECT `users`.* FROM `users` WHERE `users`.`invitation_token` = 'Ww-y2QbgsswZCgovAzWx' LIMIT 1
Redirected to http://127.0.0.1:56113/
Filter chain halted as :resource_from_invitation_token rendered or redirected
有什么帮助吗?