aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/message_verifier_test.rb
diff options
context:
space:
mode:
authorKostiantyn Kahanskyi <kostiantyn.kahanskyi@googlemail.com>2014-09-12 14:58:04 +0200
committerKostiantyn Kahanskyi <kostiantyn.kahanskyi@googlemail.com>2014-09-12 15:09:00 +0200
commit4bf9d1938bb144ef2a6c3d03a2d01add62e90114 (patch)
treec881ff8cf675795aa9057957dd3f6615820b4eb1 /activesupport/test/message_verifier_test.rb
parentb259b06e73a44f87654d26759b0a679e1ecc069c (diff)
downloadrails-4bf9d1938bb144ef2a6c3d03a2d01add62e90114.tar.gz
rails-4bf9d1938bb144ef2a6c3d03a2d01add62e90114.tar.bz2
rails-4bf9d1938bb144ef2a6c3d03a2d01add62e90114.zip
MessageVerifier raises an appropriate exception if the secret is nil
Otherwise this will lead to another error later on when generating a signature: TypeError (no implicit conversion of nil into String).
Diffstat (limited to 'activesupport/test/message_verifier_test.rb')
-rw-r--r--activesupport/test/message_verifier_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb
index a5748d28ba..28035bc428 100644
--- a/activesupport/test/message_verifier_test.rb
+++ b/activesupport/test/message_verifier_test.rb
@@ -69,6 +69,13 @@ class MessageVerifierTest < ActiveSupport::TestCase
"undefined class/module MessageVerifierTest::AutoloadClass"], exception.message
end
+ def test_raise_error_when_secret_is_nil
+ exception = assert_raise(ArgumentError) do
+ ActiveSupport::MessageVerifier.new(nil)
+ end
+ assert_equal exception.message, 'Secret should not be nil.'
+ end
+
def assert_not_verified(message)
assert_raise(ActiveSupport::MessageVerifier::InvalidSignature) do
@verifier.verify(message)