The main goal of this project is built a API following TDD methodology principles.
- Add a test
- Run all tests and fails
- Write code
- Run tests
- Refactor
- Repeat
Users have posts.
Serializer our post to provide for author information and control our json objects.
Authentication (Auth token).
Create services for search and generate token.
Make Healt point.
ActiveJob & ActiveMailer.
-
Ruby version 2.5.0
-
If want testing can use Postman
- Install gems
bundle install
- Runing Rspec
bundle exec rspec
- Runing specific test
bundle exec rspec spec/requests/posts_spec.rb:line_number
- BDD
rake db:create
rake db:migrate
- If want test FactoryBot by console
RAILS_ENV=test rails c
FactoryBot.build(:post)
rails s
-
check Healt point: localhost:3000/health
-
Set BBDD
rake db:seed
End points:
-
GET localhost:3000/posts -> return all posts
-
POST localhost:3000/posts -> return unauthorized without header || return created post if set Bearer auth_token on headers
{
"post": {
"title": "titulo",
"content": "content",
"published": true
}
}
- PUT localhost:3000/posts/{post.id} -> return update post (200)
{
"post": {
"title": "Hi!"
}
}
rails c
- Letter opener
PostReportMailer.post_report(user, post, report).deliver_now
- Send by job
PostReportJob.perform_later(User.first.id, Post.first.id)