Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transitioning password should not set password_changed? true #722

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/acts_as_authentic_test/password_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +96 to +109
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something simpler work too, vs using callbacks? I don't think the record would get reloaded, so we could do e.g.

     ben = transition_password_to(Authlogic::CryptoProviders::BCrypt, users(:ben)).first
     refute ben.send(:password_changed?)`

Or, maybe we should just move this assertion into transition_password_to?

end

def test_v2_crypto_provider_transition
ben = users(:ben)

Expand Down