aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-07-26 12:48:55 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-07-26 12:51:53 +0900
commit971cd757eaeb6da34a256b35457749d067073c03 (patch)
treee837833f4398b68459f7a08640cb286b6666a8ea /activesupport/test
parente5dc101cc51c89b0c585fbe7f40d72408bec19c6 (diff)
downloadrails-971cd757eaeb6da34a256b35457749d067073c03.tar.gz
rails-971cd757eaeb6da34a256b35457749d067073c03.tar.bz2
rails-971cd757eaeb6da34a256b35457749d067073c03.zip
Use correct variable in `secure_compare!`
`Messages::Rotator` has `@on_rotation` not `@rotation`. https://github.com/rails/rails/blob/72bc0806a7b378cd544e8fbf7ab22d74b7913ffb/activesupport/lib/active_support/messages/rotator.rb#L11
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/secure_compare_rotator_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/secure_compare_rotator_test.rb b/activesupport/test/secure_compare_rotator_test.rb
index 8acf13e38f..d80faea128 100644
--- a/activesupport/test/secure_compare_rotator_test.rb
+++ b/activesupport/test/secure_compare_rotator_test.rb
@@ -41,4 +41,17 @@ class SecureCompareRotatorTest < ActiveSupport::TestCase
assert_equal(true, wrapper.secure_compare!("and_another_one", on_rotation: -> { @witness = true }))
end
end
+
+ test "#secure_compare! calls the on_rotation proc that given in constructor" do
+ @witness = nil
+
+ wrapper = ActiveSupport::SecureCompareRotator.new("old_secret", on_rotation: -> { @witness = true })
+ wrapper.rotate("new_secret")
+ wrapper.rotate("another_secret")
+ wrapper.rotate("and_another_one")
+
+ assert_changes(:@witness, from: nil, to: true) do
+ assert_equal(true, wrapper.secure_compare!("and_another_one"))
+ end
+ end
end