Merge remote-tracking branch 'origin/master' into develop

v1.18.x
Julian Lam 8 years ago
commit 0e157d93ea

@ -73,9 +73,9 @@ apiController.getConfig = function (req, res, next) {
config.cookies = {
enabled: parseInt(meta.config.cookieConsentEnabled, 10) === 1,
message: translator.escape(validator.escape(meta.config.cookieConsentMessage) || '[[global:cookies.message]]').replace(/\\/g, '\\\\'),
dismiss: translator.escape(validator.escape(meta.config.cookieConsentDismiss) || '[[global:cookies.accept]]').replace(/\\/g, '\\\\'),
link: translator.escape(validator.escape(meta.config.cookieConsentLink) || '[[global:cookies.learn_more]]').replace(/\\/g, '\\\\'),
message: translator.escape(validator.escape(meta.config.cookieConsentMessage || '[[global:cookies.message]]')).replace(/\\/g, '\\\\'),
dismiss: translator.escape(validator.escape(meta.config.cookieConsentDismiss || '[[global:cookies.accept]]')).replace(/\\/g, '\\\\'),
link: translator.escape(validator.escape(meta.config.cookieConsentLink || '[[global:cookies.learn_more]]')).replace(/\\/g, '\\\\'),
};
async.waterfall([

@ -1017,6 +1017,50 @@ describe('Controllers', function () {
});
});
describe('cookie consent', function () {
it('should return relevant data in configs API route', function (done) {
request(nconf.get('url') + '/api/config', function (err, res, body) {
var parsed;
assert.ifError(err);
assert.equal(res.statusCode, 200);
try {
parsed = JSON.parse(body);
} catch (e) {
assert.ifError(e);
}
assert.ok(parsed.cookies);
assert.equal('\\\\[\\\\[global:cookies.message\\\\]\\\\]', parsed.cookies.message);
assert.equal('\\\\[\\\\[global:cookies.accept\\\\]\\\\]', parsed.cookies.dismiss);
assert.equal('\\\\[\\\\[global:cookies.learn_more\\\\]\\\\]', parsed.cookies.link);
done();
});
});
it('response should be parseable when entries have apostrophes', function (done) {
meta.configs.set('cookieConsentMessage', 'Julian\'s Message', function (err) {
assert.ifError(err);
request(nconf.get('url') + '/api/config', function (err, res, body) {
var parsed;
assert.ifError(err);
assert.equal(res.statusCode, 200);
try {
parsed = JSON.parse(body);
} catch (e) {
assert.ifError(e);
}
assert.equal('Julian's Message', parsed.cookies.message);
done();
});
});
});
});
after(function (done) {
var analytics = require('../src/analytics');
analytics.writeData(function (err) {

Loading…
Cancel
Save