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

Merge pull request #6225 from ErisDS/ghost-head-fix

Ensure `{{ghost_head}}` doesn't overwrite values
This commit is contained in:
Sebastian Gierlinger 2015-12-15 15:13:17 +01:00
commit 68a3c2527d
2 changed files with 8 additions and 3 deletions

View file

@ -302,7 +302,7 @@ ghost_head = function (options) {
schema, schema,
title = hbs.handlebars.Utils.escapeExpression(blog.title), title = hbs.handlebars.Utils.escapeExpression(blog.title),
context = self.context ? self.context[0] : null, context = self.context ? self.context[0] : null,
contextObject = self[context] || blog; contextObject = _.cloneDeep(self[context] || blog);
// Store Async calls in an object of named promises // Store Async calls in an object of named promises
props.url = urlHelper.call(self, {hash: {absolute: true}}); props.url = urlHelper.call(self, {hash: {absolute: true}});

View file

@ -2,6 +2,7 @@
/*jshint expr:true*/ /*jshint expr:true*/
var should = require('should'), var should = require('should'),
sinon = require('sinon'), sinon = require('sinon'),
_ = require('lodash'),
Promise = require('bluebird'), Promise = require('bluebird'),
hbs = require('express-hbs'), hbs = require('express-hbs'),
utils = require('./utils'), utils = require('./utils'),
@ -243,7 +244,7 @@ describe('{{ghost_head}} helper', function () {
image: '/content/images/test-author-image.png', image: '/content/images/test-author-image.png',
cover: '/content/images/author-cover-image.png', cover: '/content/images/author-cover-image.png',
website: 'http://authorwebsite.com' website: 'http://authorwebsite.com'
}; }, authorBk = _.cloneDeep(author);
helpers.ghost_head.call( helpers.ghost_head.call(
{safeVersion: '0.3', relativeUrl: '/author/AuthorName/', author: author, context: ['author']}, {safeVersion: '0.3', relativeUrl: '/author/AuthorName/', author: author, context: ['author']},
@ -273,6 +274,8 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/"name": "Author name"/); rendered.string.should.match(/"name": "Author name"/);
rendered.string.should.match(/"description": "Author bio"/); rendered.string.should.match(/"description": "Author bio"/);
author.should.eql(authorBk);
done(); done();
}).catch(done); }).catch(done);
}); });
@ -331,7 +334,7 @@ describe('{{ghost_head}} helper', function () {
website: 'http://authorwebsite.com', website: 'http://authorwebsite.com',
bio: 'Author bio' bio: 'Author bio'
} }
}; }, postBk = _.cloneDeep(post);
helpers.ghost_head.call( helpers.ghost_head.call(
{relativeUrl: '/post/', safeVersion: '0.3', context: ['post'], post: post}, {relativeUrl: '/post/', safeVersion: '0.3', context: ['post'], post: post},
@ -382,6 +385,8 @@ describe('{{ghost_head}} helper', function () {
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/); rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/testurl.com\/rss\/" \/>/); rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/testurl.com\/rss\/" \/>/);
post.should.eql(postBk);
done(); done();
}).catch(done); }).catch(done);
}); });