mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Removed deletable
property in favour of protected slugs
We couldn't decide on the best way to encode this in the database. e.g. deletable: true? or type: internal? but type conflicts with the storage of manual/automatic. For now we can use this, and add something in future if we're finding problems
This commit is contained in:
parent
cf83d169db
commit
16db3bbf17
2 changed files with 21 additions and 8 deletions
|
@ -48,8 +48,10 @@ export class Collection {
|
||||||
featureImage: string | null;
|
featureImage: string | null;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
deletable: boolean;
|
get deletable() {
|
||||||
_deleted: boolean = false;
|
return this.slug !== 'index' && this.slug !== 'featured';
|
||||||
|
}
|
||||||
|
private _deleted: boolean = false;
|
||||||
|
|
||||||
private _posts: string[];
|
private _posts: string[];
|
||||||
get posts() {
|
get posts() {
|
||||||
|
@ -151,7 +153,6 @@ export class Collection {
|
||||||
this.featureImage = data.featureImage;
|
this.featureImage = data.featureImage;
|
||||||
this.createdAt = data.createdAt;
|
this.createdAt = data.createdAt;
|
||||||
this.updatedAt = data.updatedAt;
|
this.updatedAt = data.updatedAt;
|
||||||
this.deletable = data.deletable;
|
|
||||||
this.deleted = data.deleted;
|
this.deleted = data.deleted;
|
||||||
this._posts = data.posts;
|
this._posts = data.posts;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +226,6 @@ export class Collection {
|
||||||
createdAt: Collection.validateDateField(data.created_at, 'created_at'),
|
createdAt: Collection.validateDateField(data.created_at, 'created_at'),
|
||||||
updatedAt: Collection.validateDateField(data.updated_at, 'updated_at'),
|
updatedAt: Collection.validateDateField(data.updated_at, 'updated_at'),
|
||||||
deleted: data.deleted || false,
|
deleted: data.deleted || false,
|
||||||
deletable: (data.deletable !== false),
|
|
||||||
posts: data.posts || []
|
posts: data.posts || []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,10 +286,10 @@ describe('Collection', function () {
|
||||||
assert.equal(collection.posts.length, 0);
|
assert.equal(collection.posts.length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Cannot set non deletable collection to deleted', async function () {
|
it('Cannot set index collection to deleted', async function () {
|
||||||
const collection = await Collection.create({
|
const collection = await Collection.create({
|
||||||
title: 'Testing adding posts',
|
title: 'Testing adding posts',
|
||||||
deletable: false
|
slug: 'index'
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(collection.deleted, false);
|
assert.equal(collection.deleted, false);
|
||||||
|
@ -299,10 +299,23 @@ describe('Collection', function () {
|
||||||
assert.equal(collection.deleted, false);
|
assert.equal(collection.deleted, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can set deletable collection to deleted', async function () {
|
it('Cannot set featured collection to deleted', async function () {
|
||||||
const collection = await Collection.create({
|
const collection = await Collection.create({
|
||||||
title: 'Testing adding posts',
|
title: 'Testing adding posts',
|
||||||
deletable: true
|
slug: 'featured'
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(collection.deleted, false);
|
||||||
|
|
||||||
|
collection.deleted = true;
|
||||||
|
|
||||||
|
assert.equal(collection.deleted, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Can set other collection to deleted', async function () {
|
||||||
|
const collection = await Collection.create({
|
||||||
|
title: 'Testing adding posts',
|
||||||
|
slug: 'non-internal-slug'
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(collection.deleted, false);
|
assert.equal(collection.deleted, false);
|
||||||
|
|
Loading…
Reference in a new issue