🐛 Fixed pagination/duplicate posts and users appearing in admin area (#10031)

closes #10029

- allowed page option for users, posts, & tags browse 
  - The page query param was not forwarding to the query, meaning that when the admin client requested the next page of users or posts, it would receive the first page again.
This commit is contained in:
Fabien O'Carroll 2018-10-18 16:05:51 +07:00 committed by Kevin Ansfield
parent ae71f2deca
commit e865d2218c
6 changed files with 49 additions and 0 deletions

View File

@ -15,6 +15,7 @@ module.exports = {
'status',
'limit',
'order',
'page',
'debug'
],
validation: {

View File

@ -13,6 +13,7 @@ module.exports = {
'fields',
'limit',
'order',
'page',
'debug'
],
validation: {

View File

@ -16,6 +16,7 @@ module.exports = {
'limit',
'status',
'order',
'page',
'debug'
],
validation: {

View File

@ -206,6 +206,23 @@ describe('Posts API V2', function () {
done();
});
});
it('supports usage of the page param', function (done) {
request.get(localUtils.API.getApiQuery('posts/?page=2'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200)
.end(function (err, res) {
if (err) {
return done(err);
}
const jsonResponse = res.body;
should.equal(jsonResponse.meta.pagination.page, 2);
done();
});
});
});
describe('read', function () {

View File

@ -51,6 +51,18 @@ describe('Tag API V2', function () {
});
});
it('browse accepts the page parameter', function () {
return request
.get(localUtils.API.getApiQuery('tags/?page=2'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200)
.then((res) => {
should.equal(res.body.meta.pagination.page, 2);
});
});
it('read', function () {
return request
.get(localUtils.API.getApiQuery(`tags/${testUtils.existingData.tags[0].id}/?include=count.posts`))

View File

@ -113,6 +113,23 @@ describe('User API V2', function () {
done();
});
});
it('supports usage of the page param', function (done) {
request.get(localUtils.API.getApiQuery('users/?page=2'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200)
.end(function (err, res) {
if (err) {
return done(err);
}
const jsonResponse = res.body;
should.equal(jsonResponse.meta.pagination.page, 2);
done();
});
});
});
describe('Read', function () {