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

Merge pull request #5203 from jaswilli/jscs-whitespace

Upgrade grunt-jscs to fix whitespace linting.
This commit is contained in:
Matt Enlow 2015-05-01 00:04:14 +01:00
commit f4a9f0c82d
23 changed files with 581 additions and 582 deletions

View file

@ -17,7 +17,7 @@ app = new EmberApp({
outputPaths: { outputPaths: {
app: { app: {
js: assetLocation('ghost.js') js: assetLocation('ghost.js')
// css: see config/environment.js (sassOptions) // css: see config/environment.js (sassOptions)
}, },
vendor: { vendor: {
js: assetLocation('vendor.js'), js: assetLocation('vendor.js'),

View file

@ -133,9 +133,9 @@ UploadUi = function ($dropzone, settings) {
if (!$dropzone.find('a.image-url')[0]) { if (!$dropzone.find('a.image-url')[0]) {
$dropzone.append('<a class="image-url" title="Add image from URL"><span class="hidden">URL</span></a>'); $dropzone.append('<a class="image-url" title="Add image from URL"><span class="hidden">URL</span></a>');
} }
// if (!$dropzone.find('a.image-webcam')[0]) { // if (!$dropzone.find('a.image-webcam')[0]) {
// $dropzone.append('<a class="image-webcam" title="Add image from webcam"><span class="hidden">Webcam</span></a>'); // $dropzone.append('<a class="image-webcam" title="Add image from webcam"><span class="hidden">Webcam</span></a>');
// } // }
}, },
removeExtras: function () { removeExtras: function () {

View file

@ -51,7 +51,7 @@ var EditorEditRoute = AuthenticatedRoute.extend(base, {
}, },
actions: { actions: {
authorizationFailed: function () { authorizationFailed: function () {
this.send('openModal', 'signin'); this.send('openModal', 'signin');
} }
} }

View file

@ -4,8 +4,8 @@ import config from '../../config/environment';
var resolver = Resolver.create(); var resolver = Resolver.create();
resolver.namespace = { resolver.namespace = {
modulePrefix: config.modulePrefix, modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix podModulePrefix: config.podModulePrefix
}; };
export default resolver; export default resolver;

View file

@ -74,7 +74,7 @@ populate = function (options) {
logInfo('Populating permissions'); logInfo('Populating permissions');
// ### Ensure all permissions are added // ### Ensure all permissions are added
return addAllPermissions(options).then(function () { return addAllPermissions(options).then(function () {
// ### Ensure all roles_permissions are added // ### Ensure all roles_permissions are added
return addAllRolesPermissions(); return addAllRolesPermissions();
}); });
}; };

View file

@ -159,7 +159,7 @@ utils = {
tableData = stripProperties(['id'], tableData); tableData = stripProperties(['id'], tableData);
_.each(tableData, function (tag) { _.each(tableData, function (tag) {
// Validate minimum tag fields // Validate minimum tag fields
if (areEmpty(tag, 'name', 'slug')) { if (areEmpty(tag, 'name', 'slug')) {
return; return;
} }
@ -188,12 +188,12 @@ utils = {
tableData = stripProperties(['id'], tableData); tableData = stripProperties(['id'], tableData);
_.each(tableData, function (post) { _.each(tableData, function (post) {
// Validate minimum post fields // Validate minimum post fields
if (areEmpty(post, 'title', 'slug', 'markdown')) { if (areEmpty(post, 'title', 'slug', 'markdown')) {
return; return;
} }
// The post importer has auto-timestamping disabled // The post importer has auto-timestamping disabled
if (!post.created_at) { if (!post.created_at) {
post.created_at = Date.now(); post.created_at = Date.now();
} }
@ -213,7 +213,7 @@ utils = {
tableData = stripProperties(['id'], tableData); tableData = stripProperties(['id'], tableData);
_.each(tableData, function (user) { _.each(tableData, function (user) {
// Validate minimum user fields // Validate minimum user fields
if (areEmpty(user, 'name', 'slug', 'email')) { if (areEmpty(user, 'name', 'slug', 'email')) {
return; return;
} }

View file

@ -6,7 +6,7 @@ App = ghostBookshelf.Model.extend({
tableName: 'apps', tableName: 'apps',
saving: function (newPage, attr, options) { saving: function (newPage, attr, options) {
/*jshint unused:false*/ /*jshint unused:false*/
var self = this; var self = this;
ghostBookshelf.Model.prototype.saving.apply(this, arguments); ghostBookshelf.Model.prototype.saving.apply(this, arguments);

View file

@ -213,7 +213,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
return filteredOptions; return filteredOptions;
}, },
// ## Model Data Functions // ## Model Data Functions
/** /**
* ### Find All * ### Find All

View file

@ -67,11 +67,11 @@ Settings = ghostBookshelf.Model.extend({
}, },
saving: function () { saving: function () {
// disabling sanitization until we can implement a better version // disabling sanitization until we can implement a better version
// All blog setting keys that need their values to be escaped. // All blog setting keys that need their values to be escaped.
// if (this.get('type') === 'blog' && _.contains(['title', 'description', 'email'], this.get('key'))) { // if (this.get('type') === 'blog' && _.contains(['title', 'description', 'email'], this.get('key'))) {
// this.set('value', this.sanitize('value')); // this.set('value', this.sanitize('value'));
// } // }
return ghostBookshelf.Model.prototype.saving.apply(this, arguments); return ghostBookshelf.Model.prototype.saving.apply(this, arguments);
} }

View file

@ -41,7 +41,7 @@ Tag = ghostBookshelf.Model.extend({
}, },
saving: function (newPage, attr, options) { saving: function (newPage, attr, options) {
/*jshint unused:false*/ /*jshint unused:false*/
var self = this; var self = this;

View file

@ -590,7 +590,7 @@ User = ghostBookshelf.Model.extend({
// Users with the role 'Editor' and 'Author' have complex permissions when the action === 'edit' // Users with the role 'Editor' and 'Author' have complex permissions when the action === 'edit'
// We now have all the info we need to construct the permissions // We now have all the info we need to construct the permissions
if (_.any(loadedPermissions.user.roles, {name: 'Author'})) { if (_.any(loadedPermissions.user.roles, {name: 'Author'})) {
// If this is the same user that requests the operation allow it. // If this is the same user that requests the operation allow it.
hasUserPermission = hasUserPermission || context.user === userModel.get('id'); hasUserPermission = hasUserPermission || context.user === userModel.get('id');
} }
@ -611,7 +611,7 @@ User = ghostBookshelf.Model.extend({
// Users with the role 'Editor' have complex permissions when the action === 'destroy' // Users with the role 'Editor' have complex permissions when the action === 'destroy'
if (_.any(loadedPermissions.user.roles, {name: 'Editor'})) { if (_.any(loadedPermissions.user.roles, {name: 'Editor'})) {
// If this is the same user that requests the operation allow it. // If this is the same user that requests the operation allow it.
hasUserPermission = context.user === userModel.get('id'); hasUserPermission = context.user === userModel.get('id');
// Alternatively, if the user we are trying to edit is an Author, allow it // Alternatively, if the user we are trying to edit is an Author, allow it

View file

@ -289,7 +289,7 @@ casper.captureScreenshot = function (filename, debugOnly) {
} }
}; };
// on failure, grab a screenshot // on failure, grab a screenshot
casper.test.on('fail', function captureFailure() { casper.test.on('fail', function captureFailure() {
casper.captureScreenshot(casper.test.filename || 'casper_test_fail.png', false); casper.captureScreenshot(casper.test.filename || 'casper_test_fail.png', false);
casper.then(function () { casper.then(function () {

View file

@ -83,20 +83,20 @@ CasperTest.begin('Content list shows correct post status', 5, function testStati
casper.thenClick('.post-edit'); casper.thenClick('.post-edit');
casper.waitForSelector('#entry-title'); casper.waitForSelector('#entry-title');
// TODO readd this test when #3811 is fixed // // TODO readd this test when #3811 is fixed
// // Change post to static page // // Change post to static page
// casper.thenClick('.post-settings'); // casper.thenClick('.post-settings');
// casper.waitForOpaque('.post-settings-menu.open'); // casper.waitForOpaque('.post-settings-menu.open');
//
// casper.thenClick('.post-setting-static-page'); // casper.thenClick('.post-setting-static-page');
//
// casper.thenTransitionAndWaitForScreenLoad('content', function onSuccess() { // casper.thenTransitionAndWaitForScreenLoad('content', function onSuccess() {
// casper.waitForSelector('.content-list-content li .entry-meta .status .page', function waitForSuccess() { // casper.waitForSelector('.content-list-content li .entry-meta .status .page', function waitForSuccess() {
// test.assertSelectorHasText('.content-list-content li .entry-meta .status .page', 'Page', 'status is Page'); // test.assertSelectorHasText('.content-list-content li .entry-meta .status .page', 'Page', 'status is Page');
// }, function onTimeout() { // }, function onTimeout() {
// test.assert(false, 'status did not change'); // test.assert(false, 'status did not change');
// }); // });
// }); // });
}); });
// TODO: Implement this test... much needed! // TODO: Implement this test... much needed!

View file

@ -330,7 +330,7 @@ CasperTest.begin('Publish menu - new post', 10, function suite(test) {
}); });
casper.then(function switchMenuToPublish() { casper.then(function switchMenuToPublish() {
// Open the publish options menu; // Open the publish options menu;
casper.thenClick('.js-publish-splitbutton .dropdown-toggle'); casper.thenClick('.js-publish-splitbutton .dropdown-toggle');
casper.waitForOpaque('.js-publish-splitbutton .open'); casper.waitForOpaque('.js-publish-splitbutton .open');
@ -386,7 +386,7 @@ CasperTest.begin('Publish menu - new page', 10, function suite(test) {
casper.thenClick('label[for=static-page]'); casper.thenClick('label[for=static-page]');
casper.then(function switchMenuToPublish() { casper.then(function switchMenuToPublish() {
// Open the publish options menu; // Open the publish options menu;
casper.thenClick('.js-publish-splitbutton .dropdown-toggle'); casper.thenClick('.js-publish-splitbutton .dropdown-toggle');
casper.waitForOpaque('.js-publish-splitbutton .open'); casper.waitForOpaque('.js-publish-splitbutton .open');
@ -596,7 +596,7 @@ CasperTest.begin('Publish menu - new post status is correct after failed save',
}); });
casper.then(function switchMenuToPublish() { casper.then(function switchMenuToPublish() {
// Open the publish options menu; // Open the publish options menu;
casper.thenClick('.js-publish-splitbutton .dropdown-toggle'); casper.thenClick('.js-publish-splitbutton .dropdown-toggle');
casper.waitForOpaque('.js-publish-splitbutton .open'); casper.waitForOpaque('.js-publish-splitbutton .open');

View file

@ -51,7 +51,7 @@ CasperTest.begin('Post url can be changed', 4, function suite(test) {
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
}); });
// Transition to the editor // Transition to the editor
casper.thenClick('.post-edit'); casper.thenClick('.post-edit');
casper.waitForSelector('#entry-title'); casper.waitForSelector('#entry-title');
@ -89,7 +89,7 @@ CasperTest.begin('Post published date can be changed', 4, function suite(test) {
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
}); });
// Transition to the editor // Transition to the editor
casper.thenClick('.post-edit'); casper.thenClick('.post-edit');
casper.waitForSelector('#entry-title'); casper.waitForSelector('#entry-title');

View file

@ -5,33 +5,32 @@
CasperTest.begin('Ghost signup fails properly', 0, function suite(test) { CasperTest.begin('Ghost signup fails properly', 0, function suite(test) {
/*jshint unused:false */ /*jshint unused:false */
/*
casper.thenOpenAndWaitForPageLoad('signup', function then() {
test.assertUrlMatch(/ghost\/signup\/$/, 'Landed on the correct URL');
});
casper.then(function signupWithShortPassword() { // casper.thenOpenAndWaitForPageLoad('signup', function then() {
casper.fillAndSave('#signup', {email: email, password: 'test'}); // test.assertUrlMatch(/ghost\/signup\/$/, 'Landed on the correct URL');
}); // });
// should now throw a short password error // casper.then(function signupWithShortPassword() {
casper.waitForSelector('.notification-error', function onSuccess() { // casper.fillAndSave('#signup', {email: email, password: 'test'});
test.assert(true, 'Got error notification'); // });
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
}, function onTimeout() {
test.assert(false, 'No error notification :(');
});
casper.then(function signupWithLongPassword() { // // should now throw a short password error
casper.fillAndSave('#signup', {email: email, password: 'testing1234'}); // casper.waitForSelector('.notification-error', function onSuccess() {
}); // test.assert(true, 'Got error notification');
// test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
// }, function onTimeout() {
// test.assert(false, 'No error notification :(');
// });
// should now throw a 1 user only error // casper.then(function signupWithLongPassword() {
casper.waitForSelector('.notification-error', function onSuccess() { // casper.fillAndSave('#signup', {email: email, password: 'testing1234'});
test.assert(true, 'Got error notification'); // });
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
}, function onTimeout() { // // should now throw a 1 user only error
test.assert(false, 'No error notification :('); // casper.waitForSelector('.notification-error', function onSuccess() {
}); // test.assert(true, 'Got error notification');
*/ // test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
// }, function onTimeout() {
// test.assert(false, 'No error notification :(');
// });
}, true); }, true);

View file

@ -211,141 +211,141 @@ describe('Admin Routing', function () {
// Add user // Add user
// it('should redirect from /ghost/signup to /ghost/signin with user', function (done) { // it('should redirect from /ghost/signup to /ghost/signin with user', function (done) {
// done(); // done();
// }); // });
// it('should respond with html for /ghost/signin', function (done) { // it('should respond with html for /ghost/signin', function (done) {
// done(); // done();
// }); // });
// Do Login // Do Login
// it('should redirect from /ghost/signup to /ghost/ when logged in', function (done) { // it('should redirect from /ghost/signup to /ghost/ when logged in', function (done) {
// done(); // done();
// }); // });
// it('should redirect from /ghost/signup to /ghost/ when logged in', function (done) { // it('should redirect from /ghost/signup to /ghost/ when logged in', function (done) {
// done(); // done();
// }); // });
}); });
//
// describe('Ghost Admin Forgot Password', function () {
// before(function (done) {
// // Create a user / do setup etc
// testUtils.clearData()
// .then(function () {
// return testUtils.initData();
// })
// .then(function () {
// return testUtils.insertDefaultFixtures();
// }).then(function () {
// done();
// })
// .catch(done);
// });
//
// it('should respond with html for /ghost/forgotten/', function (done) {
// request.get('/ghost/forgotten/')
// .expect('Content-Type', /html/)
// .expect('Cache-Control', testUtils.cacheRules['private'])
// .expect(200)
// .end(doEnd(done));
// });
//
// it('should respond 404 for /ghost/reset/', function (done) {
// request.get('/ghost/reset/')
// .expect('Cache-Control', testUtils.cacheRules['private'])
// .expect(404)
// .expect(/Page Not Found/)
// .end(doEnd(done));
// });
//
// it('should redirect /ghost/reset/*/', function (done) {
// request.get('/ghost/reset/athing/')
// .expect('Location', /ghost\/forgotten/)
// .expect('Cache-Control', testUtils.cacheRules['private'])
// .expect(302)
// .end(doEnd(done));
// });
// });
// });
// TODO: not working anymore, needs new test for Ember // describe('Ghost Admin Forgot Password', function () {
// describe('Authenticated Admin Routing', function () { // before(function (done) {
// var user = testUtils.DataGenerator.forModel.users[0]; // // Create a user / do setup etc
// testUtils.clearData()
// .then(function () {
// return testUtils.initData();
// })
// .then(function () {
// return testUtils.insertDefaultFixtures();
// }).then(function () {
// done();
// })
// .catch(done);
// });
// before(function (done) { // it('should respond with html for /ghost/forgotten/', function (done) {
// var app = express(); // request.get('/ghost/forgotten/')
// .expect('Content-Type', /html/)
// .expect('Cache-Control', testUtils.cacheRules['private'])
// .expect(200)
// .end(doEnd(done));
// });
// ghost({app: app}).then(function (_ghostServer) { // it('should respond 404 for /ghost/reset/', function (done) {
// ghostServer = _ghostServer; // request.get('/ghost/reset/')
// request = agent(app); // .expect('Cache-Control', testUtils.cacheRules['private'])
// .expect(404)
// .expect(/Page Not Found/)
// .end(doEnd(done));
// });
// testUtils.clearData() // it('should redirect /ghost/reset/*/', function (done) {
// .then(function () { // request.get('/ghost/reset/athing/')
// return testUtils.initData(); // .expect('Location', /ghost\/forgotten/)
// }) // .expect('Cache-Control', testUtils.cacheRules['private'])
// .then(function () { // .expect(302)
// return testUtils.insertDefaultFixtures(); // .end(doEnd(done));
// }) // });
// .then(function () { // });
// });
// request.get('/ghost/signin/') // TODO: not working anymore, needs new test for Ember
// .expect(200) // describe('Authenticated Admin Routing', function () {
// .end(function (err, res) { // var user = testUtils.DataGenerator.forModel.users[0];
// if (err) {
// return done(err);
// }
// process.nextTick(function () { // before(function (done) {
// request.post('/ghost/signin/') // var app = express();
// .send({email: user.email, password: user.password})
// .expect(200)
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// request.saveCookies(res); // ghost({app: app}).then(function (_ghostServer) {
// request.get('/ghost/') // ghostServer = _ghostServer;
// .expect(200) // request = agent(app);
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// done(); // testUtils.clearData()
// }); // .then(function () {
// }); // return testUtils.initData();
// })
// .then(function () {
// return testUtils.insertDefaultFixtures();
// })
// .then(function () {
// }); // request.get('/ghost/signin/')
// .expect(200)
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// }); // process.nextTick(function () {
// }).catch(done); // request.post('/ghost/signin/')
// }).catch(function (e) { // .send({email: user.email, password: user.password})
// console.log('Ghost Error: ', e); // .expect(200)
// console.log(e.stack); // .end(function (err, res) {
// }); // if (err) {
// }); // return done(err);
// }
// after(function () { // request.saveCookies(res);
// ghostServer.stop(); // request.get('/ghost/')
// }); // .expect(200)
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// describe('Ghost Admin magic /view/ route', function () { // done();
// });
// });
// it('should redirect to the single post page on the frontend', function (done) { // });
// request.get('/ghost/editor/1/view/')
// .expect(302)
// .expect('Location', '/welcome-to-ghost/')
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// done(); // });
// }); // }).catch(done);
// }); // }).catch(function (e) {
// }); // console.log('Ghost Error: ', e);
// console.log(e.stack);
// });
// });
// after(function () {
// ghostServer.stop();
// });
// describe('Ghost Admin magic /view/ route', function () {
// it('should redirect to the single post page on the frontend', function (done) {
// request.get('/ghost/editor/1/view/')
// .expect(302)
// .expect('Location', '/welcome-to-ghost/')
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// done();
// });
// });
// });
}); });

View file

@ -98,50 +98,50 @@ describe('Authentication API', function () {
}); });
}); });
// describe('Authentication', function () { // describe('Authentication', function () {
//
// describe('Setup not completed', function () { // describe('Setup not completed', function () {
//
// beforeEach(testUtils.setup()); // beforeEach(testUtils.setup());
//
// it('should not allow an invitation to be accepted', function (done) { // it('should not allow an invitation to be accepted', function (done) {
// AuthAPI.acceptInvitation().then(function () { // AuthAPI.acceptInvitation().then(function () {
// done(new Error('Invitation was allowed to be accepted')); // done(new Error('Invitation was allowed to be accepted'));
// }).catch(function (err) { // }).catch(function (err) {
// should.exist(err); // should.exist(err);
//
// err.name.should.equal('NoPermissionError'); // err.name.should.equal('NoPermissionError');
// err.code.should.equal(403); // err.code.should.equal(403);
//
// done(); // done();
// }); // });
// }); // });
//
// it('should not generate a password reset token', function (done) { // it('should not generate a password reset token', function (done) {
// AuthAPI.generateResetToken().then(function () { // AuthAPI.generateResetToken().then(function () {
// done(new Error('Reset token was generated')); // done(new Error('Reset token was generated'));
// }).catch(function (err) { // }).catch(function (err) {
// should.exist(err); // should.exist(err);
//
// err.name.should.equal('NoPermissionError'); // err.name.should.equal('NoPermissionError');
// err.code.should.equal(403); // err.code.should.equal(403);
//
// done(); // done();
// }); // });
// }); // });
//
// it('should not allow a password reset', function (done) { // it('should not allow a password reset', function (done) {
// AuthAPI.resetPassword().then(function () { // AuthAPI.resetPassword().then(function () {
// done(new Error('Password was reset')); // done(new Error('Password was reset'));
// }).catch(function (err) { // }).catch(function (err) {
// should.exist(err); // should.exist(err);
//
// err.name.should.equal('NoPermissionError'); // err.name.should.equal('NoPermissionError');
// err.code.should.equal(403); // err.code.should.equal(403);
//
// done(); // done();
// }); // });
// }); // });
// }); // });
// }); // });
}); });

View file

@ -86,91 +86,91 @@ describe('Permission Model', function () {
}).catch(done); }).catch(done);
}); });
// it('can add user to role', function (done) { // it('can add user to role', function (done) {
// var existingUserRoles; // var existingUserRoles;
//
// Models.User.findOne({id: 1}, { withRelated: ['roles'] }).then(function (foundUser) { // Models.User.findOne({id: 1}, { withRelated: ['roles'] }).then(function (foundUser) {
// var testRole = new Models.Role({ // var testRole = new Models.Role({
// name: 'testrole1', // name: 'testrole1',
// description: 'testrole1 description' // description: 'testrole1 description'
// }); // });
//
// should.exist(foundUser); // should.exist(foundUser);
//
// should.exist(foundUser.roles()); // should.exist(foundUser.roles());
//
// existingUserRoles = foundUser.related('roles').length; // existingUserRoles = foundUser.related('roles').length;
//
// return testRole.save(null, context).then(function () { // return testRole.save(null, context).then(function () {
// return foundUser.roles().attach(testRole); // return foundUser.roles().attach(testRole);
// }); // });
// }).then(function () { // }).then(function () {
// return Models.User.findOne({id: 1}, { withRelated: ['roles'] }); // return Models.User.findOne({id: 1}, { withRelated: ['roles'] });
// }).then(function (updatedUser) { // }).then(function (updatedUser) {
// should.exist(updatedUser); // should.exist(updatedUser);
//
// updatedUser.related('roles').length.should.equal(existingUserRoles + 1); // updatedUser.related('roles').length.should.equal(existingUserRoles + 1);
//
// done(); // done();
// }).catch(done); // }).catch(done);
// }); // });
//
// it('can add user permissions', function (done) { // it('can add user permissions', function (done) {
// Models.User.findOne({id: 1}, { withRelated: ['permissions']}).then(function (testUser) { // Models.User.findOne({id: 1}, { withRelated: ['permissions']}).then(function (testUser) {
// var testPermission = new Models.Permission({ // var testPermission = new Models.Permission({
// name: 'test edit posts', // name: 'test edit posts',
// action_type: 'edit', // action_type: 'edit',
// object_type: 'post' // object_type: 'post'
// }); // });
//
// testUser.related('permissions').length.should.equal(0); // testUser.related('permissions').length.should.equal(0);
//
// return testPermission.save(null, context).then(function () { // return testPermission.save(null, context).then(function () {
// return testUser.permissions().attach(testPermission); // return testUser.permissions().attach(testPermission);
// }); // });
// }).then(function () { // }).then(function () {
// return Models.User.findOne({id: 1}, { include: ['permissions']}); // return Models.User.findOne({id: 1}, { include: ['permissions']});
// }).then(function (updatedUser) { // }).then(function (updatedUser) {
// should.exist(updatedUser); // should.exist(updatedUser);
//
// updatedUser.related('permissions').length.should.equal(1); // updatedUser.related('permissions').length.should.equal(1);
//
// done(); // done();
// }).catch(done); // }).catch(done);
// }); // });
//
// it('can add role permissions', function (done) { // it('can add role permissions', function (done) {
// var testRole = new Models.Role({ // var testRole = new Models.Role({
// name: 'test2', // name: 'test2',
// description: 'test2 description' // description: 'test2 description'
// }); // });
//
// testRole.save(null, context) // testRole.save(null, context)
// .then(function () { // .then(function () {
// return testRole.load('permissions'); // return testRole.load('permissions');
// }) // })
// .then(function () { // .then(function () {
// var rolePermission = new Models.Permission({ // var rolePermission = new Models.Permission({
// name: 'test edit posts', // name: 'test edit posts',
// action_type: 'edit', // action_type: 'edit',
// object_type: 'post' // object_type: 'post'
// }); // });
//
// testRole.related('permissions').length.should.equal(0); // testRole.related('permissions').length.should.equal(0);
//
// return rolePermission.save(null, context).then(function () { // return rolePermission.save(null, context).then(function () {
// return testRole.permissions().attach(rolePermission); // return testRole.permissions().attach(rolePermission);
// }); // });
// }) // })
// .then(function () { // .then(function () {
// return Models.Role.findOne({id: testRole.id}, { withRelated: ['permissions']}); // return Models.Role.findOne({id: testRole.id}, { withRelated: ['permissions']});
// }) // })
// .then(function (updatedRole) { // .then(function (updatedRole) {
// should.exist(updatedRole); // should.exist(updatedRole);
//
// updatedRole.related('permissions').length.should.equal(1); // updatedRole.related('permissions').length.should.equal(1);
//
// done(); // done();
// }).catch(done); // }).catch(done);
// }); // });
}); });

View file

@ -376,7 +376,7 @@ describe('Config', function () {
}); });
it('creates the config file if one does not exist', function (done) { it('creates the config file if one does not exist', function (done) {
// trick bootstrap into thinking that the config file doesn't exist yet // trick bootstrap into thinking that the config file doesn't exist yet
var existsStub = sandbox.stub(fs, 'stat', function (file, cb) { return cb(true); }), var existsStub = sandbox.stub(fs, 'stat', function (file, cb) { return cb(true); }),
// ensure that the file creation is a stub, the tests shouldn't really create a file // ensure that the file creation is a stub, the tests shouldn't really create a file
writeFileStub = sandbox.stub(config, 'writeFile').returns(Promise.resolve()), writeFileStub = sandbox.stub(config, 'writeFile').returns(Promise.resolve()),
@ -403,13 +403,13 @@ describe('Config', function () {
}).then(function (localConfig) { }).then(function (localConfig) {
localConfig.url.should.equal('https://testurl.com'); localConfig.url.should.equal('https://testurl.com');
// Next test // Next test
overrideConfig({url: 'http://testurl.com/blog/'}); overrideConfig({url: 'http://testurl.com/blog/'});
return config.load(); return config.load();
}).then(function (localConfig) { }).then(function (localConfig) {
localConfig.url.should.equal('http://testurl.com/blog/'); localConfig.url.should.equal('http://testurl.com/blog/');
// Next test // Next test
overrideConfig({url: 'http://testurl.com/ghostly/'}); overrideConfig({url: 'http://testurl.com/ghostly/'});
return config.load(); return config.load();
}).then(function (localConfig) { }).then(function (localConfig) {

View file

@ -47,236 +47,236 @@ describe('Permissions', function () {
}).catch(done); }).catch(done);
}); });
// it('does not allow edit post without permission', function (done) { // it('does not allow edit post without permission', function (done) {
// var fakePage = { // var fakePage = {
// id: 1 // id: 1
// }; // };
//
// permissions.init() // permissions.init()
// .then(function () { // .then(function () {
// var canThisResult = permissions.canThis({id: 1}); // var canThisResult = permissions.canThis({id: 1});
//
// should.exist(canThisResult.edit); // should.exist(canThisResult.edit);
// should.exist(canThisResult.edit.post); // should.exist(canThisResult.edit.post);
//
// return canThisResult.edit.page(fakePage); // return canThisResult.edit.page(fakePage);
// }) // })
// .then(function () { // .then(function () {
// done(new Error('was able to edit post without permission')); // done(new Error('was able to edit post without permission'));
// }).catch(done); // }).catch(done);
// }); // });
// ////
// it('allows edit post with permission', function (done) { // it('allows edit post with permission', function (done) {
// var fakePost = { // var fakePost = {
// id: '1' // id: '1'
// }; // };
//
// permissions.init() // permissions.init()
// .then(function () { // .then(function () {
// return Models.User.findOne({id: 1}); // return Models.User.findOne({id: 1});
// }) // })
// .then(function (foundUser) { // .then(function (foundUser) {
// var newPerm = new Models.Permission({ // var newPerm = new Models.Permission({
// name: 'test3 edit post', // name: 'test3 edit post',
// action_type: 'edit', // action_type: 'edit',
// object_type: 'post' // object_type: 'post'
// }); // });
//
// return newPerm.save(null, context).then(function () { // return newPerm.save(null, context).then(function () {
// return foundUser.permissions().attach(newPerm); // return foundUser.permissions().attach(newPerm);
// }); // });
// }) // })
// .then(function () { // .then(function () {
// return Models.User.findOne({id: 1}, { withRelated: ['permissions']}); // return Models.User.findOne({id: 1}, { withRelated: ['permissions']});
// }) // })
// .then(function (updatedUser) { // .then(function (updatedUser) {
//
// // TODO: Verify updatedUser.related('permissions') has the permission? // // TODO: Verify updatedUser.related('permissions') has the permission?
// var canThisResult = permissions.canThis(updatedUser.id); // var canThisResult = permissions.canThis(updatedUser.id);
//
// should.exist(canThisResult.edit); // should.exist(canThisResult.edit);
// should.exist(canThisResult.edit.post); // should.exist(canThisResult.edit.post);
//
// return canThisResult.edit.post(fakePost); // return canThisResult.edit.post(fakePost);
// }) // })
// .then(function () { // .then(function () {
// done(); // done();
// }).catch(done); // }).catch(done);
// }); // });
//
// it('can use permissible function on Model to allow something', function (done) { // it('can use permissible function on Model to allow something', function (done) {
// var testUser, // var testUser,
// permissibleStub = sandbox.stub(Models.Post, 'permissible', function () { // permissibleStub = sandbox.stub(Models.Post, 'permissible', function () {
// return Promise.resolve(); // return Promise.resolve();
// }); // });
//
// testUtils.insertAuthorUser() // testUtils.insertAuthorUser()
// .then(function () { // .then(function () {
// return Models.User.findAll(); // return Models.User.findAll();
// }) // })
// .then(function (foundUser) { // .then(function (foundUser) {
// testUser = foundUser.models[1]; // testUser = foundUser.models[1];
//
// return permissions.canThis({user: testUser.id}).edit.post(123); // return permissions.canThis({user: testUser.id}).edit.post(123);
// }) // })
// .then(function () { // .then(function () {
// permissibleStub.restore(); // permissibleStub.restore();
// permissibleStub.calledWith(123, { user: testUser.id, app: null, internal: false }) // permissibleStub.calledWith(123, { user: testUser.id, app: null, internal: false })
// .should.equal(true); // .should.equal(true);
//
// done(); // done();
// }) // })
// .catch(function () { // .catch(function () {
// permissibleStub.restore(); // permissibleStub.restore();
//
// done(new Error('did not allow testUser')); // done(new Error('did not allow testUser'));
// }); // });
// }); // });
//
// it('can use permissible function on Model to forbid something', function (done) { // it('can use permissible function on Model to forbid something', function (done) {
// var testUser, // var testUser,
// permissibleStub = sandbox.stub(Models.Post, 'permissible', function () { // permissibleStub = sandbox.stub(Models.Post, 'permissible', function () {
// return Promise.reject(); // return Promise.reject();
// }); // });
//
// testUtils.insertAuthorUser() // testUtils.insertAuthorUser()
// .then(function () { // .then(function () {
// return Models.User.findAll(); // return Models.User.findAll();
// }) // })
// .then(function (foundUser) { // .then(function (foundUser) {
// testUser = foundUser.models[1]; // testUser = foundUser.models[1];
//
// return permissions.canThis({user: testUser.id}).edit.post(123); // return permissions.canThis({user: testUser.id}).edit.post(123);
// }) // })
// .then(function () { // .then(function () {
//
// permissibleStub.restore(); // permissibleStub.restore();
// done(new Error('Allowed testUser to edit post')); // done(new Error('Allowed testUser to edit post'));
// }) // })
// .catch(function () { // .catch(function () {
// permissibleStub.calledWith(123, { user: testUser.id, app: null, internal: false }) // permissibleStub.calledWith(123, { user: testUser.id, app: null, internal: false })
// .should.equal(true); // .should.equal(true);
// permissibleStub.restore(); // permissibleStub.restore();
// done(); // done();
// }); // });
// }); // });
//
// it('can get effective user permissions', function (done) { // it('can get effective user permissions', function (done) {
// effectivePerms.user(1).then(function (effectivePermissions) { // effectivePerms.user(1).then(function (effectivePermissions) {
// should.exist(effectivePermissions); // should.exist(effectivePermissions);
//
// effectivePermissions.length.should.be.above(0); // effectivePermissions.length.should.be.above(0);
//
// done(); // done();
// }).catch(done); // }).catch(done);
// }); // });
//
// it('can check an apps effective permissions', function (done) { // it('can check an apps effective permissions', function (done) {
// effectivePerms.app('Kudos') // effectivePerms.app('Kudos')
// .then(function (effectivePermissions) { // .then(function (effectivePermissions) {
// should.exist(effectivePermissions); // should.exist(effectivePermissions);
//
// effectivePermissions.length.should.be.above(0); // effectivePermissions.length.should.be.above(0);
//
// done(); // done();
// }) // })
// .catch(done); // .catch(done);
// }); // });
//
// it('does not allow an app to edit a post without permission', function (done) { // it('does not allow an app to edit a post without permission', function (done) {
// // Change the author of the post so the author override doesn't affect the test // // Change the author of the post so the author override doesn't affect the test
// Models.Post.edit({'author_id': 2}, _.extend(context, {id: 1})) // Models.Post.edit({'author_id': 2}, _.extend(context, {id: 1}))
// .then(function (updatedPost) { // .then(function (updatedPost) {
// // Add user permissions // // Add user permissions
// return Models.User.findOne({id: 1}) // return Models.User.findOne({id: 1})
// .then(function (foundUser) { // .then(function (foundUser) {
// var newPerm = new Models.Permission({ // var newPerm = new Models.Permission({
// name: 'app test edit post', // name: 'app test edit post',
// action_type: 'edit', // action_type: 'edit',
// object_type: 'post' // object_type: 'post'
// }); // });
//
// return newPerm.save(null, context).then(function () { // return newPerm.save(null, context).then(function () {
// return foundUser.permissions().attach(newPerm).then(function () { // return foundUser.permissions().attach(newPerm).then(function () {
// return Promise.all([updatedPost, foundUser]); // return Promise.all([updatedPost, foundUser]);
// }); // });
// }); // });
// }); // });
// }) // })
// .then(function (results) { // .then(function (results) {
// var updatedPost = results[0], // var updatedPost = results[0],
// updatedUser = results[1]; // updatedUser = results[1];
//
// return permissions.canThis({ user: updatedUser.id }) // return permissions.canThis({ user: updatedUser.id })
// .edit // .edit
// .post(updatedPost.id) // .post(updatedPost.id)
// .then(function () { // .then(function () {
// return results; // return results;
// }) // })
// .catch(function (err) { // .catch(function (err) {
// /*jshint unused:false */ // /*jshint unused:false */
// done(new Error('Did not allow user 1 to edit post 1')); // done(new Error('Did not allow user 1 to edit post 1'));
// }); // });
// }) // })
// .then(function (results) { // .then(function (results) {
// var updatedPost = results[0], // var updatedPost = results[0],
// updatedUser = results[1]; // updatedUser = results[1];
//
// // Confirm app cannot edit it. // // Confirm app cannot edit it.
// return permissions.canThis({ app: 'Hemingway', user: updatedUser.id }) // return permissions.canThis({ app: 'Hemingway', user: updatedUser.id })
// .edit // .edit
// .post(updatedPost.id) // .post(updatedPost.id)
// .then(function () { // .then(function () {
// done(new Error('Allowed an edit of post 1')); // done(new Error('Allowed an edit of post 1'));
// }).catch(done); // }).catch(done);
// }).catch(done); // }).catch(done);
// }); // });
//
// it('allows an app to edit a post with permission', function (done) { // it('allows an app to edit a post with permission', function (done) {
// permissions.canThis({ app: 'Kudos', user: 1 }) // permissions.canThis({ app: 'Kudos', user: 1 })
// .edit // .edit
// .post(1) // .post(1)
// .then(function () { // .then(function () {
// done(); // done();
// }) // })
// .catch(function () { // .catch(function () {
// done(new Error('Did not allow an edit of post 1')); // done(new Error('Did not allow an edit of post 1'));
// }); // });
// }); // });
//
// it('checks for null context passed and rejects', function (done) { // it('checks for null context passed and rejects', function (done) {
// permissions.canThis(undefined) // permissions.canThis(undefined)
// .edit // .edit
// .post(1) // .post(1)
// .then(function () { // .then(function () {
// done(new Error('Should not allow editing post')); // done(new Error('Should not allow editing post'));
// }) // })
// .catch(done); // .catch(done);
// }); // });
//
// it('allows \'internal\' to be passed for internal requests', function (done) { // it('allows \'internal\' to be passed for internal requests', function (done) {
// // Using tag here because post implements the custom permissible interface // // Using tag here because post implements the custom permissible interface
// permissions.canThis('internal') // permissions.canThis('internal')
// .edit // .edit
// .tag(1) // .tag(1)
// .then(function () { // .then(function () {
// done(); // done();
// }) // })
// .catch(function () { // .catch(function () {
// done(new Error('Should allow editing post with "internal"')); // done(new Error('Should allow editing post with "internal"'));
// }); // });
// }); // });
//
// it('allows { internal: true } to be passed for internal requests', function (done) { // it('allows { internal: true } to be passed for internal requests', function (done) {
// // Using tag here because post implements the custom permissible interface // // Using tag here because post implements the custom permissible interface
// permissions.canThis({ internal: true }) // permissions.canThis({internal: true})
// .edit // .edit
// .tag(1) // .tag(1)
// .then(function () { // .then(function () {
// done(); // done();
// }) // })
// .catch(function () { // .catch(function () {
// done(new Error('Should allow editing post with { internal: true }')); // done(new Error('Should allow editing post with { internal: true }'));
// }); // });
// }); // });
}); });

View file

@ -41,13 +41,13 @@ describe('Showdown client side converter', function () {
processedMarkup.should.match(testPhrase.output); processedMarkup.should.match(testPhrase.output);
}); });
// Currently failing - fixing this causes other issues // Currently failing - fixing this causes other issues
// it('should not create italic words between lines', function () { // it('should not create italic words between lines', function () {
// var testPhrase = {input: 'foo_bar\nbar_foo', output: /^<p>foo_bar <br \/>\nbar_foo<\/p>$/}, // var testPhrase = {input: 'foo_bar\nbar_foo', output: /^<p>foo_bar <br \/>\nbar_foo<\/p>$/},
// processedMarkup = converter.makeHtml(testPhrase.input); // processedMarkup = converter.makeHtml(testPhrase.input);
//
// processedMarkup.should.match(testPhrase.output); // processedMarkup.should.match(testPhrase.output);
// }); // });
it('should not touch underscores in code blocks', function () { it('should not touch underscores in code blocks', function () {
var testPhrase = {input: ' foo_bar_baz', output: /^<pre><code>foo_bar_baz\n<\/code><\/pre>$/}, var testPhrase = {input: ' foo_bar_baz', output: /^<pre><code>foo_bar_baz\n<\/code><\/pre>$/},
@ -576,15 +576,15 @@ describe('Showdown client side converter', function () {
it('should not effect pre tags', function () { it('should not effect pre tags', function () {
var testPhrase = { var testPhrase = {
input: '```javascript\n' + input: '```javascript\n' +
'var foo = "bar";\n' + 'var foo = "bar";\n' +
'if (foo === "bar") {\n' + 'if (foo === "bar") {\n' +
' return true;\n' + ' return true;\n' +
'} else if (foo === "baz") {\n' + '} else if (foo === "baz") {\n' +
' return "magic happened";\n' + ' return "magic happened";\n' +
'}\n' + '}\n' +
'```', '```',
output: /^<mark><\/mark>$/ output: /^<mark><\/mark>$/
}, },
processedMarkup = converter.makeHtml(testPhrase.input); processedMarkup = converter.makeHtml(testPhrase.input);
@ -617,17 +617,17 @@ describe('Showdown client side converter', function () {
}); });
}); });
// Waiting for showdown typography to be updated // Waiting for showdown typography to be updated
// it('should correctly convert quotes to curly quotes', function () { // it('should correctly convert quotes to curly quotes', function () {
// var testPhrases = [ // var testPhrases = [
// { // {
// input: 'Hello world\nIt's a fine day\nout', // input: 'Hello world\nIt's a fine day\nout',
// output: /^<p>Hello world <br \/>\nIts a fine day <br \/>\nout<\/p>$/} // output: /^<p>Hello world <br \/>\nIts a fine day <br \/>\nout<\/p>$/}
// ]; // ];
//
// testPhrases.forEach(function (testPhrase) { // testPhrases.forEach(function (testPhrase) {
// processedMarkup = converter.makeHtml(testPhrase.input); // processedMarkup = converter.makeHtml(testPhrase.input);
// processedMarkup.should.match(testPhrase.output); // processedMarkup.should.match(testPhrase.output);
// }); // });
// }) // });
}); });

View file

@ -84,7 +84,7 @@
"grunt-contrib-watch": "~0.6.1", "grunt-contrib-watch": "~0.6.1",
"grunt-docker": "~0.0.8", "grunt-docker": "~0.0.8",
"grunt-express-server": "~0.4.19", "grunt-express-server": "~0.4.19",
"grunt-jscs": "~1.2.0", "grunt-jscs": "~1.8.0",
"grunt-mocha-cli": "~1.11.0", "grunt-mocha-cli": "~1.11.0",
"grunt-mocha-istanbul": "2.4.0", "grunt-mocha-istanbul": "2.4.0",
"grunt-shell": "~1.1.1", "grunt-shell": "~1.1.1",