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

Commit c0431d6

Browse files
committed
Merge remote-tracking branch 'origin/develop' into cucumber-js
2 parents d577d98 + 309787d commit c0431d6

File tree

8 files changed

+84
-20
lines changed

8 files changed

+84
-20
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<a href="https://travis-ci.org/Human-Connection/API"><img src="https://img.shields.io/travis/Human-Connection/API/master.svg" alt="Build Status"></a>
88
<a href="https://github.com/Human-Connection/WebApp/blob/develop/LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-green.svg" "MIT" /></a>
99
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2FHuman-Connection%2FAPI?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2FHuman-Connection%2FAPI.svg?type=shield"/></a>
10+
<a href="https://discord.gg/NgVpvx9" alt="Discord Channel">
11+
<img src="https://img.shields.io/discord/443107904757694465.svg" alt="Discord" /></a>
1012
</p>
1113

1214
# Human-Connection API

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@
100100
"request-promise": "~4.2.2",
101101
"sanitize-html": "^1.18.2",
102102
"serve-favicon": "~2.5.0",
103-
"shortid": "~2.2.11",
103+
"shortid": "~2.2.12",
104104
"slug": "~0.9.1",
105105
"trunc-html": "^1.1.2",
106106
"uuid": "^3.3.2",
107107
"valid-url": "^1.0.9",
108108
"winston": "~3.0.0-rc5"
109109
},
110110
"devDependencies": {
111-
"babel-eslint": "~8.2.3",
111+
"babel-eslint": "~8.2.6",
112112
"chai": "^4.1.2",
113113
"cucumber": "^4.2.1",
114114
"concurrently": "~3.6.0",
@@ -117,7 +117,7 @@
117117
"istanbul": "1.1.0-alpha.1",
118118
"mocha": "~5.2.0",
119119
"node-fetch": "^2.1.2",
120-
"nodemon": "~1.18.0",
120+
"nodemon": "~1.18.1",
121121
"nyc": "^12.0.2",
122122
"wait-on": "~2.1.0"
123123
}

server/helper/get-unique-slug.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const getUniqueSlug = (service, slug, count, id) => {
1414
}
1515
service.find({
1616
query,
17+
_includeAll: true,
1718
_populate: 'skip'
1819
}).then((result) => {
1920
if (result.data.length > 0) {

server/hooks/include-all.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = () => hook => {
2+
if (!hook.params._includeAll) {
3+
return hook;
4+
}
5+
if (hook.params.query.deleted) {
6+
delete hook.params.query.deleted;
7+
}
8+
if (hook.params.query.isEnabled) {
9+
delete hook.params.query.isEnabled;
10+
}
11+
return hook;
12+
};

server/services/comments/comments.hooks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = {
4141
],
4242
find: [
4343
// We want to deleted comments to show up
44-
(hook) => {
44+
hook => {
4545
delete hook.params.query.deleted;
4646
return hook;
4747
}
@@ -120,10 +120,10 @@ module.exports = {
120120
createNotifications()
121121
],
122122
update: [
123-
createMentionNotifications()
123+
// createMentionNotifications()
124124
],
125125
patch: [
126-
createMentionNotifications()
126+
// createMentionNotifications()
127127
],
128128
remove: []
129129
},

server/services/contributions/contributions.hooks.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const createSlug = require('../../hooks/create-slug');
1010
const saveRemoteImages = require('../../hooks/save-remote-images');
1111
const createExcerpt = require('../../hooks/create-excerpt');
1212
const patchDeletedData = require('../../hooks/patch-deleted-data');
13+
const includeAll = require('../../hooks/include-all');
1314
const cleanupRelatedItems = require('../../hooks/cleanup-related-items');
1415
const keepDeletedDataFields = require('../../hooks/keep-deleted-data-fields');
1516
const search = require('feathers-mongodb-fuzzy-search');
@@ -108,6 +109,9 @@ module.exports = {
108109
unless(isModerator(),
109110
excludeDisabled()
110111
),
112+
when(isProvider('server'),
113+
includeAll()
114+
),
111115
search(),
112116
search({
113117
fields: ['title', 'content']
@@ -163,7 +167,6 @@ module.exports = {
163167
patchDeletedData({
164168
data: {
165169
$set: {
166-
title: 'DELETED',
167170
type: 'DELETED',
168171
content: 'DELETED',
169172
contentExcerpt: 'DELETED',
@@ -225,11 +228,11 @@ module.exports = {
225228
thumbnails(thumbs)
226229
],
227230
update: [
228-
createMentionNotifications(),
231+
// createMentionNotifications(),
229232
thumbnails(thumbs)
230233
],
231234
patch: [
232-
createMentionNotifications(),
235+
// createMentionNotifications(),
233236
thumbnails(thumbs)
234237
],
235238
remove: [

test/services/contributions.test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,52 @@ describe('\'contributions\' service', () => {
8181
assert.ok(notification.relatedContributionId, 'has relatedContributionId');
8282
assert.equal(notification.relatedContributionId, contribution._id, 'has correct relatedContributionId');
8383
});
84+
85+
context('given soft-deleted contribution', () => {
86+
const contributionAttributes = {
87+
title: 'title',
88+
type: 'post',
89+
content: 'blah',
90+
language: 'en',
91+
};
92+
93+
beforeEach(async () => {
94+
const deletedContributionAttributes = Object.assign({}, contributionAttributes, {
95+
deleted: true,
96+
slug: 'title'
97+
});
98+
await service.create(deletedContributionAttributes, params);
99+
});
100+
101+
it('increments title slug', async () => {
102+
let contribution = await service.create(contributionAttributes, params);
103+
assert.ok(contribution, 'created contribution');
104+
assert.equal(contribution.slug, 'title1');
105+
});
106+
});
107+
108+
context('given disabled contribution', () => {
109+
const contributionAttributes = {
110+
title: 'title',
111+
type: 'post',
112+
content: 'blah',
113+
language: 'en',
114+
};
115+
116+
beforeEach(async () => {
117+
const disabledContributionAttributes = Object.assign({}, contributionAttributes, {
118+
isEnabled: false,
119+
slug: 'title'
120+
});
121+
await service.create(disabledContributionAttributes, params);
122+
});
123+
124+
it('increments title slug', async () => {
125+
let contribution = await service.create(contributionAttributes, params);
126+
assert.ok(contribution, 'created contribution');
127+
assert.equal(contribution.slug, 'title1');
128+
});
129+
});
84130
});
85131

86132
describe('contributions patch', () => {

yarn.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,15 @@ babel-code-frame@^6.22.0, babel-code-frame@^6.26.0:
562562
esutils "^2.0.2"
563563
js-tokens "^3.0.2"
564564

565-
babel-eslint@~8.2.3:
566-
version "8.2.5"
567-
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.5.tgz#dc2331c259d36782aa189da510c43dedd5adc7a3"
565+
babel-eslint@~8.2.6:
566+
version "8.2.6"
567+
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.6.tgz#6270d0c73205628067c0f7ae1693a9e797acefd9"
568568
dependencies:
569569
"@babel/code-frame" "7.0.0-beta.44"
570570
"@babel/traverse" "7.0.0-beta.44"
571571
"@babel/types" "7.0.0-beta.44"
572572
babylon "7.0.0-beta.44"
573-
eslint-scope "~3.7.1"
573+
eslint-scope "3.7.1"
574574
eslint-visitor-keys "^1.0.0"
575575

576576
babel-generator@^6.18.0:
@@ -1850,7 +1850,7 @@ [email protected], escape-string-regexp@^1.0.2, escape-string-regexp@^1
18501850
version "1.0.5"
18511851
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
18521852

1853-
eslint-scope@^3.7.1, eslint-scope@~3.7.1:
1853+
[email protected], eslint-scope@^3.7.1:
18541854
version "3.7.1"
18551855
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
18561856
dependencies:
@@ -4087,9 +4087,9 @@ nodemailer@^4.0.0:
40874087
version "4.6.7"
40884088
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-4.6.7.tgz#b68de7f36d65618bdeeeb76234e3547d51266373"
40894089

4090-
nodemon@~1.18.0:
4091-
version "1.18.0"
4092-
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-1.18.0.tgz#44b75d5f19065c47a262d4ab21990da3b6f8feae"
4090+
nodemon@~1.18.1:
4091+
version "1.18.1"
4092+
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-1.18.1.tgz#873d2f7799662c549f7ea557db6934d5cbf665d6"
40934093
dependencies:
40944094
chokidar "^2.0.2"
40954095
debug "^3.1.0"
@@ -5160,9 +5160,9 @@ shebang-regex@^1.0.0:
51605160
version "1.0.0"
51615161
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
51625162

5163-
shortid@~2.2.11:
5164-
version "2.2.11"
5165-
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.11.tgz#a77896f086b0dae7fce1237e29232d2aeef5738e"
5163+
shortid@~2.2.12:
5164+
version "2.2.12"
5165+
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.12.tgz#8e9a95ffbc671fff8f09e985dbc7874102b0cfd2"
51665166
dependencies:
51675167
nanoid "^1.0.7"
51685168

0 commit comments

Comments
 (0)