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

#164798023 Implement follow and unfollow feature #58

Merged
merged 14 commits into from
Apr 8, 2019

Conversation

amaechi-chuks
Copy link
Contributor

Description

This PR keep tabs of users following each other and by extension the articles they author.

Type of change

  • New feature

How Has This Been Tested?

  • unit testing
  • Hit this callback endpoint http://localhost:6000/api/v1/follow/:followeeId and received a response Successfully followed user from the server
  • Hit the callback endpoint http://localhost:6000/api/v1/follow/unFolloweeId and received a response successfully unfollowed a user

Checklist:

  • create controller functions(callback and redirect)
  • write mock test using chai and mocha
  • implement validations

PT-ID

164798023

Screenshots

follow a user
image

unfollow a user
image

Background

N/A

@@ -0,0 +1,165 @@
import chai, { expect } from 'chai';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@@ -0,0 +1,118 @@
import model from '../models';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@@ -0,0 +1,18 @@
import express from 'express';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

…into feature/164798023-follow-unfollow-user
Copy link
Contributor

@rotimi-babalola rotimi-babalola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, let's try to have JSDocs for each function also explaining the difference between follower and followee it's a bit confusing to understand what's happening

.filter(
followed =>
followed.follower_id === followerId &&
followed.followee_id === followeeId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a more meaningful variable name in the map function. Also what is the meaning of the variable userFollowing? @amaechi-chuks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable userFollowing is a validation that checks for follower and followee in the database.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable userFollowing is a validation that checks for follower and followee in the database.

Can you describe what the variable is going to contain? Is it an object or array? And what will be its content(s)? @amaechi-chuks

…into feature/164798023-follow-unfollow-user
- use more descriptive variable name
- update test cases
- update create controller functions(callback and redirect)
[Finishes #164798023]
@Akinmyde Akinmyde temporarily deployed to hermes-ah-backend-stagin-pr-58 April 6, 2019 22:17 Inactive
done();
});
});
it('It should return a 200 status code if user unfollow successfully', done => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected parentheses around arrow function argument having a body with curly braces arrow-parens

done();
});
});
it('lgoin a user', done => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected parentheses around arrow function argument having a body with curly braces arrow-parens

});
});
describe('TEST USER UNFOLLOW', () => {
it('Create a follower', done => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected parentheses around arrow function argument having a body with curly braces arrow-parens

done();
});
});
it('It should return a 406 if user try to follow him/herself', done => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected parentheses around arrow function argument having a body with curly braces arrow-parens

done();
});
});
it('It should return a 403 if user try to follow him/herself', done => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected parentheses around arrow function argument having a body with curly braces arrow-parens

});
});

it('It should return a 201 if a user is been followed successfully', done => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected parentheses around arrow function argument having a body with curly braces arrow-parens

done();
});
});
it('lgoin a user', done => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected parentheses around arrow function argument having a body with curly braces arrow-parens

let token2;
let token3;
describe('TEST USER FOLLOW', () => {
it('Create a follower', done => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected parentheses around arrow function argument having a body with curly braces arrow-parens

chai.use(chaiHttp);
let token1;
let token2;
let token3;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'token3' is assigned a value but never used no-unused-vars

* @param {followerId} person following the user
* @returns {object} response and user profile data
*/
async followUser(req, res) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing error: Unexpected token followUser

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you seen this? @amaechi-chuks

@rotimi-babalola rotimi-babalola merged commit cab11d4 into develop Apr 8, 2019
@rotimi-babalola rotimi-babalola deleted the feature/164798023-follow-unfollow-user branch April 8, 2019 12:11
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.

None yet

4 participants