Skip to content
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

Merged
merged 1 commit into from
Jul 15, 2019

Conversation

phembarl
Copy link
Contributor

@phembarl phembarl commented Jul 9, 2019

What does this PR do?

  • Enables a user to like and unlike articles

Description of Task to be completed?

  • Create likes table
  • Create API endpoint that enables a user to make a POST request to like an article

How should this be manually tested?

  • After running your server, make an API POST request to the following address: localhost:3000/api/v1/articles/<slug>/like

Any background context you want to provide?

  • N/A

What are the relevant pivotal tracker stories?

Screenshots (if appropriate)

  • N/A

Questions:

  • N/A

router.put('/profiles/:id',
verify, upload.single('avatar'),
profileChecker,
UserController.updateProfile);
Copy link

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

verify,
UserController.getUserProfile);

router.put('/profiles/:id',
Copy link

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.get('/profiles/:userName',
verify,
UserController.getUserProfile);
Copy link

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.get('/profiles/:userName',
Copy link

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);
Copy link

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',
Copy link

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

@@ -8,7 +8,7 @@ module.exports = (sequelize, DataTypes) => {
defaultValue: true
},
}, {});
Blacklist.associate = function(models) {
Blacklist.associate = (models) => {
Copy link

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'),
Copy link

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'),
Copy link

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 9, 2019 19:41 Inactive
@phembarl phembarl force-pushed the ft-like-articles-166841020 branch from 9af244b to b80c479 Compare July 9, 2019 19:57
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
}
}),
down: (queryInterface, Sequelize) => queryInterface.dropTable('Tags')
Copy link

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 9, 2019 19:57 Inactive
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 10, 2019 11:47 Inactive
Copy link
Contributor

@codeBlock-1984 codeBlock-1984 left a 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

chai.request(app).post('/api/v1/auth/login')
.send(user)
.end((err, res) => {
token = res.body.token;
Copy link

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

chai.request(app).post('/api/v1/auth/login')
.send(user)
.end((err, res) => {
token = res.body.token;
Copy link

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

@@ -40,6 +40,7 @@ describe('Auth', () => {
chai.request(app).post('/api/v1/auth/signup')
.send(defaultUser)
.end((err, res) => {
console.log(res.body);
Copy link

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 11, 2019 18:23 Inactive
chai.request(app).post('/api/v1/auth/login')
.send(user)
.end((err, res) => {
token = res.body.token;
Copy link

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 11, 2019 20:09 Inactive
});
});

it('should not return the right error message', (done) => {
Copy link
Contributor

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

const userId = req.user;

try {
const article = await Article.findOne({
Copy link
Contributor

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 12, 2019 08:21 Inactive
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 15, 2019 09:54 Inactive
chai.request(app).post('/api/v1/articles/article/like')
.set('token', testToken)
.end((err, res) => {
console.log(res.body);
Copy link

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

chai.request(app).post('/api/v1/articles/article/like')
.set('token', testToken)
.end((err, res) => {
console.log(res.body);
Copy link

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 15, 2019 10:18 Inactive
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 15, 2019 10:29 Inactive
* @memberof LikeController
*/
static async likeArticle(req, res) {
const { slug } = req.params;
Copy link

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

@@ -0,0 +1,56 @@
import { Article, Like } from '../db/models';
Copy link

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-36 July 15, 2019 11:02 Inactive
…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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants