Updated regression tests for subscribers removal

This commit is contained in:
Kevin Ansfield 2019-10-09 16:26:14 +01:00
parent 3fd328de88
commit 57e9bd5aae
3 changed files with 55 additions and 183 deletions

View File

@ -1,110 +0,0 @@
var supertest = require('supertest'),
should = require('should'),
sinon = require('sinon'),
testUtils = require('../../../utils'),
labs = require('../../../../server/services/labs'),
config = require('../../../../server/config'),
ghost = testUtils.startGhost;
describe('Subscriber: Routing', function () {
var request;
before(function () {
return ghost()
.then(function () {
request = supertest.agent(config.get('url'));
});
});
before(function () {
sinon.stub(labs, 'isSet').callsFake(function (key) {
if (key === 'subscribers') {
return true;
}
});
});
after(function () {
sinon.restore();
});
describe('GET', function () {
it('[success]', function (done) {
request.get('/subscribe/')
.expect(200)
.end(function (err, res) {
should.not.exist(err);
done();
});
});
});
describe('POST', function () {
it('[success]', function (done) {
request.post('/subscribe/')
.set('Content-type', 'application/x-www-form-urlencoded')
.send({
email: 'test@ghost.org',
location: 'http://localhost:2368',
confirm: ''
})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
res.text.should.containEql('Subscribed!');
res.text.should.containEql('test@ghost.org');
done();
});
});
it('[error] email is invalid', function (done) {
request.post('/subscribe/')
.set('Content-type', 'application/x-www-form-urlencoded')
.send({
email: 'alphabetazeta',
location: 'http://localhost:2368',
confirm: ''
})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
res.text.should.containEql('http://localhost:2368');
res.text.should.not.containEql('Subscribed!');
res.text.should.not.containEql('alphabetazeta');
done();
});
});
it('[error] location is not defined', function (done) {
request.post('/subscribe/')
.set('Content-type', 'application/x-www-form-urlencoded')
.send({
email: 'test@ghost.org',
confirm: ''
})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
res.text.should.not.containEql('Subscribed!');
res.text.should.not.containEql('test@ghost.org');
done();
});
});
it('[error] confirm is not defined', function (done) {
request.post('/subscribe/')
.set('Content-type', 'application/x-www-form-urlencoded')
.send({
email: 'test@ghost.org',
location: 'http://localhost:2368'
})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
res.text.should.not.containEql('Subscribed!');
res.text.should.not.containEql('test@ghost.org');
done();
});
});
});
});

View File

