Ghost/core/test/unit/data
kirrg001 00cf043e15 Fixed missing defaults in model layer
no issue

- reported in the forum: https://forum.ghost.org/t/publishing-with-a-single-post-request-to-posts/1648
- the defaults are defined in two places
  1. on the schema level (defaults for the database)
  2. on the ORM (model layer)
- the defaults on the db layer are set correctly when inserting a new resource
- but if we don't apply all defaults on the model layer, it will happen that model events are emitted without the correct defaults
  - see comment in code base
  - it's caused by the fact that knex only returns the inserted resource id (probably caused by the fact knex has to support x databases)
- components/modules are listening on model events and expect:
  1. a complete set of attributes
  2. a complete set of defaults
  3. sanitized values e.g. bool, date
- this commit fixes:
  1. added missing defaults for user & post model
  2. sanitize booleans (0|1 => false|true)
  3. added tests to ensure this works as expected
  4. clarfies the usage of `defaults`

Regarding https://forum.ghost.org/t/publishing-with-a-single-post-request-to-posts/1648:
  - the post event was emitted with the following values {page: undefined, featured: undefined}
  - the urlservice receives this event and won't match the resource against collection filters correctly
  - NOTE: the post data in the db were correct
2018-06-26 16:35:23 +02:00
..
db Removed old jshint/jscs rules 2018-06-02 21:48:23 +02:00
export Multiple authors (#9426) 2018-03-27 15:16:15 +01:00
importer Import lib/common only 2017-12-12 10:28:13 +01:00
meta Dynamic Routing Beta: collection name behaviour 2018-06-21 20:59:43 +02:00
schema Changed theme fixture post: point to forum instead of slack (#9703) 2018-06-25 22:06:21 +02:00
validation Fixed missing defaults in model layer 2018-06-26 16:35:23 +02:00
xml/sitemap Dynamic Routing Beta (#9596) 2018-06-05 19:02:20 +02:00