0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Merge pull request #7016 from kirrg001/fix/6999

fix: url for post path when post is not published
This commit is contained in:
Austin Burdine 2016-06-21 07:09:11 -04:00 committed by GitHub
commit bfaa8ece90
2 changed files with 16 additions and 1 deletions

View file

@ -104,7 +104,7 @@ function createUrl(urlPath, absolute, secure) {
function urlPathForPost(post) {
var output = '',
permalinks = ghostConfig.theme.permalinks,
publishedAtMoment = moment.tz(post.published_at, ghostConfig.theme.timezone),
publishedAtMoment = moment.tz(post.published_at || Date.now(), ghostConfig.theme.timezone),
tags = {
year: function () { return publishedAtMoment.format('YYYY'); },
month: function () { return publishedAtMoment.format('MM'); },

View file

@ -1,6 +1,7 @@
var should = require('should'),
sinon = require('sinon'),
Promise = require('bluebird'),
moment = require('moment'),
path = require('path'),
fs = require('fs'),
_ = require('lodash'),
@ -454,6 +455,20 @@ describe('Config', function () {
testData.published_at = new Date('2016-01-01T00:00:00.000Z');
config.urlPathForPost(testData).should.equal(postLink);
});
it('post is not published yet', function () {
config.theme.permalinks = '/:year/:month/:day/:slug/';
var testData = _.merge(testUtils.DataGenerator.Content.posts[2], {id: 3, published_at: null}),
nowMoment = moment(),
postLink = '/YYYY/MM/DD/short-and-sweet/';
postLink = postLink.replace('YYYY', nowMoment.format('YYYY'));
postLink = postLink.replace('MM', nowMoment.format('MM'));
postLink = postLink.replace('DD', nowMoment.format('DD'));
config.urlPathForPost(testData).should.equal(postLink);
});
});
describe('apiUrl', function () {