diff --git a/imports/api/Rest/Rest.js b/imports/api/Rest/Rest.js index 8be33e5..a5296ae 100644 --- a/imports/api/Rest/Rest.js +++ b/imports/api/Rest/Rest.js @@ -317,13 +317,16 @@ if (!Meteor.settings.private.internalApiToken) { return fail(e); } return jsend.success({ subsId: result._str }); - }, + } + }); + + apiV1.addRoute('mobile/subscriptions/:token/:mobileToken/:subsId', { authRequired: false }, { delete: function del() { const { token, mobileToken, subsId - } = this.bodyParams; + } = this.urlParams; try { check(token, String); check(mobileToken, String); diff --git a/test/rest.test.js b/test/rest.test.js index 52c7997..d365ab2 100644 --- a/test/rest.test.js +++ b/test/rest.test.js @@ -140,7 +140,6 @@ describe('basic api v1 returns', () => { }); }); - function addSubs(done) { // this are removed in the test database but we are testing in dev/ci database // Remove previous subs of this user @@ -199,6 +198,7 @@ describe('basic api v1 returns', () => { chai.expect(jsendResult.status).equal('success'); chai.expect(typeof jsendResult.data.subscriptions).to.equal('object'); chai.expect(typeof jsendResult.data.count).to.equal('number'); + if (jsendResult.data.count !== 1) console.log(result); chai.expect(jsendResult.data.count).to.equal(1); // console.log(JSON.stringify(jsendResult.data.subscriptions)); done(); @@ -209,12 +209,7 @@ describe('basic api v1 returns', () => { it('should remove mobile user subscriptions', async (done) => { // this are removed in the test database but we are testing in dev/ci database - HTTP.del(url('api/v1/mobile/subscriptions'), { - data: { - token, - mobileToken, - subsId: returnedSubsId - } + HTTP.del(url(`api/v1/mobile/subscriptions/${token}/${mobileToken}/${returnedSubsId}`), { }, (error, result) => { chai.expect(error, null); if (result.statusCode !== 200) console.log(result); @@ -235,20 +230,15 @@ describe('basic api v1 returns', () => { chai.expect(jsendResult.status).equal('success'); chai.expect(typeof jsendResult.data.subscriptions).to.equal('object'); chai.expect(typeof jsendResult.data.count).to.equal('number'); + if (jsendResult.data.count !== 0) console.log(result); chai.expect(jsendResult.data.count).to.equal(0); // console.log(JSON.stringify(jsendResult.data.subscriptions)); done(); }); }); - it('should not remove mobile user subscriptions with wrong token', async (done) => { - HTTP.del(url('api/v1/mobile/subscriptions'), { - data: { - token: 'wrongOne', - mobileToken, - subsId: returnedSubsId - } + HTTP.del(url(`api/v1/mobile/subscriptions/wrongOne/${mobileToken}/${returnedSubsId}`), { }, (error, result) => { chai.expect(error, null); if (result.statusCode !== 401) console.log(result); @@ -278,6 +268,7 @@ describe('basic api v1 returns', () => { chai.expect(jsendResult.status).equal('success'); chai.expect(typeof jsendResult.data.subscriptions).to.equal('object'); chai.expect(typeof jsendResult.data.count).to.equal('number'); + if (jsendResult.data.count !== 0) console.log(result); chai.expect(jsendResult.data.count).to.equal(0); done(); });