0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Changed test assertion of one test in integeration/api/api_users_spec

no issue

- admin2 was never in the database
- the model layer has thrown a 404
This commit is contained in:
kirrg001 2018-10-06 01:11:15 +02:00
parent 5e838cf3db
commit d3b1f582ab
6 changed files with 43 additions and 32 deletions

View file

@ -462,7 +462,7 @@ describe('Public API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.users);
testUtils.API.checkResponse(jsonResponse, 'users');
jsonResponse.users.should.have.length(6);
jsonResponse.users.should.have.length(7);
// We don't expose the email address.
testUtils.API.checkResponse(jsonResponse.users[0], 'user', null, null, null, {public: true});
@ -485,7 +485,7 @@ describe('Public API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.users);
testUtils.API.checkResponse(jsonResponse, 'users');
jsonResponse.users.should.have.length(6);
jsonResponse.users.should.have.length(7);
// We don't expose the email address.
testUtils.API.checkResponse(jsonResponse.users[0], 'user', null, null, null, {public: true});
@ -635,7 +635,7 @@ describe('Public API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.users);
testUtils.API.checkResponse(jsonResponse, 'users');
jsonResponse.users.should.have.length(6);
jsonResponse.users.should.have.length(7);
// We don't expose the email address.
testUtils.API.checkResponse(jsonResponse.users[0], 'user', ['count'], null, null, {public: true});
@ -658,7 +658,7 @@ describe('Public API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.users);
testUtils.API.checkResponse(jsonResponse, 'users');
jsonResponse.users.should.have.length(6);
jsonResponse.users.should.have.length(7);
// We don't expose the email address.
testUtils.API.checkResponse(jsonResponse.users[0], 'user', null, null, null, {public: true});

View file

@ -67,49 +67,49 @@ describe('Users API', function () {
it('Owner can browse', function (done) {
UserAPI.browse(context.owner).then(function (response) {
checkBrowseResponse(response, 9);
checkBrowseResponse(response, 10);
done();
}).catch(done);
});
it('Admin can browse', function (done) {
UserAPI.browse(context.admin).then(function (response) {
checkBrowseResponse(response, 9);
checkBrowseResponse(response, 10);
done();
}).catch(done);
});
it('Editor can browse', function (done) {
UserAPI.browse(context.editor).then(function (response) {
checkBrowseResponse(response, 9);
checkBrowseResponse(response, 10);
done();
}).catch(done);
});
it('Author can browse active', function (done) {
UserAPI.browse(context.author).then(function (response) {
checkBrowseResponse(response, 9);
checkBrowseResponse(response, 10);
done();
}).catch(done);
});
it('Contributor can browse active', function (done) {
UserAPI.browse(context.contributor).then(function (response) {
checkBrowseResponse(response, 9);
checkBrowseResponse(response, 10);
done();
}).catch(done);
});
it('No-auth CAN browse, but only gets filtered active users', function (done) {
UserAPI.browse().then(function (response) {
checkBrowseResponse(response, 9, null, null, null, {public: true});
checkBrowseResponse(response, 10, null, null, null, {public: true});
done();
}).catch(done);
});
it('Can browse all', function (done) {
UserAPI.browse(_.extend({}, testUtils.context.admin, {status: 'all'})).then(function (response) {
checkBrowseResponse(response, 9);
checkBrowseResponse(response, 10);
done();
}).catch(done);
});
@ -122,7 +122,7 @@ describe('Users API', function () {
should.exist(response);
testUtils.API.checkResponse(response, 'users');
should.exist(response.users);
response.users.should.have.length(9);
response.users.should.have.length(10);
testUtils.API.checkResponse(response.users[0], 'user', 'roles');
testUtils.API.checkResponse(response.users[1], 'user', 'roles');
testUtils.API.checkResponse(response.users[2], 'user', 'roles');
@ -182,7 +182,7 @@ describe('Users API', function () {
should.exist(response);
testUtils.API.checkResponse(response, 'users');
should.exist(response.users);
response.users.should.have.length(9);
response.users.should.have.length(10);
response.users.map((user) => {
testUtils.API.checkResponse(user, 'user', 'count');
@ -201,7 +201,7 @@ describe('Users API', function () {
response.meta.pagination.should.have.property('page', 1);
response.meta.pagination.should.have.property('limit', 15);
response.meta.pagination.should.have.property('pages', 1);
response.meta.pagination.should.have.property('total', 9);
response.meta.pagination.should.have.property('total', 10);
response.meta.pagination.should.have.property('next', null);
response.meta.pagination.should.have.property('prev', null);
@ -602,7 +602,7 @@ describe('Users API', function () {
});
});
it('[failure] can\'t change status to inactive for admin', function () {
it('[success] can change status to inactive for admin', function () {
return UserAPI.edit(
{
users: [
@ -611,11 +611,7 @@ describe('Users API', function () {
}
]
}, _.extend({}, context.admin, {id: userIdFor.admin2})
).then(function () {
throw new Error('this is not allowed');
}).catch(function (err) {
(err instanceof common.errors.NoPermissionError).should.eql(true);
});
);
});
it('[failure] can\' change my own status to inactive', function () {
@ -919,7 +915,7 @@ describe('Users API', function () {
return db.knex('users');
}).then(function (result) {
_.flatten(result).length.should.eql(9);
_.flatten(result).length.should.eql(10);
return UserAPI.destroy(_.extend({}, context.owner, _.merge({}, options, {id: userIdFor.editor})));
}).then(function () {
@ -967,8 +963,8 @@ describe('Users API', function () {
return db.knex('users');
}).then(function (allUsers) {
// one user was deleted, that's why 8
allUsers.length.should.eql(8);
// one user was deleted, that's why 9
allUsers.length.should.eql(9);
done();
}).catch(done);
});

View file

@ -1705,11 +1705,11 @@ describe('Post Model', function () {
return models.Post.destroyByAuthor(authorData);
}).then(function (results) {
// User 1 has 10 posts in the database
results.length.should.equal(10);
results.length.should.equal(9);
return models.Post.findAll({context: {internal: true}});
}).then(function (found) {
// Only 40 should remain
found.length.should.equal(40);
found.length.should.equal(41);
done();
}).catch(done);
});

View file

@ -201,7 +201,7 @@ describe('User Model', function run() {
it('can findAll', function (done) {
UserModel.findAll().then(function (results) {
should.exist(results);
results.length.should.equal(5);
results.length.should.equal(6);
done();
}).catch(done);
@ -214,7 +214,7 @@ describe('User Model', function run() {
results.meta.pagination.page.should.equal(1);
results.meta.pagination.limit.should.equal(15);
results.meta.pagination.pages.should.equal(1);
results.data.length.should.equal(5);
results.data.length.should.equal(6);
done();
}).catch(done);
@ -260,7 +260,7 @@ describe('User Model', function run() {
results.meta.pagination.page.should.equal(1);
results.meta.pagination.limit.should.equal('all');
results.meta.pagination.pages.should.equal(1);
results.data.length.should.equal(9);
results.data.length.should.equal(10);
});
});

View file

@ -148,7 +148,7 @@ describe('Integration: services/url/UrlService', function () {
}
if (generator.router.getResourceType() === 'users') {
generator.getUrls().length.should.eql(5);
generator.getUrls().length.should.eql(6);
}
});
@ -190,6 +190,9 @@ describe('Integration: services/url/UrlService', function () {
url = urlService.getUrlByResourceId(testUtils.DataGenerator.forKnex.users[4].id);
url.should.eql('/author/contributor/');
url = urlService.getUrlByResourceId(testUtils.DataGenerator.forKnex.users[5].id);
url.should.eql('/author/ad-2/');
});
it('getResource', function () {
@ -452,7 +455,7 @@ describe('Integration: services/url/UrlService', function () {
}
if (generator.router.getResourceType() === 'users') {
generator.getUrls().length.should.eql(5);
generator.getUrls().length.should.eql(6);
}
});
@ -495,6 +498,9 @@ describe('Integration: services/url/UrlService', function () {
url = urlService.getUrlByResourceId(testUtils.DataGenerator.forKnex.users[4].id);
url.should.eql('/persons/contributor/');
url = urlService.getUrlByResourceId(testUtils.DataGenerator.forKnex.users[5].id);
url.should.eql('/persons/ad-2/');
});
describe('update resource', function () {
@ -692,7 +698,7 @@ describe('Integration: services/url/UrlService', function () {
}
if (generator.router.getResourceType() === 'users') {
generator.getUrls().length.should.eql(5);
generator.getUrls().length.should.eql(6);
}
});
@ -735,6 +741,9 @@ describe('Integration: services/url/UrlService', function () {
url = urlService.getUrlByResourceId(testUtils.DataGenerator.forKnex.users[4].id);
url.should.eql('/persons/contributor/');
url = urlService.getUrlByResourceId(testUtils.DataGenerator.forKnex.users[5].id);
url.should.eql('/persons/ad-2/');
});
});
});

View file

@ -702,7 +702,8 @@ DataGenerator.forKnex = (function () {
createUser(DataGenerator.Content.users[1]),
createUser(DataGenerator.Content.users[2]),
createUser(DataGenerator.Content.users[3]),
createUser(DataGenerator.Content.users[7])
createUser(DataGenerator.Content.users[7]),
createUser(DataGenerator.Content.users[6]),
];
const clients = [
@ -737,6 +738,11 @@ DataGenerator.forKnex = (function () {
id: ObjectId.generate(),
user_id: DataGenerator.Content.users[7].id,
role_id: DataGenerator.Content.roles[4].id
},
{
id: ObjectId.generate(),
user_id: DataGenerator.Content.users[6].id,
role_id: DataGenerator.Content.roles[0].id
}
];