mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
parent
82c5fc7f5a
commit
7810140f15
4 changed files with 21 additions and 10 deletions
|
@ -131,7 +131,7 @@ module.exports = {
|
|||
query(frame) {
|
||||
return models.Post.edit(frame.data.posts[0], frame.options)
|
||||
.then((model) => {
|
||||
if (model.get('status') === 'published' ||
|
||||
if (model.get('status') === 'published' && model.wasChanged() ||
|
||||
model.get('status') === 'draft' && model.previous('status') === 'published') {
|
||||
this.headers.cacheInvalidate = true;
|
||||
} else if (model.get('status') === 'draft' && model.previous('status') !== 'published') {
|
||||
|
|
|
@ -91,9 +91,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
edit: {
|
||||
headers: {
|
||||
cacheInvalidate: true
|
||||
},
|
||||
headers: {},
|
||||
options: [
|
||||
'id',
|
||||
'include'
|
||||
|
@ -118,6 +116,12 @@ module.exports = {
|
|||
}));
|
||||
}
|
||||
|
||||
if (model.wasChanged()) {
|
||||
this.headers.cacheInvalidate = true;
|
||||
} else {
|
||||
this.headers.cacheInvalidate = false;
|
||||
}
|
||||
|
||||
return model;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -69,9 +69,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
edit: {
|
||||
headers: {
|
||||
cacheInvalidate: true
|
||||
},
|
||||
headers: {},
|
||||
options: [
|
||||
'id',
|
||||
'include'
|
||||
|
@ -98,6 +96,12 @@ module.exports = {
|
|||
}));
|
||||
}
|
||||
|
||||
if (model.wasChanged()) {
|
||||
this.headers.cacheInvalidate = true;
|
||||
} else {
|
||||
this.headers.cacheInvalidate = false;
|
||||
}
|
||||
|
||||
return model;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -125,14 +125,15 @@ describe('Posts API', function () {
|
|||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
||||
// @NOTE: you cannot modify published_at manually, that's why the resource won't change.
|
||||
should.not.exist(res.headers['x-cache-invalidate']);
|
||||
should.exist(res.body.posts);
|
||||
should.exist(res.body.posts[0].published_at);
|
||||
localUtils.API.checkResponse(res.body.posts[0], 'post');
|
||||
});
|
||||
});
|
||||
|
||||
it('update dates', function () {
|
||||
it('update dates & x_by', function () {
|
||||
const post = {
|
||||
created_by: ObjectId.generate(),
|
||||
updated_by: ObjectId.generate(),
|
||||
|
@ -148,7 +149,9 @@ describe('Posts API', function () {
|
|||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
||||
// @NOTE: you cannot modify these fields above manually, that's why the resource won't change.
|
||||
should.not.exist(res.headers['x-cache-invalidate']);
|
||||
|
||||
localUtils.API.checkResponse(res.body.posts[0], 'post');
|
||||
|
||||
return models.Post.findOne({
|
||||
|
|
Loading…
Add table
Reference in a new issue