Skip to content

Commit

Permalink
ft 164489793 user nofication settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Harerimana authored and Frank Harerimana committed Apr 30, 2019
1 parent c785941 commit a6abeb3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
8 changes: 8 additions & 0 deletions migrations/20190403114111-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ module.exports = {
type: Sequelize.BOOLEAN,
defaultValue: false
},
inapp_notifications: {
type: Sequelize.BOOLEAN,
defaultValue: true
},
email_notifications: {
type: Sequelize.BOOLEAN,
defaultValue: true
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
Expand Down
4 changes: 3 additions & 1 deletion models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const UserModel = (Sequelize, DataTypes) => {
},
provider: { type: DataTypes.STRING, allowNull: true, defaultValue: '' },
provideruserid: { type: DataTypes.STRING, allowNull: true, },
verified: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false }
verified: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
inapp_notifications: { type: DataTypes.BOOLEAN, defaultValue: true },
email_notifications: { type: DataTypes.BOOLEAN, defaultValue: true }
});
User.socialUsers = async (userProfile) => {
const result = await User.findOrCreate({
Expand Down
19 changes: 9 additions & 10 deletions test/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ describe('Test the body', () => {
title: faker.random.words(),
description: faker.lorem.paragraph(),
body: '',
authorid: 100
};
chai.request(index).post('/api/articles').send(newArticle).set('x-access-token', `${userToken}`)
.then((res) => {
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error').eql('The body can\'t be empty');
res.body.should.have.property('error').eql('body can not be null');
done();
})
.catch(error => logError(error));
Expand All @@ -113,10 +112,9 @@ describe('Test the body', () => {
describe('Test the title', () => {
it('should substring a long title to only 40 characters', (done) => {
const longTitleArticle = {
title: faker.lorem.sentences(),
title: faker.lorem.words(),
body: faker.lorem.paragraphs(),
description: faker.lorem.paragraph(),
authorid: 100
};
chai.request(index).post('/api/articles').send(longTitleArticle).set('x-access-token', `${userToken}`)
.then((res) => {
Expand All @@ -135,12 +133,13 @@ describe('Test description', () => {
authorid: 100
};
it('should provide a description if not provided', (done) => {
chai.request(index).post('/api/articles').send(newArticle).then((res) => {
res.should.have.status(201);
res.body.should.have.property('article');
res.body.article.should.have.property('description');
done();
})
chai.request(index).post('/api/articles').send(newArticle).set('x-access-token', `${userToken}`)
.then((res) => {
res.should.have.status(201);
res.body.should.have.property('article');
res.body.article.should.have.property('description');
done();
})
.catch(error => error);
});
});
Expand Down

0 comments on commit a6abeb3

Please sign in to comment.