Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
fix(purge): API expect the request to contain a body
Browse files Browse the repository at this point in the history
  • Loading branch information
vitobeto authored and terinjokes committed Jun 28, 2016
1 parent fe45f16 commit f7f3f02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/purge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function remove(z, query, options) {

options = options || {};
options.method = 'DELETE';
options.query = query;
options.body = JSON.stringify(query);

return this._got(uri, options).then(function (response) {
return response.body.success;
Expand Down
24 changes: 16 additions & 8 deletions test/purge.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ test.beforeEach(t => {

test('purge everything by id', async t => {
nock('https://api.cloudflare.com')
.delete('/client/v4/zones/1/purge_cache')
.query({purge_everything: 'true'}) // eslint-disable-line camelcase
.delete('/client/v4/zones/1/purge_cache', {
purge_everything: true // eslint-disable-line camelcase
})
.reply(200, {
success: true
});
Expand All @@ -28,8 +29,9 @@ test('purge everything by id', async t => {
test('purge everything by Zone', async t => {
const z = Zone.create({id: 1});
nock('https://api.cloudflare.com')
.delete('/client/v4/zones/1/purge_cache')
.query({purge_everything: 'true'}) // eslint-disable-line camelcase
.delete('/client/v4/zones/1/purge_cache', {
purge_everything: true // eslint-disable-line camelcase
})
.reply(200, {
success: true
});
Expand All @@ -41,8 +43,11 @@ test('purge everything by Zone', async t => {

test('purge URL by id', async t => {
nock('https://api.cloudflare.com')
.delete('/client/v4/zones/1/purge_cache')
.query({files: 'https://example.com/purge_url'}) // eslint-disable-line camelcase
.delete('/client/v4/zones/1/purge_cache', {
files: [
'https://example.com/purge_url'
]
})
.reply(200, {
success: true
});
Expand All @@ -57,8 +62,11 @@ test('purge URL by id', async t => {
test('purge URL by Zone', async t => {
const z = Zone.create({id: 1});
nock('https://api.cloudflare.com')
.delete('/client/v4/zones/1/purge_cache')
.query({files: 'https://example.com/purge_url'}) // eslint-disable-line camelcase
.delete('/client/v4/zones/1/purge_cache', {
files: [
'https://example.com/purge_url'
]
})
.reply(200, {
success: true
});
Expand Down

0 comments on commit f7f3f02

Please sign in to comment.