You will need:
- git
- docker-compose & docker
-
git clone [email protected]: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 rspecFollow Setup instructions and then execute:
docker-compose up -dThe 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
Vehicleassociation 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
Vehicleis only ever set the first time aVehicleis 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 decouplingCustomersandVehicles.- Add more fine-grain control around the response to the client, for instance, listing all
Vehiclesassociated with aCustomer. Since this API does support a1:manyrelationship here, this would be very simple. The reason theprimaryfunctionality was added was in order to implement the initial requirement of sortCustomersonvehicle_type(where someVehiclemust 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
Vehicleassociations 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.