mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Switch to using status
over statusCode
This is a difference in the request/fetch APIs. GitOrigin-RevId: bde9adcf4de2ceaabfd9baae7a93bf2b0b5e5a1e
This commit is contained in:
parent
0a62bc1239
commit
2ccd39b2fa
3 changed files with 16 additions and 17 deletions
|
@ -51,7 +51,7 @@ const promises = {
|
||||||
)
|
)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
if (response.statusCode === 404) {
|
if (response.status === 404) {
|
||||||
// actually not an error in this case, just no existing account
|
// actually not an error in this case, just no existing account
|
||||||
logger.debug(
|
logger.debug(
|
||||||
{ userId: user._id },
|
{ userId: user._id },
|
||||||
|
@ -355,7 +355,7 @@ const promises = {
|
||||||
expect422: true,
|
expect422: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (response.statusCode === 422) {
|
if (response.status === 422) {
|
||||||
return await RecurlyWrapper.promises._handle422Response(body)
|
return await RecurlyWrapper.promises._handle422Response(body)
|
||||||
} else {
|
} else {
|
||||||
return await RecurlyWrapper.promises._parseSubscriptionXml(body)
|
return await RecurlyWrapper.promises._parseSubscriptionXml(body)
|
||||||
|
@ -713,7 +713,7 @@ const promises = {
|
||||||
},
|
},
|
||||||
expect404: true,
|
expect404: true,
|
||||||
})
|
})
|
||||||
if (response.statusCode === 404) {
|
if (response.status === 404) {
|
||||||
return []
|
return []
|
||||||
} else {
|
} else {
|
||||||
return await RecurlyWrapper.promises._parseSubscriptionsXml(body)
|
return await RecurlyWrapper.promises._parseSubscriptionsXml(body)
|
||||||
|
|
|
@ -166,7 +166,7 @@ const getInvoicePage = fullInvoicesIds => queryOptions => {
|
||||||
const hasMore = end < fullInvoicesIds.length
|
const hasMore = end < fullInvoicesIds.length
|
||||||
const nextPageCursor = hasMore ? `${end}%3A${end + ITEMS_PER_PAGE}&v=2` : null
|
const nextPageCursor = hasMore ? `${end}%3A${end + ITEMS_PER_PAGE}&v=2` : null
|
||||||
const response = {
|
const response = {
|
||||||
statusCode: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
link: hasMore
|
link: hasMore
|
||||||
? `https://fakerecurly.com/v2/invoices?cursor=${nextPageCursor}`
|
? `https://fakerecurly.com/v2/invoices?cursor=${nextPageCursor}`
|
||||||
|
@ -188,7 +188,7 @@ describe('CollectPayPalPastDueInvoice', function () {
|
||||||
|
|
||||||
if (/accounts\/(\d+)\/billing_info/.test(options.url)) {
|
if (/accounts\/(\d+)\/billing_info/.test(options.url)) {
|
||||||
return {
|
return {
|
||||||
response: { statusCode: 200, headers: {} },
|
response: { status: 200, headers: {} },
|
||||||
body: billingInfoXml,
|
body: billingInfoXml,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ describe('CollectPayPalPastDueInvoice', function () {
|
||||||
const invoiceId = options.url.match(/invoices\/(\d+)\/collect/)[1]
|
const invoiceId = options.url.match(/invoices\/(\d+)\/collect/)[1]
|
||||||
if (invoiceId < 400) {
|
if (invoiceId < 400) {
|
||||||
return {
|
return {
|
||||||
response: { statusCode: 200, headers: {} },
|
response: { status: 200, headers: {} },
|
||||||
body: invoiceCollectXml,
|
body: invoiceCollectXml,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,13 +94,12 @@ const mockApiRequest = function (options) {
|
||||||
if (fixtures[options.url]) {
|
if (fixtures[options.url]) {
|
||||||
return {
|
return {
|
||||||
err: null,
|
err: null,
|
||||||
response: { statusCode: 200 },
|
response: { status: 200 },
|
||||||
body: fixtures[options.url],
|
body: fixtures[options.url],
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
err: new Error('Not found'),
|
err: new Error('Not found'),
|
||||||
response: { statusCode: 404 },
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -585,7 +584,7 @@ describe('RecurlyWrapper', function () {
|
||||||
threeDSecureActionResult: 'a-3d-token-id',
|
threeDSecureActionResult: 'a-3d-token-id',
|
||||||
}
|
}
|
||||||
this.apiRequest = sinon.stub(this.RecurlyWrapper.promises, 'apiRequest')
|
this.apiRequest = sinon.stub(this.RecurlyWrapper.promises, 'apiRequest')
|
||||||
this.response = { statusCode: 200 }
|
this.response = { status: 200 }
|
||||||
this.body = '<xml>is_bad</xml>'
|
this.body = '<xml>is_bad</xml>'
|
||||||
this.apiRequest.resolves({
|
this.apiRequest.resolves({
|
||||||
response: this.response,
|
response: this.response,
|
||||||
|
@ -684,7 +683,7 @@ describe('RecurlyWrapper', function () {
|
||||||
`
|
`
|
||||||
// this.apiRequest.yields(null, { statusCode: 422 }, body)
|
// this.apiRequest.yields(null, { statusCode: 422 }, body)
|
||||||
this.apiRequest.resolves({
|
this.apiRequest.resolves({
|
||||||
response: { statusCode: 422 },
|
response: { status: 422 },
|
||||||
body,
|
body,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -948,7 +947,7 @@ describe('RecurlyWrapper', function () {
|
||||||
const resultXml =
|
const resultXml =
|
||||||
'<account><account_code>abc</account_code></account>'
|
'<account><account_code>abc</account_code></account>'
|
||||||
this.apiRequest.resolves({
|
this.apiRequest.resolves({
|
||||||
response: { statusCode: 200 },
|
response: { status: 200 },
|
||||||
body: resultXml,
|
body: resultXml,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -987,7 +986,7 @@ describe('RecurlyWrapper', function () {
|
||||||
describe('when the account does not exist', function () {
|
describe('when the account does not exist', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.apiRequest.resolves({
|
this.apiRequest.resolves({
|
||||||
response: { statusCode: 404 },
|
response: { status: 404 },
|
||||||
body: '',
|
body: '',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1095,7 +1094,7 @@ describe('RecurlyWrapper', function () {
|
||||||
const resultXml =
|
const resultXml =
|
||||||
'<account><account_code>abc</account_code></account>'
|
'<account><account_code>abc</account_code></account>'
|
||||||
this.apiRequest.resolves({
|
this.apiRequest.resolves({
|
||||||
response: { statusCode: 200 },
|
response: { status: 200 },
|
||||||
body: resultXml,
|
body: resultXml,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1174,7 +1173,7 @@ describe('RecurlyWrapper', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const resultXml = '<billing_info><a>1</a></billing_info>'
|
const resultXml = '<billing_info><a>1</a></billing_info>'
|
||||||
this.apiRequest.resolves({
|
this.apiRequest.resolves({
|
||||||
response: { statusCode: 200 },
|
response: { status: 200 },
|
||||||
body: resultXml,
|
body: resultXml,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1260,7 +1259,7 @@ describe('RecurlyWrapper', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const resultXml = '<billing_info><city>London</city></billing_info>'
|
const resultXml = '<billing_info><city>London</city></billing_info>'
|
||||||
this.apiRequest.resolves({
|
this.apiRequest.resolves({
|
||||||
response: { statusCode: 200 },
|
response: { status: 200 },
|
||||||
body: resultXml,
|
body: resultXml,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1328,7 +1327,7 @@ describe('RecurlyWrapper', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const resultXml = '<subscription><a>1</a></subscription>'
|
const resultXml = '<subscription><a>1</a></subscription>'
|
||||||
this.apiRequest.resolves({
|
this.apiRequest.resolves({
|
||||||
response: { statusCode: 200 },
|
response: { status: 200 },
|
||||||
body: resultXml,
|
body: resultXml,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1437,7 +1436,7 @@ describe('RecurlyWrapper', function () {
|
||||||
|
|
||||||
describe('without an account', function () {
|
describe('without an account', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.response.statusCode = 404
|
this.response.status = 404
|
||||||
this.accountActiveSubscriptions =
|
this.accountActiveSubscriptions =
|
||||||
await this.RecurlyWrapper.promises.listAccountActiveSubscriptions(
|
await this.RecurlyWrapper.promises.listAccountActiveSubscriptions(
|
||||||
this.user_id
|
this.user_id
|
||||||
|
|
Loading…
Reference in a new issue