@ -381,9 +381,6 @@ describe('Integration: Importer', function () {
it('ensure complex JSON get\'s fully imported', function () {
const exportData = exportedLatestBody().db[0];
exportData.data.subscribers[0] = testUtils.DataGenerator.forKnex.createSubscriber({email: 'subscriber1@ghost.org'});
exportData.data.subscribers[1] = testUtils.DataGenerator.forKnex.createSubscriber({email: 'subscriber2@ghost.org'});
return dataImporter.doImport(exportData, importOptions)
.then(function () {
// Grab the data from tables
@ -391,25 +388,22 @@ describe('Integration: Importer', function () {
knex('users').select(),
models.Post.findPage(testUtils.context.internal),
knex('settings').select(),
knex('tags').select(),
knex('subscribers').select()
knex('tags').select()
]);
})
.then(function (importedData) {
should.exist(importedData);
importedData.length.should.equal(5, 'Did not get data successfully');
importedData.length.should.equal(4, 'Did not get data successfully');
const users = importedData[0],
posts = importedData[1].data,
settings = importedData[2],
tags = importedData[3],
subscribers = importedData[4];
tags = importedData[3];
// we always have 1 user, the owner user we added
users.length.should.equal(1, 'There should only be one user');
subscribers.length.should.equal(2, 'There should be two subscribers');
settings.length.should.be.above(0, 'Wrong number of settings');
posts.length.should.equal(exportData.data.posts.length, 'no new posts');
tags.length.should.equal(exportData.data.tags.length, 'no new tags');

View File

@ -121,86 +121,74 @@ describe('Database Migration (special functions)', function () {
permissions[33].name.should.eql('Browse roles');
permissions[33].should.be.AssignedToRoles(['Administrator', 'Editor', 'Author', 'Contributor', 'Admin Integration']);
// Subscribers
permissions[34].name.should.eql('Browse subscribers');
permissions[34].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[35].name.should.eql('Read subscribers');
permissions[35].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[36].name.should.eql('Edit subscribers');
permissions[36].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[37].name.should.eql('Add subscribers');
permissions[37].should.be.AssignedToRoles(['Administrator', 'Editor', 'Author', 'Contributor', 'Admin Integration']);
permissions[38].name.should.eql('Delete subscribers');
permissions[38].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
// Invites
permissions[39].name.should.eql('Browse invites');
permissions[39].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[40].name.should.eql('Read invites');
permissions[40].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[41].name.should.eql('Edit invites');
permissions[41].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[42].name.should.eql('Add invites');
permissions[42].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[43].name.should.eql('Delete invites');
permissions[43].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[34].name.should.eql('Browse invites');
permissions[34].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[35].name.should.eql('Read invites');
permissions[35].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[36].name.should.eql('Edit invites');
permissions[36].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[37].name.should.eql('Add invites');
permissions[37].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
permissions[38].name.should.eql('Delete invites');
permissions[38].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration']);
// Redirects
permissions[44].name.should.eql('Download redirects');
permissions[44].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[45].name.should.eql('Upload redirects');
permissions[45].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[39].name.should.eql('Download redirects');
permissions[39].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[40].name.should.eql('Upload redirects');
permissions[40].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
// Webhooks
permissions[46].name.should.eql('Add webhooks');
permissions[46].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[47].name.should.eql('Edit webhooks');
permissions[47].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[48].name.should.eql('Delete webhooks');
permissions[48].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[41].name.should.eql('Add webhooks');
permissions[41].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[42].name.should.eql('Edit webhooks');
permissions[42].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[43].name.should.eql('Delete webhooks');
permissions[43].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
// Integrations
permissions[49].name.should.eql('Browse integrations');
permissions[49].should.be.AssignedToRoles(['Administrator']);
permissions[50].name.should.eql('Read integrations');
permissions[50].should.be.AssignedToRoles(['Administrator']);
permissions[51].name.should.eql('Edit integrations');
permissions[51].should.be.AssignedToRoles(['Administrator']);
permissions[52].name.should.eql('Add integrations');
permissions[52].should.be.AssignedToRoles(['Administrator']);
permissions[53].name.should.eql('Delete integrations');
permissions[53].should.be.AssignedToRoles(['Administrator']);
permissions[44].name.should.eql('Browse integrations');
permissions[44].should.be.AssignedToRoles(['Administrator']);
permissions[45].name.should.eql('Read integrations');
permissions[45].should.be.AssignedToRoles(['Administrator']);
permissions[46].name.should.eql('Edit integrations');
permissions[46].should.be.AssignedToRoles(['Administrator']);
permissions[47].name.should.eql('Add integrations');
permissions[47].should.be.AssignedToRoles(['Administrator']);
permissions[48].name.should.eql('Delete integrations');
permissions[48].should.be.AssignedToRoles(['Administrator']);
// API Keys
permissions[54].name.should.eql('Browse API keys');
permissions[54].should.be.AssignedToRoles(['Administrator']);
permissions[55].name.should.eql('Read API keys');
permissions[55].should.be.AssignedToRoles(['Administrator']);
permissions[56].name.should.eql('Edit API keys');
permissions[56].should.be.AssignedToRoles(['Administrator']);
permissions[57].name.should.eql('Add API keys');
permissions[57].should.be.AssignedToRoles(['Administrator']);
permissions[58].name.should.eql('Delete API keys');
permissions[58].should.be.AssignedToRoles(['Administrator']);
permissions[49].name.should.eql('Browse API keys');
permissions[49].should.be.AssignedToRoles(['Administrator']);
permissions[50].name.should.eql('Read API keys');
permissions[50].should.be.AssignedToRoles(['Administrator']);
permissions[51].name.should.eql('Edit API keys');
permissions[51].should.be.AssignedToRoles(['Administrator']);
permissions[52].name.should.eql('Add API keys');
permissions[52].should.be.AssignedToRoles(['Administrator']);
permissions[53].name.should.eql('Delete API keys');
permissions[53].should.be.AssignedToRoles(['Administrator']);
// Actions
permissions[59].name.should.eql('Browse Actions');
permissions[59].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
permissions[54].name.should.eql('Browse Actions');
permissions[54].should.be.AssignedToRoles(['Administrator', 'Admin Integration']);
// Members
permissions[60].name.should.eql('Browse Members');
permissions[61].name.should.eql('Read Members');
permissions[62].name.should.eql('Edit Members');
permissions[63].name.should.eql('Add Members');
permissions[64].name.should.eql('Delete Members');
permissions[55].name.should.eql('Browse Members');
permissions[56].name.should.eql('Read Members');
permissions[57].name.should.eql('Edit Members');
permissions[58].name.should.eql('Add Members');
permissions[59].name.should.eql('Delete Members');
// Posts
permissions[65].name.should.eql('Publish posts');
permissions[65].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration', 'Scheduler Integration']);
permissions[60].name.should.eql('Publish posts');
permissions[60].should.be.AssignedToRoles(['Administrator', 'Editor', 'Admin Integration', 'Scheduler Integration']);
// DB
permissions[66].name.should.eql('Backup database');
permissions[66].should.be.AssignedToRoles(['Administrator', 'DB Backup Integration']);
permissions[61].name.should.eql('Backup database');
permissions[61].should.be.AssignedToRoles(['Administrator', 'DB Backup Integration']);
});
describe('Populate', function () {
@ -258,7 +246,7 @@ describe('Database Migration (special functions)', function () {
result.roles.at(7).get('name').should.eql('Scheduler Integration');
// Permissions
result.permissions.length.should.eql(67);
result.permissions.length.should.eql(62);
result.permissions.toJSON().should.be.CompletePermissions();
});
});