diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index f4b8967e0f..9ee926041e 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -122,7 +122,7 @@ coreHelpers = function (ghost) { var separator = ', ', tagNames; - if (typeof options.hash.separator === 'string') { + if (_.isString(options.hash.separator)) { separator = options.hash.separator; } diff --git a/core/test/unit/server_helpers_index_spec.js b/core/test/unit/server_helpers_index_spec.js index ac8571a21c..3a7ed8ef8f 100644 --- a/core/test/unit/server_helpers_index_spec.js +++ b/core/test/unit/server_helpers_index_spec.js @@ -383,4 +383,81 @@ describe('Core Helpers', function () { }).then(null, done); }); }); + + describe("tags helper", function () { + + it('has loaded tags helper', function () { + should.exist(handlebars.helpers.tags); + }); + + it('can return string with tags', function () { + var tags = [{name:'foo'}, {name:'bar'}], + rendered = handlebars.helpers.tags.call( + {tags: tags}, + {"hash": {}} + ); + should.exist(rendered); + + String(rendered).should.equal('foo, bar'); + }); + + it('can use a different separator', function () { + var tags = [{name:'haunted'},{name:'ghost'}], + rendered = handlebars.helpers.tags.call( + {tags: tags}, + {"hash": {separator: '|'}} + ); + + should.exist(rendered); + + String(rendered).should.equal('haunted|ghost'); + }); + }); + + describe("meta_title helper", function () { + + it('has loaded meta_title helper', function () { + should.exist(handlebars.helpers.meta_title); + }); + + it('can return blog title', function () { + var rendered = handlebars.helpers.meta_title.call({path: '/'}); + + should.exist(rendered); + String(rendered).should.equal('Ghost'); + }); + + it('can return title of a post', function () { + var rendered = handlebars.helpers.meta_title.call( + {path: '/nice-post', post: {title: 'Post Title'}} + ); + + should.exist(rendered); + String(rendered).should.equal('Post Title'); + }); + }); + + describe("meta_description helper", function () { + + it('has loaded meta_description helper', function () { + should.exist(handlebars.helpers.meta_description); + }); + + it('can return blog description', function () { + var rendered = handlebars.helpers.meta_description.call({path: '/'}); + + should.exist(rendered); + String(rendered).should.equal('Just a blogging platform.'); + }); + + it('can return empty description on post', function () { + var rendered = handlebars.helpers.meta_description.call( + {path: '/nice-post', post: {title: 'Post Title'}} + ); + + should.exist(rendered); + String(rendered).should.equal(''); + }); + + }); });