mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #25967 from overleaf/mf-sync-email-update-to-stripe-account
[web] Sync Stripe customer email when user update their primary email in account setting GitOrigin-RevId: a5f4b4e960d2c9d4ba96a2b3036329f4868e1bb8
This commit is contained in:
@@ -153,7 +153,9 @@ describe('SubscriptionController', function () {
|
||||
'@overleaf/settings': this.settings,
|
||||
'../User/UserGetter': this.UserGetter,
|
||||
'./RecurlyWrapper': (this.RecurlyWrapper = {
|
||||
updateAccountEmailAddress: sinon.stub().yields(),
|
||||
promises: {
|
||||
updateAccountEmailAddress: sinon.stub().resolves(),
|
||||
},
|
||||
}),
|
||||
'./RecurlyEventHandler': {
|
||||
sendRecurlyAnalyticsEvent: sinon.stub().resolves(),
|
||||
@@ -309,31 +311,39 @@ describe('SubscriptionController', function () {
|
||||
})
|
||||
|
||||
describe('updateAccountEmailAddress via put', function () {
|
||||
it('should send the user and subscriptionId to RecurlyWrapper', function () {
|
||||
it('should send the user and subscriptionId to RecurlyWrapper', async function () {
|
||||
this.res.sendStatus = sinon.spy()
|
||||
this.SubscriptionController.updateAccountEmailAddress(this.req, this.res)
|
||||
this.RecurlyWrapper.updateAccountEmailAddress
|
||||
await this.SubscriptionController.updateAccountEmailAddress(
|
||||
this.req,
|
||||
this.res
|
||||
)
|
||||
this.RecurlyWrapper.promises.updateAccountEmailAddress
|
||||
.calledWith(this.user._id, this.user.email)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should respond with 200', function () {
|
||||
it('should respond with 200', async function () {
|
||||
this.res.sendStatus = sinon.spy()
|
||||
this.SubscriptionController.updateAccountEmailAddress(this.req, this.res)
|
||||
await this.SubscriptionController.updateAccountEmailAddress(
|
||||
this.req,
|
||||
this.res
|
||||
)
|
||||
this.res.sendStatus.calledWith(200).should.equal(true)
|
||||
})
|
||||
|
||||
it('should send the error to the next handler when updating recurly account email fails', function (done) {
|
||||
this.RecurlyWrapper.updateAccountEmailAddress.yields(new Error())
|
||||
it('should send the error to the next handler when updating recurly account email fails', async function () {
|
||||
this.RecurlyWrapper.promises.updateAccountEmailAddress.rejects(
|
||||
new Error()
|
||||
)
|
||||
this.next = sinon.spy(error => {
|
||||
expect(error).instanceOf(Error)
|
||||
done()
|
||||
expect(error).to.be.instanceOf(Error)
|
||||
})
|
||||
this.SubscriptionController.updateAccountEmailAddress(
|
||||
await this.SubscriptionController.updateAccountEmailAddress(
|
||||
this.req,
|
||||
this.res,
|
||||
this.next
|
||||
)
|
||||
expect(this.next.calledOnce).to.be.true
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -59,11 +59,6 @@ describe('UserUpdater', function () {
|
||||
changeEmail: sinon.stub().resolves(),
|
||||
},
|
||||
}
|
||||
this.RecurlyWrapper = {
|
||||
promises: {
|
||||
updateAccountEmailAddress: sinon.stub().resolves(),
|
||||
},
|
||||
}
|
||||
this.AnalyticsManager = {
|
||||
recordEventForUserInBackground: sinon.stub(),
|
||||
}
|
||||
@@ -264,9 +259,11 @@ describe('UserUpdater', function () {
|
||||
expect(
|
||||
this.NewsletterManager.promises.changeEmail
|
||||
).to.have.been.calledWith(this.user, this.newEmail)
|
||||
expect(
|
||||
this.RecurlyWrapper.promises.updateAccountEmailAddress
|
||||
).to.have.been.calledWith(this.user._id, this.newEmail)
|
||||
expect(this.Modules.promises.hooks.fire).to.have.been.calledWith(
|
||||
'updateAccountEmailAddress',
|
||||
this.user._id,
|
||||
this.newEmail
|
||||
)
|
||||
})
|
||||
|
||||
it('validates email', async function () {
|
||||
@@ -615,9 +612,11 @@ describe('UserUpdater', function () {
|
||||
expect(
|
||||
this.NewsletterManager.promises.changeEmail
|
||||
).to.have.been.calledWith(this.user, this.newEmail)
|
||||
expect(
|
||||
this.RecurlyWrapper.promises.updateAccountEmailAddress
|
||||
).to.have.been.calledWith(this.user._id, this.newEmail)
|
||||
expect(this.Modules.promises.hooks.fire).to.have.been.calledWith(
|
||||
'updateAccountEmailAddress',
|
||||
this.user._id,
|
||||
this.newEmail
|
||||
)
|
||||
})
|
||||
|
||||
it('handles Mongo errors', async function () {
|
||||
|
||||
Reference in New Issue
Block a user