Guest User

Untitled

a guest
May 28th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # user.rb
  2. #
  3. #
  4.  
  5. protected
  6.  
  7. def validate
  8. errors.add(:old_password, "Указан неверный пароль.") if (self.changing_password && (old_password.to_s.crypt(PASSWORD_SALT) != password))
  9. end
  10.  
  11.  
  12. # user_spec.rb
  13. #
  14. #
  15. it "should require old password to change to new" do
  16. user = User.find(1)
  17. user.changing_password = true
  18. user.update_attributes(:new_password => "1234567", :new_password_confirmation => "1234567").should == false
  19. user.update_attributes(:new_password => "1234567", :new_password_confirmation => "1234567", :old_password => "123").should == true
Add Comment
Please, Sign In to add comment