Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release-0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
batamar committed Dec 1, 2017
2 parents ffc6334 + 6eee2c4 commit c6ba36f
Show file tree
Hide file tree
Showing 195 changed files with 19,669 additions and 740 deletions.
19 changes: 15 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
NODE_ENV=development
PORT=3400
MONGO_URL=mongodb://localhost:3001/meteor
TEST_MONGO_URL=mongodb://localhost/erxesApiTest
NODE_ENV='development'
PORT=3300
MONGO_URL=mongodb://localhost/erxes
TEST_MONGO_URL=mongodb://localhost/test
MAIN_APP_DOMAIN=http://localhost:3000
COMPANY_EMAIL_FROM='[email protected]'
MAIL_SERVICE='sendgrid'
MAIL_USER='apikey'
MAIL_PASS='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'

TWITTER_CONSUMER_KEY='xQlhyI9cAkRT5LOwGEpM1c2WU'
TWITTER_CONSUMER_SECRET='zGn2j60tBAv0tsClKOSeS3j4HXywCH01DJxOQna32bdcrGMee0'
TWITTER_REDIRECT_URL='http://5e574edb.ngrok.io/service/oauth/twitter_callback'

FACEBOOK='[{"id":"","name":"","verifyToken":"","accessToken":""}]'
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

45 changes: 37 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "erxes-app-api",
"version": "0.8.1",
"version": "0.9.0",
"description": "GraphQL API for erxes main project",
"homepage": "https://erxes.io",
"repository": "https://github.com/erxes/erxes-app-api",
Expand All @@ -19,40 +19,69 @@
"build": "babel src --out-dir dist --ignore __tests__,tests --copy-files",
"lint": "eslint src",
"format": "prettier --write --print-width 100 --single-quote --trailing-comma all 'src/**/*.js'",
"precommit": "lint-staged"
"precommit": "lint-staged",
"test": "jest --runInBand --coverage"
},
"lint-staged": {
"*.js": [
"prettier --write --print-width 100 --single-quote --trailing-comma all",
"git add"
]
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js}",
"!src/index.js",
"!src/db/factories.js",
"!src/db/connection.js",
"!src/data/schema/**",
"!src/data/resolvers/subscriptions/**",
"!src/data/index.js",
"!src/data/utils.js"
]
},
"dependencies": {
"aws-sdk": "^2.151.0",
"bcrypt": "^1.0.3",
"body-parser": "^1.17.1",
"cors": "^2.8.1",
"dotenv": "^4.0.0",
"express": "^4.15.2",
"fbgraph": "^1.4.1",
"formidable": "^1.1.1",
"graphql": "^0.10.1",
"graphql-redis-subscriptions": "^1.3.1",
"graphql-server-core": "^0.8.2",
"graphql-server-express": "^0.8.2",
"graphql-server-module-graphiql": "^0.8.2",
"graphql-subscriptions": "^0.4.3",
"graphql-subscriptions": "^0.4.4",
"graphql-tools": "^1.0.0",
"handlebars": "^4.0.10",
"jsonwebtoken": "^8.1.0",
"meteor-random": "^0.0.3",
"moment": "^2.18.1",
"mongoose": "^4.9.2",
"passport": "^0.4.0",
"passport-anonymous": "^1.0.1",
"passport-http-bearer": "^1.0.1",
"subscriptions-transport-ws": "^0.7.3",
"underscore": "^1.8.3"
"mongoose-type-email": "^1.0.5",
"node-schedule": "^1.2.5",
"nodemailer": "^4.1.3",
"sha256": "^0.2.0",
"sinon": "^4.0.1",
"social-oauth-client": "^0.1.6",
"strip": "^3.0.0",
"subscriptions-transport-ws": "0.8.3",
"twit": "^2.2.9",
"underscore": "^1.8.3",
"validator": "^9.0.0"
},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.6.0",
"eslint": "3.19.0",
"faker": "^4.1.0",
"husky": "^0.13.4",
"jest": "^21.2.1",
"jest-tobetype": "^1.1.0",
"lint-staged": "^3.6.0",
"nodemon": "^1.11.0",
"prettier": "^1.4.4"
Expand Down
80 changes: 80 additions & 0 deletions src/__tests__/activityLogCronJob.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* eslint-env jest */
/* eslint-disable no-underscore-dangle */

import { connect, disconnect } from '../db/connection';
import cronJobs from '../cronJobs';
import {
COC_CONTENT_TYPES,
ACTIVITY_TYPES,
ACTIVITY_ACTIONS,
ACTIVITY_PERFORMER_TYPES,
} from '../data/constants';
import { ActivityLogs } from '../db/models';
import { customerFactory, segmentFactory } from '../db/factories';

beforeAll(() => connect());
afterAll(() => disconnect());

describe('test activityLogsCronJob', () => {
test('test if it is working as intended', async () => {
// check if the activity log is being created ==================
const nameEqualsConditions = [
{
type: 'string',
dateUnit: 'days',
value: 'John Smith',
operator: 'e',
field: 'name',
},
];

const customer = await customerFactory({ name: 'john smith' });
const segment = await segmentFactory({
contentType: COC_CONTENT_TYPES.CUSTOMER,
conditions: nameEqualsConditions,
});

await cronJobs.createActivityLogsFromSegments();

expect(await ActivityLogs.find().count()).toBe(1);

const aLog = await ActivityLogs.findOne();

expect(aLog.activity.toObject()).toEqual({
type: ACTIVITY_TYPES.SEGMENT,
action: ACTIVITY_ACTIONS.CREATE,
content: segment.name,
id: segment._id,
});
expect(aLog.coc.toObject()).toEqual({
type: COC_CONTENT_TYPES.CUSTOMER,
id: customer._id,
});
expect(aLog.performedBy.toObject()).toEqual({
type: ACTIVITY_PERFORMER_TYPES.SYSTEM,
});

// check if the second activity log is being created
// also check if the duplicate activity log is
// not being created for the former customer ================
const nameEqualsConditions2 = [
{
type: 'string',
dateUnit: 'days',
value: 'jane smith',
operator: 'e',
field: 'name',
},
];

await customerFactory({ name: 'jane smith' });
await segmentFactory({
contentType: COC_CONTENT_TYPES.CUSTOMER,
conditions: nameEqualsConditions2,
});

await cronJobs.createActivityLogsFromSegments();

expect(await ActivityLogs.find().count()).toBe(2);
});
});
Loading

0 comments on commit c6ba36f

Please sign in to comment.