0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Removed use of author_id syntax in fixtures

refs https://github.com/TryGhost/Toolbox/issues/230

 - The `author_id` would be ignored as a parameter in the API or Post model, so would produce a falsy results if specific fixtures were used to compare test results
This commit is contained in:
Naz 2022-05-02 14:53:28 +08:00 committed by naz
parent 625f83af09
commit b71c1895fb

View file

@ -88,7 +88,7 @@ data.posts = [
slug: 'first-post', slug: 'first-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[0].id] tags: [data.tags[0].id]
}, },
{ {
@ -97,7 +97,7 @@ data.posts = [
slug: 'second-post', slug: 'second-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[1].id, authors: [{id: data.users[1].id}],
tags: [data.tags[1].id, data.tags[2].id, data.tags[3].id, data.tags[5].id] tags: [data.tags[1].id, data.tags[2].id, data.tags[3].id, data.tags[5].id]
}, },
{ {
@ -106,7 +106,7 @@ data.posts = [
slug: 'third-post', slug: 'third-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[1].id] tags: [data.tags[1].id]
}, },
{ {
@ -115,7 +115,7 @@ data.posts = [
slug: 'fourth-post', slug: 'fourth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[2].id] tags: [data.tags[2].id]
}, },
{ {
@ -124,7 +124,7 @@ data.posts = [
slug: 'fifth-post', slug: 'fifth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: true, featured: true,
author_id: data.users[1].id, authors: [{id: data.users[1].id}],
tags: [data.tags[5].id] tags: [data.tags[5].id]
}, },
{ {
@ -133,7 +133,7 @@ data.posts = [
slug: 'sixth-post', slug: 'sixth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[1].id, authors: [{id: data.users[1].id}],
feature_image: 'some/image/path.jpg', feature_image: 'some/image/path.jpg',
tags: [data.tags[0].id, data.tags[3].id, data.tags[5].id] tags: [data.tags[0].id, data.tags[3].id, data.tags[5].id]
}, },
@ -143,7 +143,7 @@ data.posts = [
slug: 'seventh-post', slug: 'seventh-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
feature_image: 'some/image/path.jpg', feature_image: 'some/image/path.jpg',
tags: [data.tags[0].id, data.tags[2].id] tags: [data.tags[0].id, data.tags[2].id]
}, },
@ -153,7 +153,7 @@ data.posts = [
slug: 'eighth-post', slug: 'eighth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: true, featured: true,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[0].id, data.tags[2].id, data.tags[3].id] tags: [data.tags[0].id, data.tags[2].id, data.tags[3].id]
}, },
{ {
@ -162,7 +162,7 @@ data.posts = [
slug: 'ninth-post', slug: 'ninth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[1].id, data.tags[3].id] tags: [data.tags[1].id, data.tags[3].id]
}, },
{ {
@ -171,7 +171,7 @@ data.posts = [
slug: 'tenth-post', slug: 'tenth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[2].id] tags: [data.tags[2].id]
}, },
{ {
@ -180,7 +180,7 @@ data.posts = [
slug: 'eleventh-post', slug: 'eleventh-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
feature_image: 'some/image/path.jpg', feature_image: 'some/image/path.jpg',
tags: [data.tags[1].id] tags: [data.tags[1].id]
}, },
@ -190,7 +190,7 @@ data.posts = [
slug: 'twelfth-post', slug: 'twelfth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[3].id] tags: [data.tags[3].id]
}, },
{ {
@ -199,7 +199,7 @@ data.posts = [
slug: 'thirteenth-post', slug: 'thirteenth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [] tags: []
}, },
{ {
@ -208,7 +208,7 @@ data.posts = [
slug: 'fourteenth-post', slug: 'fourteenth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: true, featured: true,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[3].id] tags: [data.tags[3].id]
}, },
{ {
@ -218,7 +218,7 @@ data.posts = [
mobiledoc: markdownToMobiledoc('Hello World! I am a featured page'), mobiledoc: markdownToMobiledoc('Hello World! I am a featured page'),
featured: true, featured: true,
page: 1, page: 1,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [] tags: []
}, },
{ {
@ -227,7 +227,7 @@ data.posts = [
slug: 'sixteenth-post', slug: 'sixteenth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [] tags: []
}, },
{ {
@ -236,7 +236,7 @@ data.posts = [
slug: 'seventeenth-post', slug: 'seventeenth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [] tags: []
}, },
{ {
@ -245,7 +245,7 @@ data.posts = [
slug: 'eighteenth-post', slug: 'eighteenth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [] tags: []
}, },
{ {
@ -255,7 +255,7 @@ data.posts = [
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
status: 'draft', status: 'draft',
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[0].id, data.tags[1].id, data.tags[2].id, data.tags[3].id] tags: [data.tags[0].id, data.tags[1].id, data.tags[2].id, data.tags[3].id]
}, },
{ {
@ -264,7 +264,7 @@ data.posts = [
slug: 'twentieth-post', slug: 'twentieth-post',
mobiledoc: markdownToMobiledoc('Hello World!'), mobiledoc: markdownToMobiledoc('Hello World!'),
featured: false, featured: false,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [] tags: []
}, },
{ {
@ -274,7 +274,7 @@ data.posts = [
mobiledoc: markdownToMobiledoc('About Me!'), mobiledoc: markdownToMobiledoc('About Me!'),
featured: false, featured: false,
page: 1, page: 1,
author_id: data.users[0].id, authors: [{id: data.users[0].id}],
tags: [data.tags[0].id, data.tags[1].id, data.tags[2].id, data.tags[3].id] tags: [data.tags[0].id, data.tags[1].id, data.tags[2].id, data.tags[3].id]
} }
]; ];
@ -337,12 +337,16 @@ function createPosts(knex, DataGenerator) {
}); });
_.each(data.posts, function (post) { _.each(data.posts, function (post) {
if (post.authors) {
_.each(post.authors, function (author) {
postsAuthors.push({ postsAuthors.push({
id: ObjectId().toHexString(), id: ObjectId().toHexString(),
post_id: post.id, post_id: post.id,
author_id: post.author_id author_id: author.id
}); });
}); });
}
});
// Next, insert it into the database & return the correctly indexed data // Next, insert it into the database & return the correctly indexed data
return writeFetchFix(knex, 'posts').then(function (createdPosts) { return writeFetchFix(knex, 'posts').then(function (createdPosts) {