Sha256: 02438f05357b067846082c4857df7e5ecda765bf0261d597eb757b011d323614

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

require "test_helper"

class Identity::EmailVerificationsControllerTest < ActionDispatch::IntegrationTest
  setup do
    @user = sign_in_as(users(:lazaro_nixon))
    @sid = @user.signed_id(purpose: @user.email, expires_in: 20.minutes)
    @sid_exp = @user.signed_id(purpose: @user.email, expires_in: 0.minutes)

    @user.update! verified: false
  end

  test "should send a verification email" do
    assert_enqueued_email_with UserMailer, :email_verify_confirmation, args: { user: @user } do
      post identity_email_verification_url
    end

    assert_redirected_to root_url
  end

  test "should verify email" do
    get edit_identity_email_verification_url(token: @sid, email: @user.email)
    assert_redirected_to root_url
  end

  test "should not verify email with expired token" do
    get edit_identity_email_verification_url(token: @sid_exp, email: @user.email)

    assert_redirected_to edit_identity_email_url
    assert_equal "That email verification link is invalid", flash[:alert]
  end

  test "should not verify email with previous token" do
    @user.update! email: "other_email@hey.com"

    get edit_identity_email_verification_url(token: @sid, email: @user.email_previously_was)

    assert_redirected_to edit_identity_email_url
    assert_equal "That email verification link is invalid", flash[:alert]
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
authentication-zero-2.12.4 lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.12.3 lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.12.2 lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.12.1 lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.12.0 lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt