@dmarcoux/t
Pre-interview Task
Rails 5 JSON API for users and their tasks. Each user has different needs regarding privacy, maintenance schedules and security. To respect this, each user has a database for his/her tasks. As for users, they are stored in a single database.
- Install Docker and Docker-Compose (Tested on Linux with versions
17.10.0-ce
and1.17.0
respectively) - Copy the environment file with
cp .env.example .env
- Copy the secrets file with
cp config/secrets.yml.example config/secrets.yml
- Start the application with
docker-compose up development
(If you get the errorPG::ConnectionBad: could not connect to server: Connection refused
, run it again as sometimes the database isn't ready in time for the application) - Access it at
localhost:3000
(The port is the value of$RAILS_PORT
from the file.env
)- Create a user:
curl --verbose --header "Content-Type: application/json" --data '{ "user": {"email":"[email protected]","password":"'12345'"} }' localhost:3000/users
- Login with the user:
curl --verbose --header "Content-Type: application/json" --data '{ "auth": {"email":"[email protected]","password":"'12345'"} }' localhost:3000/user_token
- Create a task for the user:
curl --verbose --header "Authorization: Bearer TOKEN_FROM_LOGIN_REQUEST" --header "Content-Type: application/json" --data '{ "task": { "start":"2017-11-16T16:28:54+01:00", "end":"2017-11-16T17:28:54+01:00", "description":"Something" } }' localhost:3000/tasks
- List tasks of the user:
curl --verbose --header "Authorization: Bearer TOKEN_FROM_LOGIN_REQUEST" localhost:3000/tasks
- Start the development environment with
docker-compose run --service-ports development bash
- Run specs/tests with: TODO
- Run code style checks with:
rubocop