0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Merge pull request #2054 from ErisDS/issue-1995

Add body class if update is available
This commit is contained in:
Hannah Wolfe 2014-01-28 00:53:45 -08:00
commit b4b7783ebd
3 changed files with 22 additions and 9 deletions

View file

@ -562,7 +562,7 @@ coreHelpers.adminUrl = function (options) {
return config.paths.urlFor(context, absolute);
};
coreHelpers.updateNotification = function () {
coreHelpers.updateNotification = function (options) {
var output = '';
if (config().updateCheck === false || !this.currentUser) {
@ -571,9 +571,13 @@ coreHelpers.updateNotification = function () {
return updateCheck.showUpdateNotification().then(function (result) {
if (result) {
output = '<div class="notification-success">' +
'A new version of Ghost is available! Hot damn. ' +
'<a href="http://ghost.org/download">Upgrade now</a></div>';
if (options && options.hash && options.hash.classOnly) {
output = ' update-available';
} else {
output = '<div class="notification-success">' +
'A new version of Ghost is available! Hot damn. ' +
'<a href="http://ghost.org/download">Upgrade now</a></div>';
}
}
return output;

View file

@ -31,7 +31,7 @@
<link rel="stylesheet" href="{{asset "css/screen.css" ghost="true"}}">
{{{block "pageStyles"}}}
</head>
<body class="{{bodyClass}}">
<body class="{{bodyClass}}{{updateNotification classOnly="true"}}">
{{#unless hideNavbar}}
{{> navbar}}
{{/unless}}

View file

@ -940,21 +940,30 @@ describe('Core Helpers', function () {
});
describe('updateNotification', function () {
it('outputs a correctly formatted notification when db version is higher than package version', function (done) {
var output = '<div class="notification-success">' +
var defaultOutput = '<div class="notification-success">' +
'A new version of Ghost is available! Hot damn. ' +
'<a href="http://ghost.org/download">Upgrade now</a></div>';
'<a href="http://ghost.org/download">Upgrade now</a></div>',
classOutput = ' update-available';
apiStub.restore();
apiStub = sandbox.stub(api.settings, 'read', function () {
var futureversion = packageInfo.version.split('.');
futureversion[futureversion.length-1] = parseInt(futureversion[futureversion.length-1], 10) + 1;
futureversion[futureversion.length - 1] = parseInt(futureversion[futureversion.length - 1], 10) + 1;
return when({value: futureversion.join('.')});
});
helpers.updateNotification.call({currentUser: {name: 'bob'}}).then(function (rendered) {
should.exist(rendered);
rendered.should.equal(output);
rendered.should.equal(defaultOutput);
// Test classOnly option
return helpers.updateNotification.call({currentUser: {name: 'bob'}}, {'hash': {'classOnly': 'true'}});
}).then(function (rendered) {
should.exist(rendered);
rendered.should.equal(classOutput);
done();
}).then(null, done);
});