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

#159987711 users should be able to follow each other #33

Merged

Conversation

GodswillOnuoha
Copy link
Contributor

What does this PR do?

implement CRUD functionalities of user-follow feature

Description of Task to be completed?

create user-follow model
unit test user-follow model
add create user-follow endpoint
add get all followers endpoint
add get all followings endpoint
add unfollow endpoint
unit test user-follow endpoints

How should this be manually tested?

Run 'npm install'
create a .env using the .env.sample template
Run 'npm run migrate'
Run 'npm run start:dev'
use postman to test:
post: /api/users/follow, get: /api/users/followers, get: /api/users/followings
and delete: /api/users/unfollow endpoints

What are the relevant pivotal tracker stories?

#159987711

- add unit test for user-follow model
- add unit tests for user-follow endpoints
- add follow a user endpoint
- add get all followings endpoint
- add get all followers endpoint
- add unfollow user endpoint

[Finishes #159987711
checkModelName,
checkPropertyExists
} from 'sequelize-test-helpers';
import userFollowModel from '../../models/userFollow';

Choose a reason for hiding this comment

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

Missing file extension for "../../models/userFollow" import/extensions

dataTypes,
checkModelName,
checkPropertyExists
} from 'sequelize-test-helpers';

Choose a reason for hiding this comment

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

Missing file extension for "sequelize-test-helpers" import/extensions

@@ -0,0 +1,28 @@
import chai from 'chai';
import chaiHttp from 'chai-http';

Choose a reason for hiding this comment

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

Missing file extension for "chai-http" import/extensions

@@ -0,0 +1,28 @@
import chai from 'chai';

Choose a reason for hiding this comment

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

Missing file extension for "chai" import/extensions

@@ -1,2 +1,3 @@
import './user.model.test';
import './article';
import './userFollow';

Choose a reason for hiding this comment

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

Missing file extension for "./userFollow" import/extensions

@@ -2,6 +2,7 @@ import { Router } from 'express';
import articlesRouter from './articles';

import userRoutes from './users';
import userFollowRoutes from './userFollows';

Choose a reason for hiding this comment

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

Missing file extension for "./userFollows" import/extensions

}
});
},
down: (queryInterface, Sequelize) => {

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
Unexpected block statement surrounding arrow body; move the returned value immediately after the => arrow-body-style

@@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {

Choose a reason for hiding this comment

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

Unexpected block statement surrounding arrow body; move the returned value immediately after the => arrow-body-style

@@ -0,0 +1,30 @@
'use strict';

Choose a reason for hiding this comment

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

Expected newline after "use strict" directive lines-around-directive
'use strict' is unnecessary inside of modules strict

@@ -0,0 +1,156 @@
import db from '../models';

Choose a reason for hiding this comment

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

Missing file extension for "../models" import/extensions

@coveralls
Copy link

coveralls commented Sep 7, 2018

Pull Request Test Coverage Report for Build 234

  • 127 of 128 (99.22%) changed or added relevant lines in 15 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+3.8%) to 93.146%

Changes Missing Coverage Covered Lines Changed/Added Lines %
server/controllers/userFollows.js 25 26 96.15%
Totals Coverage Status
Change from base Build 224: 3.8%
Covered Lines: 932
Relevant Lines: 979

💛 - Coveralls

- add unit test for user-follow model
- add unit tests for user-follow endpoints
- add follow a user endpoint
- add get all followings endpoint
- add get all followers endpoint
- add unfollow user endpoint

[Finishes #159987711
@GodswillOnuoha GodswillOnuoha force-pushed the ft-Users-should-be-able-to-follow-each-other-159987711 branch 3 times, most recently from 17bd9b0 to 1fadf04 Compare September 7, 2018 17:34
- change SECRET to JWT_KEY in email verification

[#159987711]
@GodswillOnuoha GodswillOnuoha force-pushed the ft-Users-should-be-able-to-follow-each-other-159987711 branch from 1fadf04 to 099782e Compare September 7, 2018 18:22
@emmaadesile
Copy link
Contributor

LGTM

Copy link
Contributor

@emekafredy emekafredy left a comment

Choose a reason for hiding this comment

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

LGTM


/**
* @static
* @param {reuest} req
Copy link
Contributor

Choose a reason for hiding this comment

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

On line 62, I believe this should be @param {object} req or whatever datatype you think you are dealing with for that parameter. Check also for line 86.

if (!user) {
return res.status(404).json({
errors: {
message: 'User you are not following this user',
Copy link
Contributor

Choose a reason for hiding this comment

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

On line 62, The message should be 'You are not following this user'

@aknwosu aknwosu merged commit 100baaf into develop Sep 7, 2018
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

6 participants