mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
fix tests
This commit is contained in:
Submodule habitica-images updated: acb3ede81d...aa72332019
@@ -150,7 +150,7 @@ describe('emails', () => {
|
|||||||
|
|
||||||
sendTxn(mailingInfo, emailType);
|
sendTxn(mailingInfo, emailType);
|
||||||
expect(got.post).to.be.called;
|
expect(got.post).to.be.called;
|
||||||
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
|
expect(got.post).to.be.calledWith('http://example.com/job', sinon.match({
|
||||||
json: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
emailType: sinon.match.same(emailType),
|
emailType: sinon.match.same(emailType),
|
||||||
@@ -234,7 +234,7 @@ describe('emails', () => {
|
|||||||
|
|
||||||
sendTxn(mailingInfo, emailType);
|
sendTxn(mailingInfo, emailType);
|
||||||
expect(got.post).to.be.called;
|
expect(got.post).to.be.called;
|
||||||
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
|
expect(got.post).to.be.calledWith('http://example.com/job', sinon.match({
|
||||||
json: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
emailType: sinon.match.same(emailType),
|
emailType: sinon.match.same(emailType),
|
||||||
@@ -254,7 +254,7 @@ describe('emails', () => {
|
|||||||
|
|
||||||
sendTxn(mailingInfo, emailType, variables);
|
sendTxn(mailingInfo, emailType, variables);
|
||||||
expect(got.post).to.be.called;
|
expect(got.post).to.be.called;
|
||||||
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
|
expect(got.post).to.be.calledWith('http://example.com/job', sinon.match({
|
||||||
json: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
variables: sinon.match(value => value[0].name === 'BASE_URL', 'matches variables'),
|
variables: sinon.match(value => value[0].name === 'BASE_URL', 'matches variables'),
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import got from 'got';
|
|||||||
import nconf from 'nconf';
|
import nconf from 'nconf';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
|
||||||
const IS_PROD = nconf.get('IS_PROD');
|
|
||||||
const EMAIL_SERVER = {
|
const EMAIL_SERVER = {
|
||||||
url: nconf.get('EMAIL_SERVER_URL'),
|
url: nconf.get('EMAIL_SERVER_URL'),
|
||||||
auth: {
|
auth: {
|
||||||
@@ -12,26 +11,23 @@ const EMAIL_SERVER = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function sendJob (type, config) {
|
export function sendJob (type, config) {
|
||||||
if (IS_PROD) {
|
const { data, options } = config;
|
||||||
const { data, options } = config;
|
const usedOptions = {
|
||||||
const usedOptions = {
|
backoff: { delay: 10 * 60 * 1000, type: 'exponential' },
|
||||||
backoff: { delay: 10 * 60 * 1000, type: 'exponential' },
|
...options,
|
||||||
...options,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
return got.post(`${EMAIL_SERVER.url}/job`, {
|
return got.post(`${EMAIL_SERVER.url}/job`, {
|
||||||
retry: 5, // retry the http request to the email server 5 times
|
retry: 5, // retry the http request to the email server 5 times
|
||||||
timeout: 60000, // wait up to 60s before timing out
|
timeout: 60000, // wait up to 60s before timing out
|
||||||
username: EMAIL_SERVER.auth.user,
|
username: EMAIL_SERVER.auth.user,
|
||||||
password: EMAIL_SERVER.auth.password,
|
password: EMAIL_SERVER.auth.password,
|
||||||
json: {
|
json: {
|
||||||
type,
|
type,
|
||||||
data,
|
data,
|
||||||
options: usedOptions,
|
options: usedOptions,
|
||||||
},
|
},
|
||||||
}).json().catch(err => logger.error(err, {
|
}).json().catch(err => logger.error(err, {
|
||||||
extraMessage: 'Error while sending an email.',
|
extraMessage: 'Error while sending an email.',
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user