Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ashton & Addie's VideoStoreAPI #17

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ff54822
initial rails setup
add2point71dots May 9, 2017
d8cf182
created models and controllers for movie and customer
add2point71dots May 9, 2017
3ccc5bc
customer validations and tests
add2point71dots May 9, 2017
392bcb5
added simplecov
add2point71dots May 9, 2017
05aa5bd
movie model validations and testing
add2point71dots May 9, 2017
f47b977
customer's account_credit must be a number
add2point71dots May 9, 2017
292b1e2
index method and tests for customers
add2point71dots May 9, 2017
d5b5b2b
added movies_checked_out_count to customer model as a required field …
add2point71dots May 9, 2017
e7a35f8
gives movies_checked_out_count data in customers show
add2point71dots May 9, 2017
3006e38
cleaned up code slightly
add2point71dots May 9, 2017
7fa0fa1
fixed confusing variable name
add2point71dots May 9, 2017
07ebb0b
changed constant name so it wasn't the same across different tests
add2point71dots May 9, 2017
bb157a9
movies index method and tests
add2point71dots May 9, 2017
0494237
movies show method and tests
add2point71dots May 9, 2017
b3a790f
added available_inventory as a field and set it to the inventory numb…
add2point71dots May 9, 2017
a78854f
validations and tests on available_inventory
add2point71dots May 9, 2017
4657fd7
made available_inventory available in movies show
add2point71dots May 9, 2017
4a46faa
adding erd.pdf/test pushing
ashtn May 10, 2017
e5a020b
updated customer and movie model
ashtn May 10, 2017
babc29c
adjusted movie tests to account for removed schema column
ashtn May 10, 2017
14dd978
adjusted customer model test to account for removed schema column
ashtn May 10, 2017
6de94ed
adjusted movies and customers controller to account for removed schem…
ashtn May 10, 2017
e03bf9d
added 3 rental routes
ashtn May 10, 2017
72a11e8
added rental model
ashtn May 10, 2017
8a1a9d3
added a column i forgot whoooops!
ashtn May 10, 2017
bd94fe3
added model tests for rental
ashtn May 10, 2017
cdaea5c
added available_inventory to model + tests, and check_out method rent…
ashtn May 10, 2017
d9aa2b2
added movie_checked_out_count model method + test
ashtn May 10, 2017
e709142
added test for find rentals by customer_id
ashtn May 10, 2017
240d59f
added custom methods to json output in controller
ashtn May 10, 2017
a67b6dc
created check out action method plus tests
ashtn May 12, 2017
7329c24
wrote check_in method
add2point71dots May 12, 2017
d68879d
tests for check_in for rentals controller
add2point71dots May 12, 2017
9f453b5
added over model method plus tests
ashtn May 12, 2017
9a2718f
deleted a space
add2point71dots May 12, 2017
508be02
re-added tests that got lost on github somehow
add2point71dots May 12, 2017
19a5327
added overdue controller method in rentals controller
ashtn May 12, 2017
bacc496
changed name of movies_checked_out_method
add2point71dots May 12, 2017
f379347
removed pseudo code
ashtn May 12, 2017
4a82001
added overdue rental controller tests
ashtn May 12, 2017
733923e
minor tweak to overdue edge case
ashtn May 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
index method and tests for customers
add2point71dots committed May 9, 2017
commit 292b1e23aa311884cb1f8d407de3af4afe227de6
4 changes: 4 additions & 0 deletions app/controllers/customers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
class CustomersController < ApplicationController
def index
customer = Customer.all
render json: customer.as_json(only: [:id, :name, :registered_at, :postal_code, :phone])
end
end
32 changes: 29 additions & 3 deletions test/controllers/customers_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
require "test_helper"

describe CustomersController do
# it "must be a real test" do
# flunk "Need real tests"
# end
KEYS = %w(id name phone postal_code registered_at)

describe "index" do
it "is a real working route" do
get customers_path
must_respond_with :success
end

it "returns json" do
get customers_path
response.header['Content-Type'].must_include 'json'
end

it "returns an Array of all the customers" do
get customers_path
body = JSON.parse(response.body)

body.must_be_kind_of Array
body.length.must_equal Customer.count
end

it "returns customers with exactly the required fields" do
get customers_path
body = JSON.parse(response.body)
body.each do |customer|
customer.keys.sort.must_equal KEYS
end
end
end
end