I've come across a strange situation updating a rails 4.2 app to 5.1. For debugging purposes I have removed everything from the user model, it is now completely empty standard model:
class User < ActiveRecord::Base
end
I'm having problems with tests on this model and I've tracked it down to the behavior of will_save_change_to_password. The problem I am seeing is:
[1] pry> user = User.new(...)
=> #<User:0x007fa5abbe02f0 ... >
[2] pry> user.save
=> true
[3] pry> user.will_save_change_to_password?
=> nil
[2] pry> user
=> #<User:0x007fa5abbe02f0 ... >
[4] pry> user.will_save_change_to_password?
=> true
[5] pry> user.changes
=> {"username"=>["68c0bad3-d661-4008-9728-2dcb192f2ba1", "68c0bad3-d661-4008-9728-2dcb192f2ba1"], "password"=>["cebb41d5-5421-4de6-8c48-04ce735b1bb7", "cebb41d5-5421-4de6-8c48-04ce735b1bb7"]}
This is making absolutely no sense to me. After saving the model AR agrees there will be no change to the password. Then you access the user object (you can also call a method on the user object with the same effect) and suddenly it thinks the password will change. And if you ask it, it says the password is changing to the exact same password (same for username)!
I would LOVE any insight into wtf is going on here, I've been banging my head on the wall for a while on this one trying to understand it.