From fe0fdd11bf80840ba50829e791d2b810e29e43d3 Mon Sep 17 00:00:00 2001 From: Tim Alby Date: Wed, 27 Jun 2018 09:33:06 +0200 Subject: [PATCH] call v1 affiliation deletion endpoint with POST instead of DELETE --- .../coffee/Features/User/UserAffiliationsManager.coffee | 6 +++--- .../unit/coffee/User/UserAffiliationsManagerTests.coffee | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/services/web/app/coffee/Features/User/UserAffiliationsManager.coffee b/services/web/app/coffee/Features/User/UserAffiliationsManager.coffee index 95c74eab39..68da2f7cba 100644 --- a/services/web/app/coffee/Features/User/UserAffiliationsManager.coffee +++ b/services/web/app/coffee/Features/User/UserAffiliationsManager.coffee @@ -22,10 +22,10 @@ module.exports = UserAffiliationsManager = removeAffiliation: (userId, email, callback = (error) ->) -> - email = encodeURIComponent(email) makeAffiliationRequest { - method: 'DELETE' - path: "/api/v2/users/#{userId.toString()}/affiliations/#{email}" + method: 'POST' + path: "/api/v2/users/#{userId.toString()}/affiliations/remove" + body: { email } extraSuccessStatusCodes: [404] # `Not Found` responses are considered successful defaultErrorMessage: "Couldn't remove affiliation" }, callback diff --git a/services/web/test/unit/coffee/User/UserAffiliationsManagerTests.coffee b/services/web/test/unit/coffee/User/UserAffiliationsManagerTests.coffee index d463983cfd..dfcd864c09 100644 --- a/services/web/test/unit/coffee/User/UserAffiliationsManagerTests.coffee +++ b/services/web/test/unit/coffee/User/UserAffiliationsManagerTests.coffee @@ -1,4 +1,5 @@ should = require('chai').should() +expect = require('chai').expect SandboxedModule = require('sandboxed-module') assert = require('assert') path = require('path') @@ -91,10 +92,10 @@ describe "UserAffiliationsManager", -> should.not.exist(err) @request.calledOnce.should.equal true requestOptions = @request.lastCall.args[0] - expectedUrl = "v1.url/api/v2/users/#{@stubbedUser._id}/affiliations/" - expectedUrl += encodeURIComponent(@newEmail) + expectedUrl = "v1.url/api/v2/users/#{@stubbedUser._id}/affiliations/remove" requestOptions.url.should.equal expectedUrl - requestOptions.method.should.equal 'DELETE' + requestOptions.method.should.equal 'POST' + expect(requestOptions.body).to.deep.equal { email: @newEmail } done() it 'handle error', (done)->