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: {
app: {
js: assetLocation('ghost.js')
// css: see config/environment.js (sassOptions)
// css: see config/environment.js (sassOptions)
},
vendor: {
js: assetLocation('vendor.js'),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@ Tag = ghostBookshelf.Model.extend({
},
saving: function (newPage, attr, options) {
/*jshint unused:false*/
/*jshint unused:false*/
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'
// We now have all the info we need to construct the permissions
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');
}
@ -611,7 +611,7 @@ User = ghostBookshelf.Model.extend({
// Users with the role 'Editor' have complex permissions when the action === 'destroy'
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');
// 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.captureScreenshot(casper.test.filename || 'casper_test_fail.png', false);
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.waitForSelector('#entry-title');
// TODO readd this test when #3811 is fixed
// // Change post to static page
// casper.thenClick('.post-settings');
// casper.waitForOpaque('.post-settings-menu.open');
//
// casper.thenClick('.post-setting-static-page');
//
// casper.thenTransitionAndWaitForScreenLoad('content', function onSuccess() {
// 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');
// }, function onTimeout() {
// test.assert(false, 'status did not change');
// });
// });
// // TODO readd this test when #3811 is fixed
// // Change post to static page
// casper.thenClick('.post-settings');
// casper.waitForOpaque('.post-settings-menu.open');
// casper.thenClick('.post-setting-static-page');
// casper.thenTransitionAndWaitForScreenLoad('content', function onSuccess() {
// 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');
// }, function onTimeout() {
// test.assert(false, 'status did not change');
// });
// });
});
// 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() {
// Open the publish options menu;
// Open the publish options menu;
casper.thenClick('.js-publish-splitbutton .dropdown-toggle');
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.then(function switchMenuToPublish() {
// Open the publish options menu;
// Open the publish options menu;
casper.thenClick('.js-publish-splitbutton .dropdown-toggle');
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() {
// Open the publish options menu;
// Open the publish options menu;
casper.thenClick('.js-publish-splitbutton .dropdown-toggle');
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');
});
// Transition to the editor
// Transition to the editor
casper.thenClick('.post-edit');
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');
});
// Transition to the editor
// Transition to the editor
casper.thenClick('.post-edit');
casper.waitForSelector('#entry-title');

View File

@ -5,33 +5,32 @@
CasperTest.begin('Ghost signup fails properly', 0, function suite(test) {
/*jshint unused:false */
/*
casper.thenOpenAndWaitForPageLoad('signup', function then() {
test.assertUrlMatch(/ghost\/signup\/$/, 'Landed on the correct URL');
});
casper.then(function signupWithShortPassword() {
casper.fillAndSave('#signup', {email: email, password: 'test'});
});
// casper.thenOpenAndWaitForPageLoad('signup', function then() {
// test.assertUrlMatch(/ghost\/signup\/$/, 'Landed on the correct URL');
// });
// should now throw a short password error
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 :(');
});
// casper.then(function signupWithShortPassword() {
// casper.fillAndSave('#signup', {email: email, password: 'test'});
// });
casper.then(function signupWithLongPassword() {
casper.fillAndSave('#signup', {email: email, password: 'testing1234'});
});
// // should now throw a short password error
// 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.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 :(');
});
*/
// casper.then(function signupWithLongPassword() {
// casper.fillAndSave('#signup', {email: email, password: 'testing1234'});
// });
// // should now throw a 1 user only error
// 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);

View File

@ -211,141 +211,141 @@ describe('Admin Routing', function () {
// Add user
// it('should redirect from /ghost/signup to /ghost/signin with user', function (done) {
// done();
// });
// it('should redirect from /ghost/signup to /ghost/signin with user', function (done) {
// done();
// });
// it('should respond with html for /ghost/signin', function (done) {
// done();
// });
// it('should respond with html for /ghost/signin', function (done) {
// done();
// });
// Do Login
// it('should redirect from /ghost/signup to /ghost/ when logged in', function (done) {
// done();
// });
// it('should redirect from /ghost/signup to /ghost/ when logged in', function (done) {
// done();
// });
// it('should redirect from /ghost/signup to /ghost/ when logged in', function (done) {
// done();
// });
// it('should redirect from /ghost/signup to /ghost/ when logged in', function (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('Authenticated Admin Routing', function () {
// var user = testUtils.DataGenerator.forModel.users[0];
// 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);
// });
// before(function (done) {
// var app = express();
// 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));
// });
// ghost({app: app}).then(function (_ghostServer) {
// ghostServer = _ghostServer;
// request = agent(app);
// 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));
// });
// testUtils.clearData()
// .then(function () {
// return testUtils.initData();
// })
// .then(function () {
// return testUtils.insertDefaultFixtures();
// })
// .then(function () {
// 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));
// });
// });
// });
// request.get('/ghost/signin/')
// .expect(200)
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// TODO: not working anymore, needs new test for Ember
// describe('Authenticated Admin Routing', function () {
// var user = testUtils.DataGenerator.forModel.users[0];
// process.nextTick(function () {
// request.post('/ghost/signin/')
// .send({email: user.email, password: user.password})
// .expect(200)
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// before(function (done) {
// var app = express();
// request.saveCookies(res);
// request.get('/ghost/')
// .expect(200)
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// ghost({app: app}).then(function (_ghostServer) {
// ghostServer = _ghostServer;
// request = agent(app);
// 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);
// }
// });
// }).catch(done);
// }).catch(function (e) {
// console.log('Ghost Error: ', e);
// console.log(e.stack);
// });
// });
// process.nextTick(function () {
// request.post('/ghost/signin/')
// .send({email: user.email, password: user.password})
// .expect(200)
// .end(function (err, res) {
// if (err) {
// return done(err);
// }
// after(function () {
// ghostServer.stop();
// });
// request.saveCookies(res);
// 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('Setup not completed', function () {
//
// beforeEach(testUtils.setup());
//
// it('should not allow an invitation to be accepted', function (done) {
// AuthAPI.acceptInvitation().then(function () {
// done(new Error('Invitation was allowed to be accepted'));
// }).catch(function (err) {
// should.exist(err);
//
// err.name.should.equal('NoPermissionError');
// err.code.should.equal(403);
//
// done();
// });
// });
//
// it('should not generate a password reset token', function (done) {
// AuthAPI.generateResetToken().then(function () {
// done(new Error('Reset token was generated'));
// }).catch(function (err) {
// should.exist(err);
//
// err.name.should.equal('NoPermissionError');
// err.code.should.equal(403);
//
// done();
// });
// });
//
// it('should not allow a password reset', function (done) {
// AuthAPI.resetPassword().then(function () {
// done(new Error('Password was reset'));
// }).catch(function (err) {
// should.exist(err);
//
// err.name.should.equal('NoPermissionError');
// err.code.should.equal(403);
//
// done();
// });
// });
// });
// });
// describe('Authentication', function () {
// describe('Setup not completed', function () {
// beforeEach(testUtils.setup());
// it('should not allow an invitation to be accepted', function (done) {
// AuthAPI.acceptInvitation().then(function () {
// done(new Error('Invitation was allowed to be accepted'));
// }).catch(function (err) {
// should.exist(err);
// err.name.should.equal('NoPermissionError');
// err.code.should.equal(403);
// done();
// });
// });
// it('should not generate a password reset token', function (done) {
// AuthAPI.generateResetToken().then(function () {
// done(new Error('Reset token was generated'));
// }).catch(function (err) {
// should.exist(err);
// err.name.should.equal('NoPermissionError');
// err.code.should.equal(403);
// done();
// });
// });
// it('should not allow a password reset', function (done) {
// AuthAPI.resetPassword().then(function () {
// done(new Error('Password was reset'));
// }).catch(function (err) {
// should.exist(err);
// err.name.should.equal('NoPermissionError');
// err.code.should.equal(403);
// done();
// });
// });
// });
// });
});

View File

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

View File

@ -376,7 +376,7 @@ describe('Config', function () {
});
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); }),
// ensure that the file creation is a stub, the tests shouldn't really create a file
writeFileStub = sandbox.stub(config, 'writeFile').returns(Promise.resolve()),
@ -403,13 +403,13 @@ describe('Config', function () {
}).then(function (localConfig) {
localConfig.url.should.equal('https://testurl.com');
// Next test
// Next test
overrideConfig({url: 'http://testurl.com/blog/'});
return config.load();
}).then(function (localConfig) {
localConfig.url.should.equal('http://testurl.com/blog/');
// Next test
// Next test
overrideConfig({url: 'http://testurl.com/ghostly/'});
return config.load();
}).then(function (localConfig) {

View File

@ -47,236 +47,236 @@ describe('Permissions', function () {
}).catch(done);
});
// it('does not allow edit post without permission', function (done) {
// var fakePage = {
// id: 1
// };
//
// permissions.init()
// .then(function () {
// var canThisResult = permissions.canThis({id: 1});
//
// should.exist(canThisResult.edit);
// should.exist(canThisResult.edit.post);
//
// return canThisResult.edit.page(fakePage);
// })
// .then(function () {
// done(new Error('was able to edit post without permission'));
// }).catch(done);
// });
// ////
// it('allows edit post with permission', function (done) {
// var fakePost = {
// id: '1'
// };
//
// permissions.init()
// .then(function () {
// return Models.User.findOne({id: 1});
// })
// .then(function (foundUser) {
// var newPerm = new Models.Permission({
// name: 'test3 edit post',
// action_type: 'edit',
// object_type: 'post'
// });
//
// return newPerm.save(null, context).then(function () {
// return foundUser.permissions().attach(newPerm);
// });
// })
// .then(function () {
// return Models.User.findOne({id: 1}, { withRelated: ['permissions']});
// })
// .then(function (updatedUser) {
//
// // TODO: Verify updatedUser.related('permissions') has the permission?
// var canThisResult = permissions.canThis(updatedUser.id);
//
// should.exist(canThisResult.edit);
// should.exist(canThisResult.edit.post);
//
// return canThisResult.edit.post(fakePost);
// })
// .then(function () {
// done();
// }).catch(done);
// });
//
// it('can use permissible function on Model to allow something', function (done) {
// var testUser,
// permissibleStub = sandbox.stub(Models.Post, 'permissible', function () {
// return Promise.resolve();
// });
//
// testUtils.insertAuthorUser()
// .then(function () {
// return Models.User.findAll();
// })
// .then(function (foundUser) {
// testUser = foundUser.models[1];
//
// return permissions.canThis({user: testUser.id}).edit.post(123);
// })
// .then(function () {
// permissibleStub.restore();
// permissibleStub.calledWith(123, { user: testUser.id, app: null, internal: false })
// .should.equal(true);
//
// done();
// })
// .catch(function () {
// permissibleStub.restore();
//
// done(new Error('did not allow testUser'));
// });
// });
//
// it('can use permissible function on Model to forbid something', function (done) {
// var testUser,
// permissibleStub = sandbox.stub(Models.Post, 'permissible', function () {
// return Promise.reject();
// });
//
// testUtils.insertAuthorUser()
// .then(function () {
// return Models.User.findAll();
// })
// .then(function (foundUser) {
// testUser = foundUser.models[1];
//
// return permissions.canThis({user: testUser.id}).edit.post(123);
// })
// .then(function () {
//
// permissibleStub.restore();
// done(new Error('Allowed testUser to edit post'));
// })
// .catch(function () {
// permissibleStub.calledWith(123, { user: testUser.id, app: null, internal: false })
// .should.equal(true);
// permissibleStub.restore();
// done();
// });
// });
//
// it('can get effective user permissions', function (done) {
// effectivePerms.user(1).then(function (effectivePermissions) {
// should.exist(effectivePermissions);
//
// effectivePermissions.length.should.be.above(0);
//
// done();
// }).catch(done);
// });
//
// it('can check an apps effective permissions', function (done) {
// effectivePerms.app('Kudos')
// .then(function (effectivePermissions) {
// should.exist(effectivePermissions);
//
// effectivePermissions.length.should.be.above(0);
//
// done();
// })
// .catch(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
// Models.Post.edit({'author_id': 2}, _.extend(context, {id: 1}))
// .then(function (updatedPost) {
// // Add user permissions
// return Models.User.findOne({id: 1})
// .then(function (foundUser) {
// var newPerm = new Models.Permission({
// name: 'app test edit post',
// action_type: 'edit',
// object_type: 'post'
// });
//
// return newPerm.save(null, context).then(function () {
// return foundUser.permissions().attach(newPerm).then(function () {
// return Promise.all([updatedPost, foundUser]);
// });
// });
// });
// })
// .then(function (results) {
// var updatedPost = results[0],
// updatedUser = results[1];
//
// return permissions.canThis({ user: updatedUser.id })
// .edit
// .post(updatedPost.id)
// .then(function () {
// return results;
// })
// .catch(function (err) {
// /*jshint unused:false */
// done(new Error('Did not allow user 1 to edit post 1'));
// });
// })
// .then(function (results) {
// var updatedPost = results[0],
// updatedUser = results[1];
//
// // Confirm app cannot edit it.
// return permissions.canThis({ app: 'Hemingway', user: updatedUser.id })
// .edit
// .post(updatedPost.id)
// .then(function () {
// done(new Error('Allowed an edit of post 1'));
// }).catch(done);
// }).catch(done);
// });
//
// it('allows an app to edit a post with permission', function (done) {
// permissions.canThis({ app: 'Kudos', user: 1 })
// .edit
// .post(1)
// .then(function () {
// done();
// })
// .catch(function () {
// done(new Error('Did not allow an edit of post 1'));
// });
// });
//
// it('checks for null context passed and rejects', function (done) {
// permissions.canThis(undefined)
// .edit
// .post(1)
// .then(function () {
// done(new Error('Should not allow editing post'));
// })
// .catch(done);
// });
//
// it('allows \'internal\' to be passed for internal requests', function (done) {
// // Using tag here because post implements the custom permissible interface
// permissions.canThis('internal')
// .edit
// .tag(1)
// .then(function () {
// done();
// })
// .catch(function () {
// done(new Error('Should allow editing post with "internal"'));
// });
// });
//
// it('allows { internal: true } to be passed for internal requests', function (done) {
// // Using tag here because post implements the custom permissible interface
// permissions.canThis({ internal: true })
// .edit
// .tag(1)
// .then(function () {
// done();
// })
// .catch(function () {
// done(new Error('Should allow editing post with { internal: true }'));
// });
// });
// it('does not allow edit post without permission', function (done) {
// var fakePage = {
// id: 1
// };
// permissions.init()
// .then(function () {
// var canThisResult = permissions.canThis({id: 1});
// should.exist(canThisResult.edit);
// should.exist(canThisResult.edit.post);
// return canThisResult.edit.page(fakePage);
// })
// .then(function () {
// done(new Error('was able to edit post without permission'));
// }).catch(done);
// });
// it('allows edit post with permission', function (done) {
// var fakePost = {
// id: '1'
// };
// permissions.init()
// .then(function () {
// return Models.User.findOne({id: 1});
// })
// .then(function (foundUser) {
// var newPerm = new Models.Permission({
// name: 'test3 edit post',
// action_type: 'edit',
// object_type: 'post'
// });
// return newPerm.save(null, context).then(function () {
// return foundUser.permissions().attach(newPerm);
// });
// })
// .then(function () {
// return Models.User.findOne({id: 1}, { withRelated: ['permissions']});
// })
// .then(function (updatedUser) {
// // TODO: Verify updatedUser.related('permissions') has the permission?
// var canThisResult = permissions.canThis(updatedUser.id);
// should.exist(canThisResult.edit);
// should.exist(canThisResult.edit.post);
// return canThisResult.edit.post(fakePost);
// })
// .then(function () {
// done();
// }).catch(done);
// });
// it('can use permissible function on Model to allow something', function (done) {
// var testUser,
// permissibleStub = sandbox.stub(Models.Post, 'permissible', function () {
// return Promise.resolve();
// });
// testUtils.insertAuthorUser()
// .then(function () {
// return Models.User.findAll();
// })
// .then(function (foundUser) {
// testUser = foundUser.models[1];
// return permissions.canThis({user: testUser.id}).edit.post(123);
// })
// .then(function () {
// permissibleStub.restore();
// permissibleStub.calledWith(123, { user: testUser.id, app: null, internal: false })
// .should.equal(true);
// done();
// })
// .catch(function () {
// permissibleStub.restore();
// done(new Error('did not allow testUser'));
// });
// });
// it('can use permissible function on Model to forbid something', function (done) {
// var testUser,
// permissibleStub = sandbox.stub(Models.Post, 'permissible', function () {
// return Promise.reject();
// });
// testUtils.insertAuthorUser()
// .then(function () {
// return Models.User.findAll();
// })
// .then(function (foundUser) {
// testUser = foundUser.models[1];
// return permissions.canThis({user: testUser.id}).edit.post(123);
// })
// .then(function () {
// permissibleStub.restore();
// done(new Error('Allowed testUser to edit post'));
// })
// .catch(function () {
// permissibleStub.calledWith(123, { user: testUser.id, app: null, internal: false })
// .should.equal(true);
// permissibleStub.restore();
// done();
// });
// });
// it('can get effective user permissions', function (done) {
// effectivePerms.user(1).then(function (effectivePermissions) {
// should.exist(effectivePermissions);
// effectivePermissions.length.should.be.above(0);
// done();
// }).catch(done);
// });
// it('can check an apps effective permissions', function (done) {
// effectivePerms.app('Kudos')
// .then(function (effectivePermissions) {
// should.exist(effectivePermissions);
// effectivePermissions.length.should.be.above(0);
// done();
// })
// .catch(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
// Models.Post.edit({'author_id': 2}, _.extend(context, {id: 1}))
// .then(function (updatedPost) {
// // Add user permissions
// return Models.User.findOne({id: 1})
// .then(function (foundUser) {
// var newPerm = new Models.Permission({
// name: 'app test edit post',
// action_type: 'edit',
// object_type: 'post'
// });
// return newPerm.save(null, context).then(function () {
// return foundUser.permissions().attach(newPerm).then(function () {
// return Promise.all([updatedPost, foundUser]);
// });
// });
// });
// })
// .then(function (results) {
// var updatedPost = results[0],
// updatedUser = results[1];
// return permissions.canThis({ user: updatedUser.id })
// .edit
// .post(updatedPost.id)
// .then(function () {
// return results;
// })
// .catch(function (err) {
// /*jshint unused:false */
// done(new Error('Did not allow user 1 to edit post 1'));
// });
// })
// .then(function (results) {
// var updatedPost = results[0],
// updatedUser = results[1];
// // Confirm app cannot edit it.
// return permissions.canThis({ app: 'Hemingway', user: updatedUser.id })
// .edit
// .post(updatedPost.id)
// .then(function () {
// done(new Error('Allowed an edit of post 1'));
// }).catch(done);
// }).catch(done);
// });
// it('allows an app to edit a post with permission', function (done) {
// permissions.canThis({ app: 'Kudos', user: 1 })
// .edit
// .post(1)
// .then(function () {
// done();
// })
// .catch(function () {
// done(new Error('Did not allow an edit of post 1'));
// });
// });
// it('checks for null context passed and rejects', function (done) {
// permissions.canThis(undefined)
// .edit
// .post(1)
// .then(function () {
// done(new Error('Should not allow editing post'));
// })
// .catch(done);
// });
// it('allows \'internal\' to be passed for internal requests', function (done) {
// // Using tag here because post implements the custom permissible interface
// permissions.canThis('internal')
// .edit
// .tag(1)
// .then(function () {
// done();
// })
// .catch(function () {
// done(new Error('Should allow editing post with "internal"'));
// });
// });
// it('allows { internal: true } to be passed for internal requests', function (done) {
// // Using tag here because post implements the custom permissible interface
// permissions.canThis({internal: true})
// .edit
// .tag(1)
// .then(function () {
// done();
// })
// .catch(function () {
// 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);
});
// Currently failing - fixing this causes other issues
// it('should not create italic words between lines', function () {
// var testPhrase = {input: 'foo_bar\nbar_foo', output: /^<p>foo_bar <br \/>\nbar_foo<\/p>$/},
// processedMarkup = converter.makeHtml(testPhrase.input);
//
// processedMarkup.should.match(testPhrase.output);
// });
// Currently failing - fixing this causes other issues
// it('should not create italic words between lines', function () {
// var testPhrase = {input: 'foo_bar\nbar_foo', output: /^<p>foo_bar <br \/>\nbar_foo<\/p>$/},
// processedMarkup = converter.makeHtml(testPhrase.input);
// processedMarkup.should.match(testPhrase.output);
// });
it('should not touch underscores in code blocks', function () {
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 () {
var testPhrase = {
input: '```javascript\n' +
'var foo = "bar";\n' +
'if (foo === "bar") {\n' +
' return true;\n' +
'} else if (foo === "baz") {\n' +
' return "magic happened";\n' +
'}\n' +
'```',
output: /^<mark><\/mark>$/
input: '```javascript\n' +
'var foo = "bar";\n' +
'if (foo === "bar") {\n' +
' return true;\n' +
'} else if (foo === "baz") {\n' +
' return "magic happened";\n' +
'}\n' +
'```',
output: /^<mark><\/mark>$/
},
processedMarkup = converter.makeHtml(testPhrase.input);
@ -617,17 +617,17 @@ describe('Showdown client side converter', function () {
});
});
// Waiting for showdown typography to be updated
// it('should correctly convert quotes to curly quotes', function () {
// var testPhrases = [
// {
// input: 'Hello world\nIt's a fine day\nout',
// output: /^<p>Hello world <br \/>\nIts a fine day <br \/>\nout<\/p>$/}
// ];
//
// testPhrases.forEach(function (testPhrase) {
// processedMarkup = converter.makeHtml(testPhrase.input);
// processedMarkup.should.match(testPhrase.output);
// });
// })
// Waiting for showdown typography to be updated
// it('should correctly convert quotes to curly quotes', function () {
// var testPhrases = [
// {
// input: 'Hello world\nIt's a fine day\nout',
// output: /^<p>Hello world <br \/>\nIts a fine day <br \/>\nout<\/p>$/}
// ];
// testPhrases.forEach(function (testPhrase) {
// processedMarkup = converter.makeHtml(testPhrase.input);
// processedMarkup.should.match(testPhrase.output);
// });
// });
});

View File

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