We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
65 lines
2.0 KiB
Ruby
65 lines
2.0 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Verify email" do
|
|
scenario "Verify" do
|
|
user = create(:user,
|
|
residence_verified_at: Time.current,
|
|
document_number: "12345678Z",
|
|
document_type: "dni")
|
|
|
|
verified_user = create(:verified_user,
|
|
document_number: "12345678Z",
|
|
document_type: "dni",
|
|
email: "rock@example.com")
|
|
|
|
login_as(user)
|
|
|
|
visit verified_user_path
|
|
|
|
within("#verified_user_#{verified_user.id}_email") do
|
|
expect(page).to have_content "roc*@example.com"
|
|
click_button "Send code"
|
|
end
|
|
|
|
expect(page).to have_content "We have sent a confirmation email to your account: rock@example.com"
|
|
|
|
sent_token = /.*email_verification_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1]
|
|
visit email_path(email_verification_token: sent_token)
|
|
|
|
expect(page).to have_content "You are a verified user"
|
|
|
|
expect(page).not_to have_link "Verify my account"
|
|
expect(page).to have_content "Account verified"
|
|
end
|
|
|
|
scenario "Errors on token verification" do
|
|
user = create(:user, residence_verified_at: Time.current)
|
|
|
|
login_as(user)
|
|
visit email_path(email_verification_token: "1234")
|
|
|
|
expect(page).to have_content "Verification code incorrect"
|
|
end
|
|
|
|
scenario "Errors on sending confirmation email" do
|
|
user = create(:user,
|
|
residence_verified_at: Time.current,
|
|
document_number: "12345678Z",
|
|
document_type: "dni")
|
|
|
|
verified_user = create(:verified_user,
|
|
document_number: "12345678Z",
|
|
document_type: "dni",
|
|
email: "rock@example.com")
|
|
|
|
login_as(user)
|
|
|
|
visit verified_user_path
|
|
|
|
verified_user.destroy!
|
|
click_button "Send code"
|
|
|
|
expect(page).to have_content "There was a problem with sending an email to your account"
|
|
end
|
|
end
|