mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🐛 Fixed persistent upgrade notifications showing for the currently installed version (#9048)
closes #9040 - introduced by https://github.com/TryGhost/Ghost/pull/9009 - a condition was missing, was removed by mistake
This commit is contained in:
parent
217bc6914d
commit
1dd365778f
2 changed files with 111 additions and 10 deletions
|
@ -249,7 +249,7 @@ function showUpdateNotification() {
|
|||
var display = response.settings[0];
|
||||
|
||||
// @TODO: We only show minor/major releases. This is a temporary fix. #5071 is coming soon.
|
||||
if (display && display.value && currentVersion && semver.patch(display.value) === 0) {
|
||||
if (display && display.value && currentVersion && semver.gt(display.value, currentVersion) && semver.patch(display.value) === 0) {
|
||||
return display.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
var should = require('should'),
|
||||
_ = require('lodash'),
|
||||
rewire = require('rewire'),
|
||||
uuid = require('uuid'),
|
||||
testUtils = require('../utils'),
|
||||
configUtils = require('../utils/configUtils'),
|
||||
packageInfo = require('../../../package'),
|
||||
updateCheck = rewire('../../server/update-check'),
|
||||
var should = require('should'),
|
||||
_ = require('lodash'),
|
||||
rewire = require('rewire'),
|
||||
uuid = require('uuid'),
|
||||
testUtils = require('../utils'),
|
||||
configUtils = require('../utils/configUtils'),
|
||||
packageInfo = require('../../../package'),
|
||||
updateCheck = rewire('../../server/update-check'),
|
||||
settingsCache = require('../../server/settings/cache'),
|
||||
NotificationsAPI = require('../../server/api/notifications');
|
||||
|
||||
describe('Update Check', function () {
|
||||
|
@ -22,7 +23,7 @@ describe('Update Check', function () {
|
|||
configUtils.restore();
|
||||
});
|
||||
|
||||
beforeEach(testUtils.setup('owner', 'posts', 'perms:setting', 'perms:user', 'perms:init'));
|
||||
beforeEach(testUtils.setup('owner', 'settings', 'posts', 'perms:setting', 'perms:user', 'perms:init'));
|
||||
|
||||
afterEach(testUtils.teardown);
|
||||
|
||||
|
@ -102,5 +103,105 @@ describe('Update Check', function () {
|
|||
}).catch(done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Show notification', function () {
|
||||
var currentVersionOrig;
|
||||
|
||||
before(function () {
|
||||
currentVersionOrig = updateCheck.__get__('currentVersion');
|
||||
});
|
||||
|
||||
after(function () {
|
||||
updateCheck.__set__('currentVersion', currentVersionOrig);
|
||||
});
|
||||
|
||||
beforeEach(testUtils.setup('settings', 'perms:setting', 'perms:notification', 'perms:init'));
|
||||
|
||||
afterEach(testUtils.teardown);
|
||||
|
||||
it('should show update notification', function (done) {
|
||||
var showUpdateNotification = updateCheck.__get__('showUpdateNotification');
|
||||
|
||||
updateCheck.__set__('currentVersion', '1.7.1');
|
||||
settingsCache.set('display_update_notification', {value: '1.9.0'});
|
||||
|
||||
showUpdateNotification()
|
||||
.then(function (result) {
|
||||
result.should.eql('1.9.0');
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should show update notification', function (done) {
|
||||
var showUpdateNotification = updateCheck.__get__('showUpdateNotification');
|
||||
|
||||
updateCheck.__set__('currentVersion', '1.7.1');
|
||||
settingsCache.set('display_update_notification', {value: '2.0.0'});
|
||||
|
||||
showUpdateNotification()
|
||||
.then(function (result) {
|
||||
result.should.eql('2.0.0');
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should not show update notification: latest minor release is not greater than your Ghost version', function (done) {
|
||||
var showUpdateNotification = updateCheck.__get__('showUpdateNotification');
|
||||
|
||||
updateCheck.__set__('currentVersion', '1.9.0');
|
||||
settingsCache.set('display_update_notification', {value: '1.9.0'});
|
||||
|
||||
showUpdateNotification()
|
||||
.then(function (result) {
|
||||
result.should.eql(false);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should not show update notification: latest minor release is not greater than your Ghost version', function (done) {
|
||||
var showUpdateNotification = updateCheck.__get__('showUpdateNotification');
|
||||
|
||||
updateCheck.__set__('currentVersion', '1.9.1');
|
||||
settingsCache.set('display_update_notification', {value: '1.9.1'});
|
||||
|
||||
showUpdateNotification()
|
||||
.then(function (result) {
|
||||
result.should.eql(false);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should not show update notification: latest release is a patch', function (done) {
|
||||
var showUpdateNotification = updateCheck.__get__('showUpdateNotification');
|
||||
|
||||
updateCheck.__set__('currentVersion', '1.9.0');
|
||||
settingsCache.set('display_update_notification', {value: '1.9.1'});
|
||||
|
||||
showUpdateNotification()
|
||||
.then(function (result) {
|
||||
result.should.eql(false);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should not show update notification: latest release is a patch', function (done) {
|
||||
var showUpdateNotification = updateCheck.__get__('showUpdateNotification');
|
||||
|
||||
updateCheck.__set__('currentVersion', '1.9.1');
|
||||
settingsCache.set('display_update_notification', {value: '1.9.0'});
|
||||
|
||||
showUpdateNotification()
|
||||
.then(function (result) {
|
||||
result.should.eql(false);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue