Merge pull request #702 from sharelatex/ta-rename-remove-endpoint

Rename Affiliation Removal Endpoint
This commit is contained in:
Timothée Alby 2018-06-28 13:48:45 +02:00 committed by GitHub
commit e0f6afcbb4
2 changed files with 7 additions and 6 deletions

View file

@ -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

View file

@ -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)->