You will need:
- git
- docker-compose & docker
-
git clone git@github.com:emmahyde/customer-vehicles.git
-
cd customer-vehicles
-
docker-compose build
-
docker-compose run web rails db:setup
Follow above instructions and then execute:
docker-compose run web rspec
Follow Setup instructions and then execute:
docker-compose up -d
The server is now running on localhost:3000
.
Load the schema in your local Postman app,
Or view it on a static site.
There are some clear opportunities for improvement here.
- The
Vehicle
association makes DB queries that could be removed if a cache layer was implemented, or we could eager-load the associations in. - More sort options for
Customers
, sort options at all forVehicles
. - Expand the primary-vehicle functionality: right now the primary
Vehicle
is only ever set the first time aVehicle
is created for aCustomer
. The intention here is to leave it very easily extendable, and the best way to do that is to support an association right off the bat, making some progress towards decouplingCustomers
andVehicles
.- Add more fine-grain control around the response to the client, for instance, listing all
Vehicles
associated with aCustomer
. Since this API does support a1:many
relationship here, this would be very simple. The reason theprimary
functionality was added was in order to implement the initial requirement of sortCustomers
onvehicle_type
(where someVehicle
must be the "default"), but implementing these two concepts as separate models leaves the door open to extendability down the line.
- Add more fine-grain control around the response to the client, for instance, listing all
- Better deletion practices: As of right now we could end up with bad data since we are not explicitly deleting
Vehicle
associations upon destroying the parentCustomer
. - It isn't necessarily DRY, it could be better abstracted, but for ease of digestion I wanted to leave it pretty friendly.
- Further awareness of edge cases and coverage on error handling, but as of right now it has 98.26% test coverage.
See code coverage report at https://emmahyde.github.io/customer-vehicles.
╰─❯ docker-compose run web rspec
Creating outdoorsy_web_run ... done
..............................
Finished in 3.22 seconds (files took 1.87 seconds to load)
30 examples, 0 failures
Coverage report generated for RSpec to /app/coverage. 395 / 402 LOC (98.26%) covered.