Coder Social home page Coder Social logo

rails_app_to_refactor's Introduction

README

This Rails app has been intentionally designed in a way that there are areas for improvement.

It's your mission to find this places and refactor them.

Requirements to run the app

  • Ruby version: 3.2.0

  • Database: sqlite3

How to setup this app

bin/setup

Table of Contents

Useful commands

  • bin/rails test - it will run the test suite.

  • bin/rails rubycritic - it will generate a quality report of this codebase.

Examples of cURL requests to interact with the API

First, run the application:

bin/rails s

Then, use some of the following commands to interact with the API resources:

Users

Add new user

curl -X POST "http://localhost:3000/users" \
  -H "Content-Type: application/json" \
  -d '{"user":{"name": "Serradura", "email": "[email protected]", "password": "123456", "password_confirmation": "123456"}}'

Display user

curl -X GET "http://localhost:3000/user" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

Delete user

curl -X DELETE "http://localhost:3000/user" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

To-Do Lists

Add new to-do list

curl -X POST "http://localhost:3000/todos_lists" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN" \
  -d '{"todo":{"title": "Things to learn"}}'

Display to-do list

curl -X GET "http://localhost:3000/todos_lists/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

Display all to-do lists

curl -X GET "http://localhost:3000/todo_lists" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

This resource accepts the following query strings:

  • sort_by (e.g, 'updated_at')
  • order (e.g, 'asc')

PS: Desc is the default order.

Example:

curl -X GET "http://localhost:3000/todo_lists?sort_by=title" -H "Content-Type: application/json" -H "Authorization: Bearer SOME-USER-TOKEN"

Edit to-do list

curl -X PUT "http://localhost:3000/todo_lists/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN" \
  -d '{"todo":{"title": "Things to learn"}}'

Remove to-do list

curl -X DELETE "http://localhost:3000/todo_lists/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

To-Dos

Add new to-do

Default list
curl -X POST "http://localhost:3000/todos" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN" \
  -d '{"todo":{"title": "Buy coffee"}}'
In a list
curl -X POST "http://localhost:3000/todo_lists/1/todos" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN" \
  -d '{"todo":{"title": "Buy coffee"}}'

Display to-do

Default list
curl -X GET "http://localhost:3000/todos/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"
From a list
curl -X GET "http://localhost:3000/todo_lists/1/todos/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

Display all to-dos

This resource accepts the following query strings:

  • status (e.g, 'completed')
  • sort_by (e.g, 'updated_at')
  • order (e.g, 'asc')

PS: Desc is the default order.

Example:

curl -X GET "http://localhost:3000/todos?status=&sort_by=&order="
  -H "Content-Type: application/json"
  -H "Authorization: Bearer SOME-USER-TOKEN"

The available statuses to filter are: overdue, completed, incomplete.

From a list
curl -X GET "http://localhost:3000/todo_lists/1/todos/1?status=&sort_by=&order=" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

Edit to-do

Modify the content of the item.

curl -X PUT "http://localhost:3000/todos/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN" \
  -d '{"todo":{"title": "Buy milk"}}'

Todo params:

  • title: string required.
  • completed: boolean optional.
In a list
curl -X PUT "http://localhost:3000/todo_lists/1/todos/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN" \
  -d '{"todo":{"title": "Buy milk"}}'

Mark to-do as completed

Change the status to 'completed'.

curl -X PUT "http://localhost:3000/todos/1/complete" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"
In a list
curl -X PUT "http://localhost:3000/todo_lists/1/todos/1/complete" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

Mark to-do as incomplete

Change the status to 'incomplete'.

curl -X PUT "http://localhost:3000/todos/1/incomplete" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"
In a list
curl -X PUT "http://localhost:3000/todo_lists/1/todos/1/incomplete" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

Remove to-do

The item will be permanently deleted from the list

curl -X DELETE "http://localhost:3000/todos/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"
From a list
curl -X DELETE "http://localhost:3000/todo_lists/1/todos/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer SOME-USER-TOKEN"

rails_app_to_refactor's People

Contributors

serradura avatar vinibispo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.