Skip to content

Commit

Permalink
📖 new default post content (#8548)
Browse files Browse the repository at this point in the history
closes #8542
- updates default post fixtures
- adds default logo and cover images to settings fixtures
- update tests due to coupling to dev/prod fixtures
  • Loading branch information
kevinansfield authored and cobbspur committed Jun 8, 2017
1 parent d823412 commit f675a96
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 98 deletions.
6 changes: 3 additions & 3 deletions core/server/apps/amp/tests/router_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('AMP getPostData', function () {
beforeEach(function () {
res = {
locals: {
relativeUrl: '/welcome-to-ghost/amp/'
relativeUrl: '/welcome/amp/'
}
};

Expand All @@ -168,7 +168,7 @@ describe('AMP getPostData', function () {
postLookupStub.returns(new Promise.resolve({
post: {
id: '1',
slug: 'welcome-to-ghost'
slug: 'welcome'
}
}));

Expand All @@ -177,7 +177,7 @@ describe('AMP getPostData', function () {
ampController.getPostData(req, res, function () {
req.body.post.should.be.eql({
id: '1',
slug: 'welcome-to-ghost'
slug: 'welcome'
}
);
done();
Expand Down
2 changes: 1 addition & 1 deletion core/server/apps/private-blogging/tests/middleware_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('Private Blogging', function () {
});

it('authenticatePrivateSession should redirect if hash is not verified', function (done) {
req.url = '/welcome-to-ghost';
req.url = '/welcome';
req.session = {
token: 'wrongpassword',
salt: Date.now().toString()
Expand Down
4 changes: 2 additions & 2 deletions core/server/data/schema/default-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"defaultValue": "Just a blogging platform."
},
"logo": {
"defaultValue": ""
"defaultValue": "https://casper.ghost.org/v1.0.0/images/ghost-logo.svg"
},
"cover_image": {
"defaultValue": ""
"defaultValue": "https://casper.ghost.org/v1.0.0/images/blog-cover.jpg"
},
"icon": {
"defaultValue": ""
Expand Down
78 changes: 75 additions & 3 deletions core/server/data/schema/fixtures/fixtures.json

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions core/server/data/slack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,27 @@ function ping(post, options) {

return getSlackSettings().then(function (slackSettings) {
// Quit here if slack integration is not activated
var defaultPostSlugs = [
'welcome',
'the-editor',
'using-tags',
'managing-users',
'private-sites',
'advanced-markdown',
'themes'
];

if (slackSettings.url && slackSettings.url !== '') {
// Only ping when not a page
if (post.page) {
return;
}

// Don't ping for the welcome to ghost post.
// Don't ping for the default posts.
// This also handles the case where during ghost's first run
// models.init() inserts this post but permissions.init() hasn't
// (can't) run yet.
if (post.slug === 'welcome-to-ghost') {
if (defaultPostSlugs.indexOf(post.slug) > -1) {
return;
}

Expand Down
15 changes: 12 additions & 3 deletions core/server/data/xml/xmlrpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,26 @@ pingList = [{
function ping(post) {
var pingXML,
title = post.title,
url = utils.url.urlFor('post', {post: post}, true);
url = utils.url.urlFor('post', {post: post}, true),
defaultPostSlugs = [
'welcome',
'the-editor',
'using-tags',
'managing-users',
'private-sites',
'advanced-markdown',
'themes'
];

if (post.page || config.isPrivacyDisabled('useRpcPing')) {
return;
}

// Don't ping for the welcome to ghost post.
// Don't ping for the default posts.
// This also handles the case where during ghost's first run
// models.init() inserts this post but permissions.init() hasn't
// (can't) run yet.
if (post.slug === 'welcome-to-ghost') {
if (defaultPostSlugs.indexOf(post.slug) > -1) {
return;
}

Expand Down
20 changes: 10 additions & 10 deletions core/test/functional/routes/api/posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
Expand All @@ -75,7 +75,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post', ['mobiledoc'], ['html']);
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
Expand All @@ -100,7 +100,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post', ['mobiledoc', 'plaintext', 'amp'], ['html']);
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
Expand All @@ -125,7 +125,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post', ['plaintext'], ['html']);
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
Expand All @@ -150,7 +150,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
Expand All @@ -175,7 +175,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);

testUtils.API.checkResponse(
jsonResponse.posts[0],
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(6);
jsonResponse.posts.should.have.length(12);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
done();
Expand All @@ -230,7 +230,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(9);
jsonResponse.posts.should.have.length(15);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
done();
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('Post API', function () {
});

it('can retrieve a post by slug', function (done) {
request.get(testUtils.API.getApiQuery('posts/slug/welcome-to-ghost/'))
request.get(testUtils.API.getApiQuery('posts/slug/welcome/'))
.set('Authorization', 'Bearer ' + accesstoken)
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
Expand All @@ -373,7 +373,7 @@ describe('Post API', function () {
should.exist(jsonResponse);
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
jsonResponse.posts[0].slug.should.equal('welcome-to-ghost');
jsonResponse.posts[0].slug.should.equal('welcome');
jsonResponse.posts[0].page.should.not.be.ok();
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
_.isBoolean(jsonResponse.posts[0].page).should.eql(true);
Expand Down
6 changes: 3 additions & 3 deletions core/test/functional/routes/api/public_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Public API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
Expand All @@ -92,7 +92,7 @@ describe('Public API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
Expand All @@ -116,7 +116,7 @@ describe('Public API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
jsonResponse.posts.should.have.length(11);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
Expand Down
26 changes: 17 additions & 9 deletions core/test/functional/routes/channel_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,26 @@ describe('Channel Routes', function () {
should.exist(res.headers.date);

$('title').text().should.equal('Ghost');
$('.content .post').length.should.equal(1);
$('.content .post').length.should.equal(5);
$('.poweredby').text().should.equal('Proudly published with Ghost');
$('body.home-template').length.should.equal(1);
$('article.post').length.should.equal(1);
$('article.tag-getting-started').length.should.equal(1);
$('article.post').length.should.equal(5);
$('article.tag-getting-started').length.should.equal(5);

done();
});
});

it('should not have as second page', function (done) {
it('should have a second page', function (done) {
request.get('/page/2/')
.expect('Content-Type', /html/)
.expect('Cache-Control', testUtils.cacheRules.public)
.expect(200)
.end(doEnd(done));
});

it('should not have a third page', function (done) {
request.get('/page/3/')
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(404)
.expect(/Page not found/)
Expand Down Expand Up @@ -138,13 +146,13 @@ describe('Channel Routes', function () {

describe('Paged', function () {
// Add enough posts to trigger pages for both the index (5 pp) and rss (15 pp)
// insertPosts adds 5 published posts, 1 draft post, 1 published static page and one draft page
// we then insert with max 11 which ensures we have 16 published posts
// insertPosts adds 11 published posts, 1 draft post, 1 published static page and one draft page
// we then insert with max 5 which ensures we have 16 published posts
before(function (done) {
testUtils.initData().then(function () {
return testUtils.fixtures.insertPostsAndTags();
}).then(function () {
return testUtils.fixtures.insertMorePosts(11);
return testUtils.fixtures.insertMorePosts(5);
}).then(function () {
done();
}).catch(done);
Expand Down Expand Up @@ -496,7 +504,7 @@ describe('Channel Routes', function () {
});

it('should 404 if page too high', function (done) {
request.get('/author/ghost-owner/page/4/')
request.get('/author/ghost-owner/page/6/')
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(404)
.expect(/Page not found/)
Expand All @@ -521,7 +529,7 @@ describe('Channel Routes', function () {
});

it('should 404 if page too high', function (done) {
request.get('/author/ghost-owner/rss/2/')
request.get('/author/ghost-owner/rss/3/')
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(404)
.expect(/Page not found/)
Expand Down
Loading

0 comments on commit f675a96

Please sign in to comment.