Sha256: 461ce874a688c6375062e14bd662e8b7eedfcf52617eff9e00ae7154947d42d6

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

require "test_helper"
require "active_support/core_ext/securerandom"

class ActiveStorage::VerifiedKeyWithExpirationTest < ActiveSupport::TestCase
  FIXTURE_KEY = SecureRandom.base58(24)

  test "without expiration" do
    encoded_key = ActiveStorage::VerifiedKeyWithExpiration.encode(FIXTURE_KEY)
    assert_equal FIXTURE_KEY, ActiveStorage::VerifiedKeyWithExpiration.decode(encoded_key)
  end

  test "with expiration" do
    encoded_key = ActiveStorage::VerifiedKeyWithExpiration.encode(FIXTURE_KEY, expires_in: 1.minute)
    assert_equal FIXTURE_KEY, ActiveStorage::VerifiedKeyWithExpiration.decode(encoded_key)

    travel 2.minutes
    assert_nil ActiveStorage::VerifiedKeyWithExpiration.decode(encoded_key)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activestorage-0.1 test/verified_key_with_expiration_test.rb