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

#161290903 CRUD operations for articles #13

Merged
merged 1 commit into from
Nov 5, 2018

Conversation

hope-uwa
Copy link
Contributor

@hope-uwa hope-uwa commented Nov 1, 2018

What does this PR do?

  • Allows any user to view all articles and specific articles
  • Allows authenticated users to view, create, edit and delete articles

Description of Task to be completed?

  • created migration and model for articles with associations
  • wrote validations for request.body of articles.
  • wrote test with 100% coverage of article controller branches
  • installed slug dependency package and created a set function to merge user uuid and title slug
  • GET api/v1/articles unprotected - it fetches all published articles
  • GET api/v1/articles/drafts protected - it fetches all drafts by the authenticated user
  • GET api/v1/users/articles protected - it fetches all published article by the authenticated user
  • GET api/v1/articles/:slug unprotected - it fetches an article with slug parameter
  • POST api/v1/articles protected - it creates an article
  • PUT api/v1/articles/:slug/publish protected - it allows only author to publish article.
  • PUT api/v1/articles/:slug protected - it allows authors to edit their articles whether published or draft
  • DELETE api/v1/articles/:slug protected - it allows authors to delete their own articles.

How should this be manually tested?

  • clone this repository
  • run npm install on command line
  • create postgres database
  • create .env file
  • set up environment variables using the sample on .envsample file
  • Run npm run dev on command/shell
  • Using postman test the endpoint with prefix- localhost:3000

Any background context you want to provide?

  • Some of the endpoints are protected so you will need to sign up with users/register

What are the relevant pivotal tracker stories?

#161290903

Screenshots (if appropriate)

Questions:

queryInterface.bulkInsert('Article', mockArticle, {});
},

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

import mockArticle from '../../helpers/seedData/articles.json';

export default {
up: (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


},

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

export default {
up: (queryInterface, Sequelize) => { queryInterface.bulkInsert('User', [], {});

},

Choose a reason for hiding this comment

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

Block must not be padded by blank lines padded-blocks


export default {
up: (queryInterface, Sequelize) => { queryInterface.bulkInsert('User', [], {});

Choose a reason for hiding this comment

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

Trailing spaces not allowed no-trailing-spaces

import mockUser from '../../helpers/seedData/users.json';

export default {
up: (queryInterface, Sequelize) => { queryInterface.bulkInsert('User', [], {});

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
Statement inside of curly braces should be on next line brace-style

@@ -0,0 +1,17 @@
import mockUser from '../../helpers/seedData/users.json';

Choose a reason for hiding this comment

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

'mockUser' is defined but never used no-unused-vars

[Op.like]: `%${articleId}`
}
}
})

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

message: 'Unauthorized'
});
}
Article.update({

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

@coveralls
Copy link

coveralls commented Nov 1, 2018

Pull Request Test Coverage Report for Build 152

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 84.472%

Totals Coverage Status
Change from base Build 150: 0.0%
Covered Lines: 752
Relevant Lines: 823

💛 - Coveralls

@hope-uwa hope-uwa force-pushed the feature/161290903/CRUD-operations-for-articles branch from 0fa7e2f to 709f33a Compare November 1, 2018 12:52
[Op.like]: `%${articleId}`
}
}
}).then(() => {

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

@hope-uwa hope-uwa force-pushed the feature/161290903/CRUD-operations-for-articles branch 4 times, most recently from abac953 to 3b0ded7 Compare November 1, 2018 16:04
@hope-uwa hope-uwa changed the title Feature/161290903/crud operations for articles #161290903 CRUD operations for articles Nov 2, 2018
@hope-uwa hope-uwa force-pushed the feature/161290903/CRUD-operations-for-articles branch from 3b0ded7 to b3f7918 Compare November 2, 2018 09:41
@desaawa
Copy link
Contributor

desaawa commented Nov 5, 2018

@uwaelpis Please resolve the conflicts here.

@hope-uwa hope-uwa force-pushed the feature/161290903/CRUD-operations-for-articles branch 2 times, most recently from e18986b to 7a6bce5 Compare November 5, 2018 14:16
            - Write test for endpoints
            - Implemented relationship in model and migration
            - Validationhelpers for articles inputs
            - Create article functionalities
            - Update article functionalities
            - Read article functionalities
            - Delete article functionality

            [Finishes #161290903]
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.

8 participants