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

Alena & Aurora VideoStoreAPI #18

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c81b0b2
initial rails setup
Spatterjaaay May 9, 2017
440373e
created movie and customer models
Spatterjaaay May 9, 2017
a5ae7f9
created test structure for models
Spatterjaaay May 9, 2017
4026896
pseudocoded routes
auroralemieux May 9, 2017
9d4e42b
added simplecov
auroralemieux May 9, 2017
b6fe999
added column to customers
auroralemieux May 9, 2017
ade5867
added model fixtures
auroralemieux May 9, 2017
88947cb
created movies controller, added route for zomg action and added zomg…
Spatterjaaay May 9, 2017
e7c6c3b
added tests for customer validations
Spatterjaaay May 9, 2017
72b597e
fixed one failing test
Spatterjaaay May 9, 2017
b968b21
Merge pull request #1 from Spatterjaaay/am/model-testing
Spatterjaaay May 9, 2017
e5e4bf2
all model validations tests passing
auroralemieux May 9, 2017
e382857
added some validations for customer model
auroralemieux May 9, 2017
775cc35
created controller for customers, added tests for movies index
Spatterjaaay May 9, 2017
f65fcfe
added test for customers index action
Spatterjaaay May 9, 2017
48815da
all movie controller show tests passing
auroralemieux May 9, 2017
a151344
added error message for json returned when no movie found with that t…
auroralemieux May 10, 2017
4a02069
added the error for title not found and no movies found
auroralemieux May 10, 2017
c075624
added default for available inventory, added rentals model and counte…
auroralemieux May 10, 2017
cde70e1
created tests for rentals model
Spatterjaaay May 10, 2017
a4c4bf5
Merge pull request #2 from Spatterjaaay/am/rentals-model-testing
Spatterjaaay May 10, 2017
14b7024
created routes for rentals
Spatterjaaay May 10, 2017
88109e4
created rentals controller, added index, create and update actions wi…
Spatterjaaay May 10, 2017
08f5142
fixed tests
Spatterjaaay May 11, 2017
3ea78a3
added column to rentals with boolean for returned or not
auroralemieux May 11, 2017
b8e0def
stubbed out tests for rentals controller
auroralemieux May 11, 2017
959ff6c
added method to rentals to get ovedue rentals and then in rentals con…
Spatterjaaay May 12, 2017
04e74e1
added json to index action in rentals controller
Spatterjaaay May 12, 2017
0bc4d2b
some spaces. oops.
auroralemieux May 12, 2017
0db8155
fixing merge conflict
auroralemieux May 12, 2017
70dc5eb
wrote method to convert the customers into the hash format we wanted
auroralemieux May 12, 2017
d9547e4
rentals controller index method tests written and passing
auroralemieux May 12, 2017
9c98f8b
wrote tests for model method list_of_rentals
auroralemieux May 12, 2017
9fa1018
added create action to rentals controller, and added duedate is not i…
Spatterjaaay May 12, 2017
88a1f0c
added check to create action that it send error if movie not found, m…
Spatterjaaay May 12, 2017
826ea51
create test passing
auroralemieux May 12, 2017
3beb019
got the darn test to pass
auroralemieux May 13, 2017
aff51c8
all checkout tests written and passing
auroralemieux May 13, 2017
05f3b04
added erd
auroralemieux May 13, 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
added test for customers index action
Spatterjaaay committed May 9, 2017
commit f65fcfed4cf86277ff13e1405213161469bee360
2 changes: 1 addition & 1 deletion app/controllers/customers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CustomersController < ApplicationController
def index
customers = Customer.all
render json: customers.as_json(only: [:name, :registered_at, :postal_code, :phone, :movies_checked_out_count]), status: :ok
render json: customers.as_json(only: [:id, :name, :registered_at, :postal_code, :phone, :movies_checked_out_count]), status: :ok
end
end
5 changes: 5 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -2,4 +2,9 @@ class MoviesController < ApplicationController
def zomg
render json: {hungry: "It works"}
end

def index
movies = Movie.all
render json: movies.as_json(except: [:created_at, :updated_at, :id]), status: :ok
end
end
26 changes: 24 additions & 2 deletions test/controllers/customers_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
require "test_helper"

describe CustomersController do
KEYS = %w(movies_checked_out_count name phone postal_code registered_at)
KEYS = %w(id movies_checked_out_count name phone postal_code registered_at)

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

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

it "returns an array" do
get customers_path
body = JSON.parse(response.body)
body.must_be_kind_of Array
end

it "returns all the customers" do
get customers_path
body = JSON.parse(response.body)
body.length.must_equal Customer.count
end

it "returns customers with exactly the required fields" do
get customers_path
must_respond_with :success
body = JSON.parse(response.body)
2 changes: 1 addition & 1 deletion test/controllers/movies_controller_test.rb
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@

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

it "returns movies with exactly the required fields" do