mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 13:21:37 +02:00
call v1 affiliation deletion endpoint with POST instead of DELETE
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)->
|
||||
|
||||
Reference in New Issue
Block a user