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

Don't require ActiveRecord #48

Conversation

BjarneD
Copy link
Contributor

@BjarneD BjarneD commented Apr 23, 2024

The existing way to decide what method to look at as a condition to validation had 2 issues:

  1. If a project weren't using ActiveRecord it couldn't use the method will_save_change_to_encrypted_password? However projects with a mongo database will be supporting this from version 8.1.0 https://jira.mongodb.com/browse/MONGOID-4528
  2. If a project uses multiple databases. Eg. one using ActiveRecord and another using mongo before version 8.1.0. In this case ActiveRecord would be defined, however not on the model if the user model (resource) is a mongo based model. It would throw an error of undefined method.

The simple fix is to just check that the method exists.

Test passes with the fix:

devise-pwned_password % bin/test
Run options: --seed 898

# Running:

...........

Finished in 2.609481s, 4.2154 runs/s, 11.1133 assertions/s.
11 runs, 29 assertions, 0 failures, 0 errors, 0 skips

Thanks for creating and maintaining the gem.

@michaelbanfield michaelbanfield merged commit 70d01e8 into michaelbanfield:master Apr 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants