From e41391fb4a46a4b53957c985806314275cd0d230 Mon Sep 17 00:00:00 2001 From: Tim Alby Date: Thu, 21 Jun 2018 13:31:55 +0200 Subject: [PATCH] ignore affiliations if v1 is not configured --- services/web/app/coffee/Features/User/UserUpdater.coffee | 3 ++- services/web/test/unit/coffee/User/UserUpdaterTests.coffee | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/services/web/app/coffee/Features/User/UserUpdater.coffee b/services/web/app/coffee/Features/User/UserUpdater.coffee index c73bef7b73..eb983cb76b 100644 --- a/services/web/app/coffee/Features/User/UserUpdater.coffee +++ b/services/web/app/coffee/Features/User/UserUpdater.coffee @@ -132,7 +132,8 @@ removeAffiliation = (userId, email, callback = (error) ->) -> defaultErrorMessage: "Couldn't remove affiliation" }, callback -makeAffiliationRequest = (requestOptions, callback = (error) ->) -> +makeAffiliationRequest = (requestOptions, callback = (error) ->) -> + return callback(null) unless settings?.apis?.v1?.url # service is not configured requestOptions.extraSuccessStatusCodes ||= [] request { method: requestOptions.method diff --git a/services/web/test/unit/coffee/User/UserUpdaterTests.coffee b/services/web/test/unit/coffee/User/UserUpdaterTests.coffee index 77f2c38c85..a2348b54e2 100644 --- a/services/web/test/unit/coffee/User/UserUpdaterTests.coffee +++ b/services/web/test/unit/coffee/User/UserUpdaterTests.coffee @@ -19,7 +19,7 @@ describe "UserUpdater", -> getUserByAnyEmail: sinon.stub() ensureUniqueEmailAddress: sinon.stub() @logger = err: sinon.stub(), log: -> - settings = apis: { v1: { url: '', user: '', pass: '' } } + settings = apis: { v1: { url: 'v1.url', user: '', pass: '' } } @request = sinon.stub() @UserUpdater = SandboxedModule.require modulePath, requires: "logger-sharelatex": @logger @@ -90,7 +90,7 @@ describe "UserUpdater", -> should.not.exist(err) @request.calledOnce.should.equal true requestOptions = @request.lastCall.args[0] - expectedUrl = "/api/v2/users/#{@stubbedUser._id}/affiliations" + expectedUrl = "v1.url/api/v2/users/#{@stubbedUser._id}/affiliations" requestOptions.url.should.equal expectedUrl requestOptions.method.should.equal 'POST' @@ -138,7 +138,7 @@ describe "UserUpdater", -> should.not.exist(err) @request.calledOnce.should.equal true requestOptions = @request.lastCall.args[0] - expectedUrl = "/api/v2/users/#{@stubbedUser._id}/affiliations/" + expectedUrl = "v1.url/api/v2/users/#{@stubbedUser._id}/affiliations/" expectedUrl += encodeURIComponent(@newEmail) requestOptions.url.should.equal expectedUrl requestOptions.method.should.equal 'DELETE'