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.
-
Ruby version:
3.2.0
-
Database:
sqlite3
bin/setup
- Requirements to run the app
- How to setup this app
- Table of Contents
- Useful commands
- Examples of cURL requests to interact with the API
-
bin/rails test
- it will run the test suite. -
bin/rails rubycritic
- it will generate a quality report of this codebase.
First, run the application:
bin/rails s
Then, use some of the following commands to interact with the API resources:
curl -X POST "http://localhost:3000/users" \
-H "Content-Type: application/json" \
-d '{"user":{"name": "Serradura", "email": "serradura@example.com", "password": "123456", "password_confirmation": "123456"}}'
curl -X GET "http://localhost:3000/user" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"
curl -X DELETE "http://localhost:3000/user" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"
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"}}'
curl -X GET "http://localhost:3000/todos_lists/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"
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"
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"}}'
curl -X DELETE "http://localhost:3000/todo_lists/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"
curl -X POST "http://localhost:3000/todos" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN" \
-d '{"todo":{"title": "Buy coffee"}}'
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"}}'
curl -X GET "http://localhost:3000/todos/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"
curl -X GET "http://localhost:3000/todo_lists/1/todos/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"
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
.
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"
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
.
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"}}'
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"
curl -X PUT "http://localhost:3000/todo_lists/1/todos/1/complete" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"
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"
curl -X PUT "http://localhost:3000/todo_lists/1/todos/1/incomplete" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"
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"
curl -X DELETE "http://localhost:3000/todo_lists/1/todos/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SOME-USER-TOKEN"