mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Fixed Tier events being created when Posts are edited
refs https://github.com/TryGhost/Team/issues/1875 - due to an misbehavior in our model layer, when `tiers` is set on a Post, it'll trigger a save of the Tier, and this produces an extra event in the `actions` table - mapping the Tier(s) to just the ID prevents bookshelf-relations from editing the Tier and thus prevents the extra event - also fixed tests which were implicitly assuming supplying a slug to a post would create the product
This commit is contained in:
parent
a27342c8ae
commit
79368f565f
@ -794,6 +794,12 @@ Post = ghostBookshelf.Model.extend({
|
||||
});
|
||||
}
|
||||
|
||||
if (this.get('tiers')) {
|
||||
this.set('tiers', this.get('tiers').map(t => ({
|
||||
id: t.id
|
||||
})));
|
||||
}
|
||||
|
||||
return sequence(ops);
|
||||
},
|
||||
|
||||
|
@ -72,11 +72,13 @@ describe('e2e {{#get}} helper', function () {
|
||||
published_at: new Date() // here to ensure sorting is not modified
|
||||
});
|
||||
|
||||
const defaultTier = await models.Product.findOne({slug: 'default-product'});
|
||||
|
||||
basicTierPost = await createPost({
|
||||
slug: 'tiers-post',
|
||||
visibility: 'tiers',
|
||||
tiers: [{
|
||||
slug: 'default-product'
|
||||
id: defaultTier.get('id')
|
||||
}],
|
||||
published_at: new Date() // here to ensure sorting is not modified
|
||||
});
|
||||
|
@ -54,11 +54,13 @@ describe('e2e {{#next_post}} helper', function () {
|
||||
published_at: new Date(2020, 0, 3) // here to ensure sorting is not modified
|
||||
});
|
||||
|
||||
const defaultTier = await models.Product.findOne({slug: 'default-product'});
|
||||
|
||||
basicTierPost = await createPost({
|
||||
slug: 'tiers-post',
|
||||
visibility: 'tiers',
|
||||
tiers: [{
|
||||
slug: 'default-product'
|
||||
id: defaultTier.get('id')
|
||||
}],
|
||||
published_at: new Date(2020, 0, 4) // here to ensure sorting is not modified
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user