diff options
Diffstat (limited to 'test/models/verified_key_with_expiration_test.rb')
-rw-r--r-- | test/models/verified_key_with_expiration_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/models/verified_key_with_expiration_test.rb b/test/models/verified_key_with_expiration_test.rb new file mode 100644 index 0000000000..ee4dc7e02e --- /dev/null +++ b/test/models/verified_key_with_expiration_test.rb @@ -0,0 +1,19 @@ +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 |