diff --git a/core/frontend/helpers/post_class.js b/core/frontend/helpers/post_class.js index f88e5d6154..83cbbaaa9b 100644 --- a/core/frontend/helpers/post_class.js +++ b/core/frontend/helpers/post_class.js @@ -11,8 +11,11 @@ module.exports = function post_class() { // eslint-disable-line camelcase var classes = ['post'], tags = this.post && this.post.tags ? this.post.tags : this.tags || [], featured = this.post && this.post.featured ? this.post.featured : this.featured || false, + image = this.post && this.post.feature_image ? this.post.feature_image : this.feature_image || false, page = this.post && this.post.page ? this.post.page : this.page || false; + console.log(this); + if (tags) { classes = classes.concat(tags.map(function (tag) { return 'tag-' + tag.slug; @@ -23,6 +26,10 @@ module.exports = function post_class() { // eslint-disable-line camelcase classes.push('featured'); } + if (!image) { + classes.push('no-image'); + } + if (page) { classes.push('page'); } diff --git a/core/test/unit/helpers/post_class_spec.js b/core/test/unit/helpers/post_class_spec.js index a084378922..d157ae6e00 100644 --- a/core/test/unit/helpers/post_class_spec.js +++ b/core/test/unit/helpers/post_class_spec.js @@ -7,6 +7,13 @@ describe('{{post_class}} helper', function () { it('can render class string', function () { var rendered = helpers.post_class.call({}); + should.exist(rendered); + rendered.string.should.equal('post no-image'); + }); + + it('can render class string without no-image class', function () { + var rendered = helpers.post_class.call({feature_image: 'blah'}); + should.exist(rendered); rendered.string.should.equal('post'); }); @@ -16,13 +23,29 @@ describe('{{post_class}} helper', function () { rendered = helpers.post_class.call(post); should.exist(rendered); - rendered.string.should.equal('post featured'); + rendered.string.should.equal('post featured no-image'); + }); + + it('can render featured class without no-image class', function () { + var post = {featured: true, feature_image: 'asdass'}, + rendered = helpers.post_class.call(post); + + should.exist(rendered); + rendered.string.should.equal('post featured no-image'); }); it('can render page class', function () { var post = {page: true}, rendered = helpers.post_class.call(post); + should.exist(rendered); + rendered.string.should.equal('post no-image page'); + }); + + it('can render page class without no-image class', function () { + var post = {page: true, featured_image: 'asdasdas'}, + rendered = helpers.post_class.call(post); + should.exist(rendered); rendered.string.should.equal('post page'); });