Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # user.rb
- #
- #
- protected
- def validate
- errors.add(:old_password, "Указан неверный пароль.") if (self.changing_password && (old_password.to_s.crypt(PASSWORD_SALT) != password))
- end
- # user_spec.rb
- #
- #
- it "should require old password to change to new" do
- user = User.find(1)
- user.changing_password = true
- user.update_attributes(:new_password => "1234567", :new_password_confirmation => "1234567").should == false
- user.update_attributes(:new_password => "1234567", :new_password_confirmation => "1234567", :old_password => "123").should == true
Add Comment
Please, Sign In to add comment