- Overview
- Learning Goals
- Installation and Database Setup
- Schema
- Testing
- Endpoints
- Gems Utilized
- Future Improvements
- Contributor
Rails Engine is a fictitious E-Commerce application intended showcase the developer's ability to create a consumable API that can be utilized by an accompanying front-end application.
- Expose an API
- Use serializers to format JSON responses
- Test API exposure
- Compose advanced ActiveRecord queries to analyze information stored in SQL databases
- Write basic SQL statements without the assistance of an ORM
% git clone [email protected]:PhilipDeFraties/rails-engine.git
% cd rails-engine
% bundle install
% rails db:{create,migrate,seed}
The program was developed through strict Test-Driven Development, utilizing RSpec for integration and unit testing. Simplecov was used to monitor test coverage. At the time of writing, test coverage is at 100%. To run the test suite and see a coverage report enter the following commands into your terminal:
% bundle exec rspec
% open coverage/index.html
The program is also tested via a mock front-end application, Rails Driver,
with its own test suite to test the rails-engine's endpoints externally. To
run the front-end program's test suite, first run % rails s
in your
terminal, then open a new tab in your terminal (cmd+t) and enter the following
commands:
% git clone [email protected]:turingschool-examples/rails_driver.git
% bundle exec rspec spec/features/harness_spec.rb
All tests should be passing.
-
All merchants: GET http://localhost:3000/api/v1/merchants
-
Show a merchant: GET http://localhost:3000/api/v1/merchants/:id
-
Create new merchant: POST http://localhost:3000/api/v1/merchants
-
Update a merchant: PATCH http://localhost:3000/api/v1/merchants/:id
-
Delete a merchant: DELETE http://localhost:3000/api/v1/merchants/:id
-
All items: GET http://localhost:3000/api/v1/items
-
Show an item: GET http://localhost:3000/api/v1/items/:id
-
Create an item: POST http://localhost:3000/api/v1/items
-
Update an item: PATCH http://localhost:3000/api/v1/items/:id
-
Destroy an item: DELETE http://localhost:3000/api/v1/items/:id
- All items belonging to merchant: GET /api/v1/merchants/:id/items
- Item's merchant GET /api/v1/items/:id/merchants
Items and Merchants can be searched by any attributes, is case insensitive and will return partial matches
-
Items search single result: GET /api/v1/items/find?=
-
Items search list of results: GET /api/v1/items/find_all?=
-
Merchants search single result: GET /api/v1/merchants/find?=
-
Merchants search list of results: GET /api/v1/merchants/find_all?=
-
Merchants ranked by revenue with specified quantity of results: GET /api/v1/merchants/most_items?quantity=
-
Total revenue for a single merchant: GET /api/v1/merchants/:id/revenue
-
Merchants ranked by total items sold with specified quantity of results: GET /api/v1/merchants/most_items?quantity=
-
Total revenue generated by all merchants across specified date range: GET /api/v1/revenue?start=<start_date>&end=<end_date>
- gem 'factory_bot_rails'
- gem 'faker'
- gem 'pry'
- gem 'fast_jsonapi'
- gem 'rspec-rails'
- gem 'capybara'
- gem 'shoulda-matchers'
- gem 'launchy'
- gem 'simplecov'
- gem 'webmock'
- gem 'vcr'
- gem 'activerecord-import'
-
Some sad paths were taken into account and tested, such as searching for an item or merchant with an undefined parameter or blank value, however no sad path has been created for an empty search result, or incompatible values entered for crud functions.
-
Currently, the search endpoints all use the same method shared by the application_record, and the only difference between a multi search and a single search is that the results for a single search come back with all matches and are reduced to the first by a ruby method in the controller. This is not ideal as it places extra strain on the database by retrieving un-needed data. Further refactoring would entail making separate single and multi finders specific to merchants and items.