From 9419f9bbe4c6ce671a0e506e7eb4cb35216cd1c8 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Tue, 5 Aug 2014 23:38:57 +0100 Subject: [PATCH] Adding missing body class for author pages closes #3606 --- core/server/helpers/index.js | 5 +++++ core/test/unit/server_helpers_index_spec.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index 8e7842dff8..60b17db318 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -411,6 +411,11 @@ coreHelpers.body_class = function (options) { classes.push('tag-' + this.tag.slug); } + if (this.author !== undefined) { + classes.push('author-template'); + classes.push('author-' + this.author.slug); + } + if (tags) { classes = classes.concat(tags.map(function (tag) { return 'tag-' + tag.slug; })); } diff --git a/core/test/unit/server_helpers_index_spec.js b/core/test/unit/server_helpers_index_spec.js index 7d614aebae..54693e0ed3 100644 --- a/core/test/unit/server_helpers_index_spec.js +++ b/core/test/unit/server_helpers_index_spec.js @@ -399,21 +399,27 @@ describe('Core Helpers', function () { helpers.body_class.call({relativeUrl: '/a-post-title', post: {}}), helpers.body_class.call({relativeUrl: '/page/4'}), helpers.body_class.call({relativeUrl: '/tag/foo', tag: { slug: 'foo'}}), - helpers.body_class.call({relativeUrl: '/tag/foo/page/2', tag: { slug: 'foo'}}) + helpers.body_class.call({relativeUrl: '/tag/foo/page/2', tag: { slug: 'foo'}}), + helpers.body_class.call({relativeUrl: '/author/bar', author: { slug: 'bar'}}), + helpers.body_class.call({relativeUrl: '/author/bar/page/2', author: { slug: 'bar'}}) ]).then(function (rendered) { - rendered.length.should.equal(5); + rendered.length.should.equal(7); should.exist(rendered[0]); should.exist(rendered[1]); should.exist(rendered[2]); should.exist(rendered[3]); should.exist(rendered[4]); + should.exist(rendered[5]); + should.exist(rendered[6]); rendered[0].string.should.equal('home-template'); rendered[1].string.should.equal('post-template'); rendered[2].string.should.equal('archive-template'); rendered[3].string.should.equal('tag-template tag-foo'); rendered[4].string.should.equal('archive-template tag-template tag-foo'); + rendered[5].string.should.equal('author-template author-bar'); + rendered[6].string.should.equal('archive-template author-template author-bar'); done(); }).catch(done);