1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/test/verified_key_with_expiration_test.rb
David Heinemeier Hansson c624df326a ActiveVault -> ActiveStorage
Yaroslav agreed to hand over the gem name ❤️
2017-07-06 11:33:29 +02:00

19 lines
724 B
Ruby

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