-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#166841020 Users should be able to like articles #36
Conversation
src/routes/userRoute.js
Outdated
router.put('/profiles/:id', | ||
verify, upload.single('avatar'), | ||
profileChecker, | ||
UserController.updateProfile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected a newline before ')' function-paren-newline
src/routes/userRoute.js
Outdated
verify, | ||
UserController.getUserProfile); | ||
|
||
router.put('/profiles/:id', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected a newline after '(' function-paren-newline
src/routes/userRoute.js
Outdated
|
||
router.get('/profiles/:userName', | ||
verify, | ||
UserController.getUserProfile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected a newline before ')' function-paren-newline
src/routes/userRoute.js
Outdated
|
||
const router = express.Router(); | ||
|
||
router.get('/profiles/:userName', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected a newline after '(' function-paren-newline
|
||
router.post('/articles/:slug/like', | ||
verify, | ||
LikeController.likeArticle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected a newline before ')' function-paren-newline
|
||
const router = express.Router(); | ||
|
||
router.post('/articles/:slug/like', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected a newline after '(' function-paren-newline
src/db/models/blacklist.js
Outdated
@@ -8,7 +8,7 @@ module.exports = (sequelize, DataTypes) => { | |||
defaultValue: true | |||
}, | |||
}, {}); | |||
Blacklist.associate = function(models) { | |||
Blacklist.associate = (models) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'models' is defined but never used no-unused-vars
type: Sequelize.DATE | ||
} | ||
}), | ||
down: (queryInterface, Sequelize) => queryInterface.dropTable('Likes'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Sequelize' is defined but never used no-unused-vars
down: (queryInterface, Sequelize) => { | ||
return queryInterface.dropTable('Blacklists'); | ||
} | ||
down: (queryInterface, Sequelize) => queryInterface.dropTable('Blacklists'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Sequelize' is defined but never used no-unused-vars
9af244b
to
b80c479
Compare
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP') | ||
} | ||
}), | ||
down: (queryInterface, Sequelize) => queryInterface.dropTable('Tags') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Sequelize' is defined but never used no-unused-vars
b80c479
to
bf4e151
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that you have squashed your commits into two. Nice job @phembarl
bf4e151
to
7516c99
Compare
test/like.test.js
Outdated
chai.request(app).post('/api/v1/auth/login') | ||
.send(user) | ||
.end((err, res) => { | ||
token = res.body.token; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use object destructuring prefer-destructuring
test/like.test.js
Outdated
chai.request(app).post('/api/v1/auth/login') | ||
.send(user) | ||
.end((err, res) => { | ||
token = res.body.token; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use object destructuring prefer-destructuring
test/auth.test.js
Outdated
@@ -40,6 +40,7 @@ describe('Auth', () => { | |||
chai.request(app).post('/api/v1/auth/signup') | |||
.send(defaultUser) | |||
.end((err, res) => { | |||
console.log(res.body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected console statement no-console
7516c99
to
5fc120b
Compare
test/like.test.js
Outdated
chai.request(app).post('/api/v1/auth/login') | ||
.send(user) | ||
.end((err, res) => { | ||
token = res.body.token; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use object destructuring prefer-destructuring
test/like.test.js
Outdated
}); | ||
}); | ||
|
||
it('should not return the right error message', (done) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by it should not return the right error message
src/controllers/likeController.js
Outdated
const userId = req.user; | ||
|
||
try { | ||
const article = await Article.findOne({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please move the aspect of finding if an article exists or not to a middleware. This middleware should be reusable. Also, confirm that it doesn't already exist in our codebase
5fc120b
to
23cf8c4
Compare
23cf8c4
to
00226af
Compare
00226af
to
2ab5fc7
Compare
test/like.test.js
Outdated
chai.request(app).post('/api/v1/articles/article/like') | ||
.set('token', testToken) | ||
.end((err, res) => { | ||
console.log(res.body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected console statement no-console
test/like.test.js
Outdated
chai.request(app).post('/api/v1/articles/article/like') | ||
.set('token', testToken) | ||
.end((err, res) => { | ||
console.log(res.body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected console statement no-console
2ab5fc7
to
5871ed9
Compare
5871ed9
to
a71b4ba
Compare
src/controllers/likeController.js
Outdated
* @memberof LikeController | ||
*/ | ||
static async likeArticle(req, res) { | ||
const { slug } = req.params; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'slug' is assigned a value but never used no-unused-vars
src/controllers/likeController.js
Outdated
@@ -0,0 +1,56 @@ | |||
import { Article, Like } from '../db/models'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Article' is defined but never used no-unused-vars
…er to like an article - [Finishes #166841020] feature(likes): user should be able to like an article - enables a user to like an article - [Finishes #166841020]
a71b4ba
to
1d96613
Compare
What does this PR do?
Description of Task to be completed?
API
endpoint that enables a user to make aPOST
request to like an articleHow should this be manually tested?
POST
request to the following address:localhost:3000/api/v1/articles/<slug>/like
Any background context you want to provide?
What are the relevant pivotal tracker stories?
Screenshots (if appropriate)
Questions: