Ghost/core/test/integration/model
Katharina Irrgang 7c6f690eb5 🐛 Fixed updated_at not being updated (#9532)
closes #9520

- it contains a dependency bump of the latest Bookshelf release
- Bookshelf introduced a bug in the last release
  - see https://github.com/bookshelf/bookshelf/pull/1583
  - see https://github.com/bookshelf/bookshelf/pull/1798
- this has caused trouble in Ghost
  - the `updated_at` attribute was not automatically set anymore

---

The bookshelf added one breaking change: it's allow to pass custom `updated_at` and `created_at`.
We already have a protection for not being able to override the `created_at` date on update.
We had to add another protection to now allow to only change the `updated_at` property.
You can only change `updated_at` if you actually change something else e.g. the title of a post.

To be able to implement this check i discovered that Bookshelfs `model.changed` object has a tricky behaviour.
It remembers **all** attributes, which where changed, doesn't matter if they are valid or invalid model properties.
We had to add a line of code to avoid remembering none valid model attributes in this object.

e.g. you change `tag.parent` (no valid model attribute). The valid property is `tag.parent_id`.
     If you pass `tag.parent` but the value has **not** changed (`tag.parent` === `tag.parent_id`), it will output you `tag.changed.parent`. But this is wrong.
     Bookshelf detects `changed` attributes too early. Or if you think the other way around, Ghost detects valid attributes too late.
     But the current earliest possible stage is the `onSaving` event, there is no earlier way to pick valid attributes (except of `.forge`, but we don't use this fn ATM).
     Later: the API should transform `tag.parent` into `tag.parent_id`, but we are not using it ATM, so no need to pre-optimise.
     The API already transforms `post.author` into `post.author_id`.
2018-03-26 14:12:02 +01:00
..
base Update Notification improvements (#9123) 2018-01-09 15:20:00 +01:00
model_accesstoken_spec.js Moved utils constants to lib/constants 2017-12-14 14:13:40 +01:00
model_app-fields_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
model_app-settings_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
model_apps_spec.js Moved pipeline/sequence to lib/promise 2017-12-13 22:20:02 +01:00
model_invite_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
model_permissions_spec.js Sorted out the mixed usages of include and withRelated (#9425) 2018-02-15 10:53:53 +01:00
model_posts_spec.js 🐛 Fixed updated_at not being updated (#9532) 2018-03-26 14:12:02 +01:00
model_roles_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
model_settings_spec.js Import lib/common only 2017-12-12 10:28:13 +01:00
model_tags_spec.js Sorted out the mixed usages of include and withRelated (#9425) 2018-02-15 10:53:53 +01:00
model_users_spec.js Removed isNew usages in model layer 2018-02-15 22:11:49 +01:00