Note: This task should take no longer than 1-2 hours at the most to complete.
-
Please note that this will require some basic Ruby on Rails and RSpec knowledge.
-
You will need to have Ruby on Rails installed to complete this task.
- Fork this repository
- Create directory challenge
- In the challenge directory, scaffold a simple Rails 5 or above web app that models a credit card charge. JSON data structure below:
{
"id",
"created",
"paid",
"amount",
"currency",
"refunded",
"customer_id"
}
*Note: Amount is in USD, cents*
- Also scaffold a customer object which only has a first and last name.
The charge object has a customer property, this property is the customer id from the customer model.
10 Should be paid charges:
- 5 Should be linked to Customer 1
- 3 Should be linked to Customer 2
- 1 Should be linked to Customer 3
- 1 Should be linked to Customer 4
5 Should be charges that refunded:
- 3 Should be linked to Customer 3
- 2 Should be linked to Customer 4
On the controller that shows all charges (most likely the GET /charges route), return a json list as follows.
"data": { "paid": [ { "id": 111, "customer_name": 'customer 1' } ], "refunded": [ { "id": 111, "customer_name": 'customer 2' } ] }
Create the following RSpec tests:
- Verify that in the Paid charges list there are 10 line items. Verify that in the refunded charges list there are 5 failed charges.
- Commit and Push your code to your new repository
- Send us a pull request, we will review your code and get back to you