Skip to content

juancu8/api-rsepc

Repository files navigation

README

Description

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.

Resources

Comands && Requeriments

  • 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)

Check with Postman

    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!"
        }
    }

Send mail with letter_opener

    rails c
  • Letter opener
    PostReportMailer.post_report(user, post, report).deliver_now
  • Send by job
    PostReportJob.perform_later(User.first.id, Post.first.id)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published