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

#165174100 Edit-Delete article #28

Merged
merged 1 commit into from
Apr 11, 2019
Merged

Conversation

itsgratien
Copy link
Contributor

@itsgratien itsgratien commented Apr 9, 2019

What does this PR do?

update and delete articles

Description of Task to be completed?

this PR allows a user to edit/update his article and delete an article. user who is allowed to update or delete article is the one who created an article and must be authenticated.
This PR also has the following endpoints:

  • PUT /api/articles/:articleId
  • DELETE /api/articles/:articleId
  • GET /api/articles/:articleId (get single article)

How should this be manually tested?

  • open your postman
  • in your URL, update article http://localhost:3000/api/articles/1
  • makesure that form is set to form-data
  • for example in your form must have
    {'title':'article1', 'body':'this article body' , 'tag':'programming,nodejs', 'image':'image.jpg'}
  • then run

Screenshoots

Screen Shot 2019-04-11 at 12 05 21

What are the relevant pivotal tracker stories?

165174100

@itsgratien itsgratien added the WIP label Apr 9, 2019
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 11:05 Inactive
@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 21ecb89 to 98e12f8 Compare April 9, 2019 11:56
router.put('/:articleId', auth, checkingArticle,multer, Article.updateArticle);
// @Method Delete
// @desc deleting articles
router.delete('/:articleId', auth, checkingArticle,Article.deleteArticle);

Choose a reason for hiding this comment

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

A space is required after ',' comma-spacing

@@ -11,5 +12,11 @@ router.post('/', auth, multer, Article.create);
// @Method GET
// @Desc get all created article
router.get('/', Article.getArticle);
// @Method PUT
// @Desc update articles
router.put('/:articleId', auth, checkingArticle,multer, Article.updateArticle);

Choose a reason for hiding this comment

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

A space is required after ',' comma-spacing

@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 11:56 Inactive
@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 98e12f8 to cdd337a Compare April 9, 2019 11:58
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 11:59 Inactive
@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from cdd337a to f3b294b Compare April 9, 2019 14:23
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 14:23 Inactive
@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from f3b294b to 7590b3c Compare April 9, 2019 14:41
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 14:41 Inactive
@@ -58,6 +58,7 @@ class UserController {
};
return User.findOne({ where: { email: user.email } })
.then((foundUser) => {
console.log('found user',foundUser);

Choose a reason for hiding this comment

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

A space is required after ',' comma-spacing

@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 7590b3c to 59cb933 Compare April 9, 2019 15:21
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 15:21 Inactive

chai.use(chaiHttp);
chai.should();
const Article = models.article;

Choose a reason for hiding this comment

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

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

@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 59cb933 to 42028be Compare April 9, 2019 15:33
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 15:33 Inactive
res.should.have.status(403);
done();
})
});

Choose a reason for hiding this comment

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

Expected indentation of 2 spaces but found 0 indent

}
res.should.have.status(403);
done();
})

Choose a reason for hiding this comment

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

Expected indentation of 6 spaces but found 2 indent
Missing semicolon semi

done(error);
}
res.should.have.status(403);
done();

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 4 indent

if(error){
done(error);
}
res.should.have.status(403);

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 4 indent

.end((error,res)=>{
if(error){
done(error);
}

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 4 indent

});
//@delete article
it("should return status code of 403 on deleting article",(done)=>{
chai.request(app)

Choose a reason for hiding this comment

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

Expected indentation of 4 spaces but found 2 indent

})
});
//@delete article
it("should return status code of 403 on deleting article",(done)=>{

Choose a reason for hiding this comment

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

A space is required after ',' comma-spacing
Expected indentation of 2 spaces but found 1 indent
Missing space after => arrow-spacing
Missing space before => arrow-spacing
Strings must use singlequote quotes

done();
})
});
//@delete article

Choose a reason for hiding this comment

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

Expected exception block, space or tab after '//' in comment spaced-comment
Expected indentation of 2 spaces but found 1 indent

res.should.have.status(404);
done();
})
});

Choose a reason for hiding this comment

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

Expected indentation of 2 spaces but found 1 indent

}
res.should.have.status(404);
done();
})

Choose a reason for hiding this comment

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

Expected indentation of 6 spaces but found 4 indent
Missing semicolon semi

@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 42028be to 5d94268 Compare April 9, 2019 15:47
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 15:47 Inactive
@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 5d94268 to 2119436 Compare April 9, 2019 15:51
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 9, 2019 15:52 Inactive
@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch 3 times, most recently from e57abef to 8b4843d Compare April 10, 2019 08:07
@@ -11,5 +12,14 @@ router.post('/', auth, multer, Article.create);
// @Method GET
// @Desc get all created article
router.get('/', Article.getArticle);
//@Method GET
//@desc get single article
router.get('/:articleId',Article.singleArticle);

Choose a reason for hiding this comment

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

A space is required after ',' comma-spacing

@@ -11,5 +12,14 @@ router.post('/', auth, multer, Article.create);
// @Method GET
// @Desc get all created article
router.get('/', Article.getArticle);
//@Method GET
//@desc get single article

Choose a reason for hiding this comment

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

Expected exception block, space or tab after '//' in comment spaced-comment

@@ -11,5 +12,14 @@ router.post('/', auth, multer, Article.create);
// @Method GET
// @Desc get all created article
router.get('/', Article.getArticle);
//@Method GET

Choose a reason for hiding this comment

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

Expected exception block, space or tab after '//' in comment spaced-comment

@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 10, 2019 08:07 Inactive
@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 8b4843d to 9a230fa Compare April 10, 2019 08:20
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 10, 2019 08:20 Inactive
@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 9a230fa to 0b09b12 Compare April 10, 2019 08:46
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 10, 2019 08:46 Inactive
@Paccy10
Copy link

Paccy10 commented Apr 10, 2019

@itsgracian your commit message is not following the conventions

@blaisebakundukize
Copy link
Contributor

@itsgracian, I like the way you handled your tasks. But it would be better if you change your commit message because it does not follow our convention.

@itsgratien
Copy link
Contributor Author

cool, let me change it

@itsgratien itsgratien force-pushed the ft-editUpdateArticles-165174100 branch from 0b09b12 to c0b1b85 Compare April 10, 2019 10:53
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-28 April 10, 2019 10:53 Inactive
 - it has PUT method (/api/articles/:articleId)
 - GET Method viewing single article (/api/articles/:articleId)
 - DELETE Method delete article (/api/articles/:articleId)

 [Delivers #165174100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants