My custom validation seems to run before my before_save
block, which is odd to me. I'm aware of before_validation
, but I'm trying to test my custom validator, so a before_validation hook wouldn't allow me to. I've also read that testing a private method (my validator) is bad practice. What should I do?
More info: We want users to be able to upload a Document with either a URL or File, but not both or none (xor). My validator checks the xor of these. If a user edits a Document, the before_save
hook removes the current URL or File. In theory, the flow should be:
- Upload file
- Validate and save
- Upload URL
- before_save, validate, save
But in my tests, I get validation errors, suggesting that the before_save
is not occurring.
Aucun commentaire:
Enregistrer un commentaire