Ghost/core/test/unit/data
Katharina Irrgang 0aff9f33d9
Improved validation layer (#9427)
refs https://github.com/TryGhost/Ghost/issues/3658

- the `validateSchema` helper was a bit broken
  - if you add a user without email, you will receive a database error
  - but the validation error should catch that email is passed with null
- it was broken, because:
  - A: it called `toJSON` -> this can remove properties from the output (e.g. password)
  - B: we only validated fields, which were part of the JSON data (model.hasOwnProperty)
- we now differentiate between schema validation for update and insert
- fixed one broken import test
  - if you import a post without a status, it should not error
  - it falls back to the default value
- removed user model `onValidate`
  - the user model added a custom implementation of `onValidate`, because of a bug which we experienced (see https://github.com/TryGhost/Ghost/issues/3638)
  - with the refactoring this is no longer required - we only validate fields which have changed when updating resources
  - also, removed extra safe catch when logging in (no longer needed - unit tested)
- add lot's of unit tests to proof the code change
- always call the base class, except you have a good reason
2018-02-16 00:49:15 +01:00
..
db Tidy up unit test files (#9340) 2017-12-14 03:36:50 +01:00
export Tidy up unit test files (#9340) 2017-12-14 03:36:50 +01:00
importer Import lib/common only 2017-12-12 10:28:13 +01:00
meta Moved image utils to lib/image 2017-12-14 20:46:53 +01:00
schema Contributor Role (#9315) 2018-02-07 10:46:22 +01:00
validation Improved validation layer (#9427) 2018-02-16 00:49:15 +01:00
xml/sitemap Tidy up unit test files (#9340) 2017-12-14 03:36:50 +01:00