From 5de25032d8f27102c72936fe8f40c4b3d2cb15fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Alby?= Date: Tue, 19 Mar 2019 18:41:15 -0500 Subject: [PATCH] Merge pull request #1634 from sharelatex/ta-no-institution-autocreate Don't Auto-Create Institutions GitOrigin-RevId: 8be3a0d9f3f3814396a58d2fd131a62c9f196861 --- .../Institutions/InstitutionsController.coffee | 12 ++---------- .../InstitutionsControllerTests.coffee | 16 ---------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee index 0d9592db58..f687c8a000 100644 --- a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee +++ b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee @@ -1,23 +1,15 @@ logger = require("logger-sharelatex") UserGetter = require("../User/UserGetter") { addAffiliation } = require("../Institutions/InstitutionsAPI") -Institution = require('../../models/Institution').Institution FeaturesUpdater = require('../Subscription/FeaturesUpdater') async = require('async') module.exports = InstitutionsController = confirmDomain: (req, res, next) -> hostname = req.body.hostname - institutionId = req.body.institution_id - createInstitution institutionId, (error) -> + affiliateUsers hostname, (error) -> return next(error) if error? - affiliateUsers hostname, (error) -> - return next(error) if error? - res.sendStatus 200 - -createInstitution = (institutionId, callback = (error)->) -> - data = v1Id: institutionId - Institution.findOneAndUpdate data, data, { upsert: true }, callback + res.sendStatus 200 affiliateUsers = (hostname, callback = (error)->) -> reversedHostname = hostname.trim().split('').reverse().join('') diff --git a/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee b/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee index 351c2a2e00..f68f1de08b 100644 --- a/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee +++ b/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee @@ -37,8 +37,6 @@ describe "InstitutionsController", -> getUsersByHostname: @getUsersByHostname '../Institutions/InstitutionsAPI': addAffiliation: @addAffiliation - '../../models/Institution': Institution: @Institution = - findOneAndUpdate: sinon.stub().yields() '../Subscription/FeaturesUpdater': refreshFeatures: @refreshFeatures @@ -71,17 +69,3 @@ describe "InstitutionsController", -> @getUsersByHostname.calledOnce.should.equal true done() @InstitutionsController.confirmDomain @req, @res, @next - - describe 'createInstitution', -> - it 'should create new institution', (done)-> - @req.body.institution_id = 123 - expectedData = v1Id: 123 - @res.sendStatus = (code) => - sinon.assert.calledWith( - @Institution.findOneAndUpdate, - expectedData, - expectedData, - { upsert: true } - ) - done() - @InstitutionsController.confirmDomain @req, @res, @next