v1.18.x
Barış Soner Uşaklı 8 years ago
parent b3a265f981
commit 77894915eb

@ -49,7 +49,7 @@ topicsController.get = function (req, res, callback) {
userPrivileges = results.privileges; userPrivileges = results.privileges;
if (!userPrivileges.read || !userPrivileges['topics:read'] || (parseInt(results.topic.deleted, 10) && !userPrivileges.view_deleted)) { if (!userPrivileges['topics:read'] || (parseInt(results.topic.deleted, 10) && !userPrivileges.view_deleted)) {
return helpers.notAllowed(req, res); return helpers.notAllowed(req, res);
} }

@ -27,7 +27,7 @@ module.exports = function (SocketTopics) {
}, next); }, next);
}, },
function (results, next) { function (results, next) {
if (!results.privileges.read || (parseInt(results.topic.deleted, 10) && !results.privileges.view_deleted)) { if (!results.privileges['topics:read'] || (parseInt(results.topic.deleted, 10) && !results.privileges.view_deleted)) {
return callback(new Error('[[error:no-privileges]]')); return callback(new Error('[[error:no-privileges]]'));
} }

@ -760,13 +760,13 @@ describe('Topic\'s', function () {
it('should 401 if not allowed to read as guest', function (done) { it('should 401 if not allowed to read as guest', function (done) {
var privileges = require('../src/privileges'); var privileges = require('../src/privileges');
privileges.categories.rescind(['read'], topicData.cid, 'guests', function (err) { privileges.categories.rescind(['topics:read'], topicData.cid, 'guests', function (err) {
assert.ifError(err); assert.ifError(err);
request(nconf.get('url') + '/api/topic/' + topicData.slug, function (err, response, body) { request(nconf.get('url') + '/api/topic/' + topicData.slug, function (err, response, body) {
assert.ifError(err); assert.ifError(err);
assert.equal(response.statusCode, 401); assert.equal(response.statusCode, 401);
assert(body); assert(body);
privileges.categories.give(['read'], topicData.cid, 'guests', done); privileges.categories.give(['topics:read'], topicData.cid, 'guests', done);
}); });
}); });
}); });
@ -1551,7 +1551,7 @@ describe('Topic\'s', function () {
it('should return empty array if first param is empty', function (done) { it('should return empty array if first param is empty', function (done) {
topics.getTeasers([], function (err, teasers) { topics.getTeasers([], 1, function (err, teasers) {
assert.ifError(err); assert.ifError(err);
assert.equal(0, teasers.length); assert.equal(0, teasers.length);
done(); done();
@ -1559,7 +1559,7 @@ describe('Topic\'s', function () {
}); });
it('should get teasers with 2 params', function (done) { it('should get teasers with 2 params', function (done) {
topics.getTeasers([topic1.topicData, topic2.topicData], function (err, teasers) { topics.getTeasers([topic1.topicData, topic2.topicData], 1, function (err, teasers) {
assert.ifError(err); assert.ifError(err);
assert.deepEqual([undefined, undefined], teasers); assert.deepEqual([undefined, undefined], teasers);
done(); done();
@ -1568,7 +1568,7 @@ describe('Topic\'s', function () {
it('should get teasers with first posts', function (done) { it('should get teasers with first posts', function (done) {
meta.config.teaserPost = 'first'; meta.config.teaserPost = 'first';
topics.getTeasers([topic1.topicData, topic2.topicData], function (err, teasers) { topics.getTeasers([topic1.topicData, topic2.topicData], 1, function (err, teasers) {
assert.ifError(err); assert.ifError(err);
assert.equal(2, teasers.length); assert.equal(2, teasers.length);
assert(teasers[0]); assert(teasers[0]);
@ -1581,7 +1581,7 @@ describe('Topic\'s', function () {
}); });
it('should get teasers even if one topic is falsy', function (done) { it('should get teasers even if one topic is falsy', function (done) {
topics.getTeasers([null, topic2.topicData], function (err, teasers) { topics.getTeasers([null, topic2.topicData], 1, function (err, teasers) {
assert.ifError(err); assert.ifError(err);
assert.equal(2, teasers.length); assert.equal(2, teasers.length);
assert.equal(undefined, teasers[0]); assert.equal(undefined, teasers[0]);
@ -1598,7 +1598,7 @@ describe('Topic\'s', function () {
topics.reply({ uid: adminUid, content: 'reply 1 content', tid: topic1.topicData.tid }, function (err, result) { topics.reply({ uid: adminUid, content: 'reply 1 content', tid: topic1.topicData.tid }, function (err, result) {
assert.ifError(err); assert.ifError(err);
topic1.topicData.teaserPid = result.pid; topic1.topicData.teaserPid = result.pid;
topics.getTeasers([topic1.topicData, topic2.topicData], function (err, teasers) { topics.getTeasers([topic1.topicData, topic2.topicData], 1, function (err, teasers) {
assert.ifError(err); assert.ifError(err);
assert(teasers[0]); assert(teasers[0]);
assert(teasers[1]); assert(teasers[1]);
@ -1610,7 +1610,7 @@ describe('Topic\'s', function () {
}); });
it('should get teasers by tids', function (done) { it('should get teasers by tids', function (done) {
topics.getTeasersByTids([topic2.topicData.tid, topic1.topicData.tid], function (err, teasers) { topics.getTeasersByTids([topic2.topicData.tid, topic1.topicData.tid], 1, function (err, teasers) {
assert.ifError(err); assert.ifError(err);
assert(2, teasers.length); assert(2, teasers.length);
assert.equal(teasers[1].content, 'reply 1 content'); assert.equal(teasers[1].content, 'reply 1 content');
@ -1619,7 +1619,7 @@ describe('Topic\'s', function () {
}); });
it('should return empty array ', function (done) { it('should return empty array ', function (done) {
topics.getTeasersByTids([], function (err, teasers) { topics.getTeasersByTids([], 1, function (err, teasers) {
assert.ifError(err); assert.ifError(err);
assert.equal(0, teasers.length); assert.equal(0, teasers.length);
done(); done();
@ -1627,7 +1627,7 @@ describe('Topic\'s', function () {
}); });
it('should get teaser by tid', function (done) { it('should get teaser by tid', function (done) {
topics.getTeaser(topic2.topicData.tid, function (err, teaser) { topics.getTeaser(topic2.topicData.tid, 1, function (err, teaser) {
assert.ifError(err); assert.ifError(err);
assert(teaser); assert(teaser);
assert.equal(teaser.content, 'content 2'); assert.equal(teaser.content, 'content 2');

Loading…
Cancel
Save