From f114f457402b25561de340eb1b871bb8a574ace4 Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Fri, 6 Apr 2018 13:36:03 +0200 Subject: [PATCH] Added a post unit test to proof a bug no issue - permalink: /:primary_tag/:slug/, columns: [title,url] - will be auto resolved with channels - the test should fail if we add channels --- core/test/unit/models/post_spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/test/unit/models/post_spec.js b/core/test/unit/models/post_spec.js index 6436a5d765..b9ee69872e 100644 --- a/core/test/unit/models/post_spec.js +++ b/core/test/unit/models/post_spec.js @@ -5,6 +5,7 @@ const should = require('should'), // jshint ignore:line _ = require('lodash'), testUtils = require('../../utils'), knex = require('../../../server/data/db').knex, + settingsCache = require('../../../server/services/settings/cache'), models = require('../../../server/models'), common = require('../../../server/lib/common'), security = require('../../../server/lib/security'), @@ -39,6 +40,22 @@ describe('Unit: models/post', function () { sandbox.restore(); }); + describe('findPage', function () { + /** + * This is a @bug. + * If you don't include tags, we can't generate the url properly. + * Will be fixed when merging channels, because the post model has no longer generate the url. + */ + it('[bug] permalink: /:primary_tag/:slug/, columns: [title,url]', function () { + sandbox.stub(settingsCache, 'get').withArgs('permalinks').returns('/:primary_tag/:slug/'); + + return models.Post.findPage({columns: ['title', 'url']}) + .then(function (result) { + result.posts[0].url.should.eql('/all/html-ipsum/'); + }); + }); + }); + describe('Edit', function () { it('update post, relation has not changed', function () { const events = {