Test deprecation warning when not using an options hash as second parameter.

This commit is contained in:
Willem van Bergen 2011-09-15 15:51:30 -04:00
parent 41fea03342
commit 6d520803ee
2 changed files with 14 additions and 2 deletions

View File

@ -10,7 +10,7 @@ else
require 'active_support/time'
require 'active_support/json'
class MessageEncryptorTest < Test::Unit::TestCase
class MessageEncryptorTest < ActiveSupport::TestCase
class JSONSerializer
def dump(value)
@ -57,6 +57,12 @@ class MessageEncryptorTest < Test::Unit::TestCase
assert_equal encryptor.decrypt_and_verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" }
end
def test_digest_algorithm_as_second_parameter_deprecation
assert_deprecated(/options hash/) do
ActiveSupport::MessageEncryptor.new(SecureRandom.hex(64), 'aes-256-cbc')
end
end
private
def assert_not_decrypted(value)
assert_raise(ActiveSupport::MessageEncryptor::InvalidMessage) do

View File

@ -10,7 +10,7 @@ else
require 'active_support/time'
require 'active_support/json'
class MessageVerifierTest < Test::Unit::TestCase
class MessageVerifierTest < ActiveSupport::TestCase
class JSONSerializer
def dump(value)
@ -49,6 +49,12 @@ class MessageVerifierTest < Test::Unit::TestCase
message = verifier.generate({ :foo => 123, 'bar' => Time.utc(2010) })
assert_equal verifier.verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" }
end
def test_digest_algorithm_as_second_parameter_deprecation
assert_deprecated(/options hash/) do
ActiveSupport::MessageVerifier.new("secret", "SHA1")
end
end
def assert_not_verified(message)
assert_raise(ActiveSupport::MessageVerifier::InvalidSignature) do