Sha256: 5a24a829a15f2f3c86084fb82549fd9d7fd8de6c6bead4747b6a3f0d6b00b059

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

require "test_helper"

class Identity::EmailVerificationsControllerTest < ActionDispatch::IntegrationTest
  setup do
    @user, @token = sign_in_as(users(:lazaro_nixon))
    @user.update! verified: false
  end

  def default_headers
    { "Authorization" => "Bearer #{@token}" }
  end

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

    assert_response :no_content
  end

  test "should verify email" do
    sid = @user.create_email_verification_token.signed_id(expires_in: 2.days)

    get edit_identity_email_verification_url, params: { sid: sid }, headers: default_headers
    assert_response :no_content
  end

  test "should not verify email with expired token" do
    sid_exp = @user.create_email_verification_token.signed_id(expires_in: 0.minutes)

    get edit_identity_email_verification_url, params: { sid: sid_exp }, headers: default_headers
    assert_response :bad_request
    assert_equal "That email verification link is invalid", response.parsed_body["error"]
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
authentication-zero-2.15.5 lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.15.4 lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.15.3 lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.15.2 lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.15.1 lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.15.0 lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.14.0 lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt
authentication-zero-2.13.0 lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt