mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Fixed update check tests
refs #12537 - Refactored overuse of rewire mocking blog-version. - Fixed a bug introduced along the way when duplicate notifications errored instead of returning empty result
This commit is contained in:
parent
cc9d987e94
commit
1cec604318
4 changed files with 34 additions and 30 deletions
|
@ -30,15 +30,17 @@ module.exports = {
|
||||||
notifications: frame.data.notifications
|
notifications: frame.data.notifications
|
||||||
});
|
});
|
||||||
|
|
||||||
return api.settings.edit({
|
if (notificationsToAdd.length){
|
||||||
settings: [{
|
return api.settings.edit({
|
||||||
key: 'notifications',
|
settings: [{
|
||||||
// @NOTE: We always need to store all notifications!
|
key: 'notifications',
|
||||||
value: allNotifications.concat(notificationsToAdd)
|
// @NOTE: We always need to store all notifications!
|
||||||
}]
|
value: allNotifications.concat(notificationsToAdd)
|
||||||
}, internalContext).then(() => {
|
}]
|
||||||
return notificationsToAdd;
|
}, internalContext).then(() => {
|
||||||
});
|
return notificationsToAdd;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,17 @@ module.exports = {
|
||||||
notifications: frame.data.notifications
|
notifications: frame.data.notifications
|
||||||
});
|
});
|
||||||
|
|
||||||
return api.settings.edit({
|
if (notificationsToAdd.length){
|
||||||
settings: [{
|
return api.settings.edit({
|
||||||
key: 'notifications',
|
settings: [{
|
||||||
// @NOTE: We always need to store all notifications!
|
key: 'notifications',
|
||||||
value: allNotifications.concat(notificationsToAdd)
|
// @NOTE: We always need to store all notifications!
|
||||||
}]
|
value: allNotifications.concat(notificationsToAdd)
|
||||||
}, internalContext).then(() => {
|
}]
|
||||||
return notificationsToAdd;
|
}, internalContext).then(() => {
|
||||||
});
|
return notificationsToAdd;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ class Notifications {
|
||||||
|
|
||||||
// CASE: nothing to add, skip
|
// CASE: nothing to add, skip
|
||||||
if (!notificationsToAdd.length) {
|
if (!notificationsToAdd.length) {
|
||||||
return Promise.resolve();
|
return {allNotifications, notificationsToAdd};
|
||||||
}
|
}
|
||||||
|
|
||||||
const releaseNotificationsToAdd = notificationsToAdd.filter((notification) => {
|
const releaseNotificationsToAdd = notificationsToAdd.filter((notification) => {
|
||||||
|
|
|
@ -11,12 +11,12 @@ const packageInfo = require('../../../package.json');
|
||||||
const api = require('../../../core/server/api').v2;
|
const api = require('../../../core/server/api').v2;
|
||||||
|
|
||||||
let updateCheck = rewire('../../../core/server/update-check');
|
let updateCheck = rewire('../../../core/server/update-check');
|
||||||
let NotificationsAPI = rewire('../../../core/server/api/v2/notifications');
|
let ghostVersion = rewire('../../../core/server/lib/ghost-version');
|
||||||
|
|
||||||
describe('Update Check', function () {
|
describe('Update Check', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
updateCheck = rewire('../../../core/server/update-check');
|
updateCheck = rewire('../../../core/server/update-check');
|
||||||
NotificationsAPI = rewire('../../../core/server/api/v2/notifications');
|
ghostVersion = rewire('../../../core/server/lib/ghost-version');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -145,14 +145,19 @@ describe('Update Check', function () {
|
||||||
|
|
||||||
describe('fn: createCustomNotification', function () {
|
describe('fn: createCustomNotification', function () {
|
||||||
let currentVersionOrig;
|
let currentVersionOrig;
|
||||||
|
let currentVersionFull;
|
||||||
|
|
||||||
before(function () {
|
before(function () {
|
||||||
currentVersionOrig = updateCheck.__get__('ghostVersion.original');
|
currentVersionOrig = updateCheck.__get__('ghostVersion.original');
|
||||||
updateCheck.__set__('ghostVersion.original', '0.9.0');
|
currentVersionFull = updateCheck.__get__('ghostVersion.original');
|
||||||
|
|
||||||
|
ghostVersion.__set__('original', '0.9.0');
|
||||||
|
ghostVersion.__set__('full', '0.9.0');
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
updateCheck.__set__('ghostVersion.original', currentVersionOrig);
|
ghostVersion.__set__('original', currentVersionOrig);
|
||||||
|
ghostVersion.__set__('full', currentVersionFull);
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(testUtils.teardownDb);
|
beforeEach(testUtils.teardownDb);
|
||||||
|
@ -170,15 +175,13 @@ describe('Update Check', function () {
|
||||||
custom: 0,
|
custom: 0,
|
||||||
messages: [{
|
messages: [{
|
||||||
id: uuid.v4(),
|
id: uuid.v4(),
|
||||||
version: '0.9.x',
|
version: '999.9.x',
|
||||||
content: '<p>Hey there! This is for 0.9.0 version</p>',
|
content: '<p>Hey there! This is for 999.9.0 version</p>',
|
||||||
dismissible: true,
|
dismissible: true,
|
||||||
top: true
|
top: true
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
NotificationsAPI.__set__('ghostVersion.full', '0.8.1');
|
|
||||||
|
|
||||||
createCustomNotification(notification).then(function () {
|
createCustomNotification(notification).then(function () {
|
||||||
return api.notifications.browse(testUtils.context.internal);
|
return api.notifications.browse(testUtils.context.internal);
|
||||||
}).then(function (results) {
|
}).then(function (results) {
|
||||||
|
@ -213,7 +216,6 @@ describe('Update Check', function () {
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
NotificationsAPI.__set__('ghostVersion.full', '0.8.1');
|
|
||||||
|
|
||||||
createCustomNotification(notification).then(function () {
|
createCustomNotification(notification).then(function () {
|
||||||
return api.notifications.browse(testUtils.context.internal);
|
return api.notifications.browse(testUtils.context.internal);
|
||||||
|
@ -240,8 +242,6 @@ describe('Update Check', function () {
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
NotificationsAPI.__set__('ghostVersion.full', '0.8');
|
|
||||||
|
|
||||||
createCustomNotification(notification).then(function () {
|
createCustomNotification(notification).then(function () {
|
||||||
return api.notifications.browse(testUtils.context.internal);
|
return api.notifications.browse(testUtils.context.internal);
|
||||||
}).then(function (results) {
|
}).then(function (results) {
|
||||||
|
|
Loading…
Reference in a new issue