Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 5125f50

Browse files
merged develop in and fixed lcov issue
2 parents 9c2c24c + e132823 commit 5125f50

File tree

9 files changed

+30
-20
lines changed

9 files changed

+30
-20
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- yarn install --frozen-lockfile --non-interactive
2424
- yarn add codacy-coverage
2525
- yarn global add nyc
26-
- yarn test:coverage
26+
- yarn test
2727
- cat ./coverage/lcov.info | codacy-coverage
2828

2929
after_success:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Getting up and running is as easy as 1, 2, 3, 4 ... 5.
7272
> ##### IMPORTANT for WIN users:
7373
> - make sure you have mongo bin directory added to your PATH
7474
> - if you picked another data directory during mongodb setup make sure
75-
> to change package.json scripts section for key "dev-win" so it points to
75+
> to change package.json scripts section for key "dev:win" so it points to
7676
> the proper path. Otherwise you will get missing data path errors from mongodb.
7777
7878
If you did it right it will seed some fake data for you and downloads some images and avatar for faster development.

package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Human-Connection API",
44
"version": "0.1.0",
55
"homepage": "https://human-connection.org",
6-
"license": "CC-BY-NC-SA-4.0",
6+
"license": "MIT",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/Human-Connection/API.git"
@@ -34,13 +34,10 @@
3434
},
3535
"scripts": {
3636
"clear": "rm -Rf tmp",
37-
"nyc": "nyc --reporter=text-summary",
38-
"test": "npm run eslint && cross-env NODE_ENV=test npm run nyc npm run mocha",
39-
"test:mongo": "npm run eslint && cross-env NODE_ENV=test npm run nyc npm run mocha:mongo",
40-
"test:coverage": "npm run eslint && cross-env NODE_ENV=test npm run nyc --reporter=lcovonly npm run mocha",
37+
"test": "npm run eslint && cross-env NODE_ENV=test && nyc --reporter=lcovonly --reporter=text-summary npm run mocha",
38+
"test:mongo": "npm run eslint && cross-env NODE_ENV=test && nyc --reporter=lcovonly --reporter=text-summary npm run mocha:mongo",
4139
"eslint": "eslint server/. test/. --config .eslintrc.json",
4240
"start": "concurrently 'mongod' 'wait-on tcp:27017 && cross-env NODE_ENV=production node server/'",
43-
"start:win": "concurrently \"mongod\" \"wait-on tcp:27017 &&SET NODE_ENV=production&& node server/\"",
4441
"dev:debug": "npm run clear && concurrently '$npm_package_config_mongoDev &>/dev/null' 'wait-on tcp:27017 && cross-env DEBUG=feathers && cross-env NODE_ENV=development nodemon --inspect server/'",
4542
"dev": "npm run clear && concurrently '$npm_package_config_mongoDev &>/dev/null' 'wait-on tcp:27017 && cross-env DEBUG=feathers && cross-env NODE_ENV=development nodemon server/'",
4643
"dev:local": "sh scripts/run-local.sh",
@@ -110,7 +107,7 @@
110107
"devDependencies": {
111108
"babel-eslint": "~8.2.3",
112109
"concurrently": "~3.5.1",
113-
"cross-env": "^5.1.5",
110+
"cross-env": "^5.2.0",
114111
"eslint": "~4.19.1",
115112
"istanbul": "1.1.0-alpha.1",
116113
"mocha": "~5.2.0",

server/hooks/create-excerpt.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ module.exports = function (options = {}) { // eslint-disable-line no-unused-vars
3737
const contentBefore = trunc(content, 9999999999);
3838
const contentTruncated = trunc(contentSanitized, options.length);
3939

40-
// save meta key hasMore to indecate if there is more text then in the excerpt
40+
// save meta key hasMore to indicate if there is more text then in the excerpt
4141
const hasMore = contentBefore.text.length > (contentTruncated.text.length + 20);
4242
setByDot(hook.data, 'hasMore', hasMore);
4343

4444
// set excerpt
4545
setByDot(hook.data, `${options.field}Excerpt`, hasMore ? contentTruncated.html : content.replace(/(\ ){2,}/ig, ' '))
4646
} catch (err) {
47-
hook.app.error(err);
48-
throw new Error(err);
47+
// hook.app.error(err);
48+
// throw new Error(err);
4949
}
5050
// trim content
5151
setByDot(hook.data, options.field, content.replace(/(\ ){2,}/ig, ' '));

server/mongoose.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function () {
1212
connectTimeoutMS: 10000,
1313
socketTimeoutMS: 10000
1414
}, function () {
15-
if (process.NODE_ENV !== 'production' && app.get('seeder').dropDatabase === true) {
15+
if (process.env.NODE_ENV !== 'production' && app.get('seeder').dropDatabase === true) {
1616
mongoose.connection.dropDatabase().then(() => {
1717
app.debug('>>>>>> DROPED DATABASE <<<<<<');
1818
let uploadDir = path.resolve('public/uploads');

server/seeder/development/users-admin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = (seederstore) => {
1616
coverImg: 'https://source.unsplash.com/random/1250x280',
1717
badgeIds: () => {
1818
let badges = [keys(seederstore.badges)[0]];
19-
if (process.NODE_ENV !== 'production') {
19+
if (process.env.NODE_ENV !== 'production') {
2020
badges.push(keys(seederstore.badges)[5]);
2121
badges.push(keys(seederstore.badges)[10]);
2222
badges.push(keys(seederstore.badges)[16]);

server/services/auth-management/notifier.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports = function (app) {
111111

112112
function sendEmail (email) {
113113
// Save copy to /tmp/emails while in debug mode
114-
if (app.get('debug')) {
114+
if (process.env.NODE_ENV !== 'production') {
115115
const filename = String(Date.now()) + '.html';
116116
const filepath = path.join(__dirname, '../../../tmp/emails/', filename);
117117
fs.outputFileSync(filepath, email.html);
@@ -124,7 +124,10 @@ module.exports = function (app) {
124124
app.debug('Sent email', result);
125125
})
126126
.catch(err => {
127-
app.error('Error sending email', err);
127+
if (process.env.NODE_ENV !== 'test') {
128+
app.error('Error sending email', err);
129+
app.debug(err.message);
130+
}
128131
});
129132
}
130133

test/services/auth-management.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,19 @@ describe('\'authManagement\' service', () => {
5757
});
5858
});
5959

60+
const waitFor = (ms) => {
61+
return new Promise((resolve) => {
62+
setTimeout(() => {
63+
resolve();
64+
}, ms);
65+
});
66+
};
67+
6068
const getTokenFromMail = async () => {
6169
// Get token from tmp email file
6270
const mailDir = path.join(__dirname, '../../tmp/emails');
71+
// wait for the mail to be created first
72+
await waitFor(50);
6373
const fileName = await fs.readdirSync(mailDir)[0];
6474
const mailFile = path.join(mailDir, fileName);
6575
const mailContent = await fs.readFileSync(mailFile, 'utf8');

test/services/contributions.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ describe('\'contributions\' service', () => {
6767

6868
it('creates mention notification', async () => {
6969
const mentionedUser = await userService.create(userData);
70-
const data = {...contributionData};
71-
data.content = `<a href="" class="hc-editor-mention-blot" data-hc-mention="{&quot;_id&quot;:&quot;${mentionedUser._id.toString()}&quot;,&quot;slug&quot;:&quot;${mentionedUser.slug}&quot;}">${mentionedUser.name}</a>`;
70+
const data = Object.assign({}, contributionData);
71+
data.content += ` <a href="" class="hc-editor-mention-blot" data-hc-mention="{&quot;_id&quot;:&quot;${mentionedUser._id.toString()}&quot;,&quot;slug&quot;:&quot;${mentionedUser.slug}&quot;}">${mentionedUser.name}</a>`;
7272
const contribution = await service.create(data, params);
7373
const result = await notificationService.find({
7474
query: {
75-
userId: mentionedUser._id
75+
userId: mentionedUser._id.toString()
7676
}
7777
});
7878
const notification = result.data[0];
@@ -176,4 +176,4 @@ describe('\'contributions\' service', () => {
176176
assert.ok(result.data[0].associatedCanDos[0], 'finds result');
177177
});
178178
});
179-
});
179+
});

0 commit comments

Comments
 (0)