Skip to content

Commit 0a6f138

Browse files
committed
fix tests
1 parent bc77c76 commit 0a6f138

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

habitica-images

Submodule habitica-images updated 1052 files

test/api/unit/libs/email.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe('emails', () => {
150150

151151
sendTxn(mailingInfo, emailType);
152152
expect(got.post).to.be.called;
153-
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
153+
expect(got.post).to.be.calledWith('http://example.com/job', sinon.match({
154154
json: {
155155
data: {
156156
emailType: sinon.match.same(emailType),
@@ -234,7 +234,7 @@ describe('emails', () => {
234234

235235
sendTxn(mailingInfo, emailType);
236236
expect(got.post).to.be.called;
237-
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
237+
expect(got.post).to.be.calledWith('http://example.com/job', sinon.match({
238238
json: {
239239
data: {
240240
emailType: sinon.match.same(emailType),
@@ -254,7 +254,7 @@ describe('emails', () => {
254254

255255
sendTxn(mailingInfo, emailType, variables);
256256
expect(got.post).to.be.called;
257-
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
257+
expect(got.post).to.be.calledWith('http://example.com/job', sinon.match({
258258
json: {
259259
data: {
260260
variables: sinon.match(value => value[0].name === 'BASE_URL', 'matches variables'),

website/server/libs/worker.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import got from 'got';
22
import nconf from 'nconf';
33
import logger from './logger';
44

5-
const IS_PROD = nconf.get('IS_PROD');
65
const EMAIL_SERVER = {
76
url: nconf.get('EMAIL_SERVER_URL'),
87
auth: {
@@ -12,26 +11,23 @@ const EMAIL_SERVER = {
1211
};
1312

1413
export function sendJob (type, config) {
15-
if (IS_PROD) {
16-
const { data, options } = config;
17-
const usedOptions = {
18-
backoff: { delay: 10 * 60 * 1000, type: 'exponential' },
19-
...options,
20-
};
14+
const { data, options } = config;
15+
const usedOptions = {
16+
backoff: { delay: 10 * 60 * 1000, type: 'exponential' },
17+
...options,
18+
};
2119

22-
return got.post(`${EMAIL_SERVER.url}/job`, {
23-
retry: 5, // retry the http request to the email server 5 times
24-
timeout: 60000, // wait up to 60s before timing out
25-
username: EMAIL_SERVER.auth.user,
26-
password: EMAIL_SERVER.auth.password,
27-
json: {
28-
type,
29-
data,
30-
options: usedOptions,
31-
},
32-
}).json().catch(err => logger.error(err, {
33-
extraMessage: 'Error while sending an email.',
34-
}));
35-
}
36-
return null;
20+
return got.post(`${EMAIL_SERVER.url}/job`, {
21+
retry: 5, // retry the http request to the email server 5 times
22+
timeout: 60000, // wait up to 60s before timing out
23+
username: EMAIL_SERVER.auth.user,
24+
password: EMAIL_SERVER.auth.password,
25+
json: {
26+
type,
27+
data,
28+
options: usedOptions,
29+
},
30+
}).json().catch(err => logger.error(err, {
31+
extraMessage: 'Error while sending an email.',
32+
}));
3733
}

0 commit comments

Comments
 (0)