From 97140ecedf945f6be524f9a387c9a6c4cef22bd8 Mon Sep 17 00:00:00 2001 From: Paul Duey Date: Thu, 28 May 2020 13:39:53 -0400 Subject: [PATCH] add failing test that calls transition_password_to with after_update :test_callback, unless: :password_changed? --- test/acts_as_authentic_test/password_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/acts_as_authentic_test/password_test.rb b/test/acts_as_authentic_test/password_test.rb index e13c76dd..b9171eea 100644 --- a/test/acts_as_authentic_test/password_test.rb +++ b/test/acts_as_authentic_test/password_test.rb @@ -92,6 +92,23 @@ def test_transitioning_password ) end + def test_password_changed_false_if_transitioning + User.class_eval do + after_update :verify_not_changed, unless: :password_changed? + def verify_not_changed; end + end + ben = users(:ben) + mock_method = MiniTest::Mock.new + mock_method.expect :call, nil + ben.stub :verify_not_changed, mock_method do + transition_password_to(Authlogic::CryptoProviders::BCrypt, ben) + end + mock_method.verify + User.class_eval do + User.skip_callback :update, :after, :verify_not_changed + end + end + def test_v2_crypto_provider_transition ben = users(:ben)