mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added support for filtering Members CSV exports
no-issue Adding these options to the endpoint will pass them to the model layer, allowing us to filter members CSV exports
This commit is contained in:
parent
800ffc2e8f
commit
171908cefa
2 changed files with 23 additions and 1 deletions
|
@ -399,7 +399,10 @@ module.exports = {
|
||||||
|
|
||||||
exportCSV: {
|
exportCSV: {
|
||||||
options: [
|
options: [
|
||||||
'limit'
|
'limit',
|
||||||
|
'filter',
|
||||||
|
'search',
|
||||||
|
'paid'
|
||||||
],
|
],
|
||||||
headers: {
|
headers: {
|
||||||
disposition: {
|
disposition: {
|
||||||
|
|
|
@ -346,6 +346,25 @@ describe('Members API', function () {
|
||||||
should.exist(csv.data.find(row => row.email === 'member2@test.com'));
|
should.exist(csv.data.find(row => row.email === 'member2@test.com'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can export a filtered CSV', async function () {
|
||||||
|
const res = await request
|
||||||
|
.get(localUtils.API.getApiQuery(`members/upload/?search=Egg`))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /text\/csv/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
should.not.exist(res.headers['x-cache-invalidate']);
|
||||||
|
res.headers['content-disposition'].should.match(/Attachment;\sfilename="members/);
|
||||||
|
res.text.should.match(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at/);
|
||||||
|
|
||||||
|
const csv = Papa.parse(res.text, {header: true});
|
||||||
|
should.exist(csv.data.find(row => row.name === 'Mr Egg'));
|
||||||
|
should.not.exist(csv.data.find(row => row.name === 'Egon Spengler'));
|
||||||
|
should.not.exist(csv.data.find(row => row.name === 'Ray Stantz'));
|
||||||
|
should.not.exist(csv.data.find(row => row.email === 'member2@test.com'));
|
||||||
|
});
|
||||||
|
|
||||||
it('Can import CSV', function () {
|
it('Can import CSV', function () {
|
||||||
return request
|
return request
|
||||||
.post(localUtils.API.getApiQuery(`members/upload/`))
|
.post(localUtils.API.getApiQuery(`members/upload/`))
|
||||||
|
|
Loading…
Add table
Reference in a new issue