-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix locking with unsaved changes bug #1340
base: master
Are you sure you want to change the base?
Fix locking with unsaved changes bug #1340
Conversation
@mrkrlli Thank you very much for actually doing it, I couldn't find time to fix my PR :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
# At this point restore the attributes so we can obtain the lock | ||
# otherwise an exception is thrown while trying to obtain the lock | ||
# with unsaved data on the resource. | ||
unless const_defined?('Mongoid') do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# At this point restore the attributes so we can obtain the lock | ||
# otherwise an exception is thrown while trying to obtain the lock | ||
# with unsaved data on the resource. | ||
@resource.restore_attributes unless const_defined?('Mongoid') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's breaking the specs, I think you have to use defined?
instead, const_defined?
is with Module.const_defined?("something")
@MaicolBen Made the change, sorry it took so long. |
@MaicolBen @Tiltorito
attr_encrypted
andlockbox
gems, since they re-encrypt data on validation.valid?
leaves unsaved changes, which throws an error when calling@resource.with_lock