Permalink
Browse files

Test deprecation warning when not using an options hash as second par…

…ameter.
  • Loading branch information...
1 parent 41fea03 commit 6d520803ee005d47c876662ba426083e823199ed @wvanbergen wvanbergen committed Sep 15, 2011
Showing with 14 additions and 2 deletions.
  1. +7 −1 activesupport/test/message_encryptor_test.rb
  2. +7 −1 activesupport/test/message_verifier_test.rb
View
8 activesupport/test/message_encryptor_test.rb
@@ -10,7 +10,7 @@
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 @@ def test_alternative_serialization_method
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
8 activesupport/test/message_verifier_test.rb
@@ -10,7 +10,7 @@
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 @@ def test_alternative_serialization_method
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

0 comments on commit 6d52080

Please sign in to comment.