Devise “Confirmation token is invalid” when user signs up

前端 未结 3 1828
感动是毒
感动是毒 2020-12-09 00:47

Using Rails 4 and Devise 3.1.0 on my web app. I wrote a Cucumber test to test user sign up; it fails when the \"confirm my account\" link is clicked from the e-mail.

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 01:44

    A friend of mine just found this question and emailed me asking if I had figured this out, which reminded me that I never submitted my own answer, so here goes :)

    I ended up resetting the token & using send to get the raw token. It's ugly, but it works in a punch for devise (3.5.1).

    26   it "should auto create org" do
    27     email = FG.generate :email
    28     visit new_user_registration_path
    29     fill_in :user_name, with: 'Ryan Angilly'
    30     fill_in :user_user_provided_email, with: email
    31     fill_in :user_password, with: '1234567890'
    32 
    33     expect do
    34       click_button 'Continue'
    35     end.to change { Organization.count }.by(1)
    36 
    37     expect(page.current_path).to eq(confirmation_required_path)
    38     u = User.where(email: email).first
    39     u.send :generate_confirmation_token
    40     email_token = u.instance_variable_get(:@raw_confirmation_token)
    41     u.save!
    42     os = u.organizations
    43     expect(os.size).to eq(1)
    44     visit user_confirmation_path(confirmation_token: email_token)
    45     o = os.first
    46 
    47     u.reload
    48     expect(u.confirmed?)
    49     expect(page.current_url).to eq(organization_getting_started_url(o))
    50   end
    

提交回复
热议问题