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

Video Store API - Jess & Adriana #9

Open
wants to merge 99 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
a11a00f
created routes files, pseudocode and lib file
jweeber Jun 14, 2016
991bd14
pseudocoded all the routes. ALL OF THEM
jweeber Jun 14, 2016
9e4894d
semicolon destructiongit add .
jweeber Jun 14, 2016
36c5ab2
completed /zomg route, json is successful
jweeber Jun 14, 2016
da05488
Added an images folder and inside put our ERD
dri19tcc Jun 14, 2016
f8ba0ae
Added massive dependencies, added extra scripts for our database
dri19tcc Jun 14, 2016
2c42d48
added load_schema with all database tables and what they will need. …
dri19tcc Jun 14, 2016
32edfb7
route for customers index created
jweeber Jun 15, 2016
cf26e91
movies index route created
jweeber Jun 15, 2016
9fc335b
added rentals/:title route
jweeber Jun 15, 2016
b9741f8
Added seeding data into database, changed schema for rentals to text,…
dri19tcc Jun 15, 2016
769fbe8
Trying to get data to customers page
dri19tcc Jun 16, 2016
01145b5
Added in controllers and customers to get json data as the output
dri19tcc Jun 16, 2016
8d3924c
getting all customers working
jweeber Jun 16, 2016
d44c8ac
moved customer.all function to model and rendered json data from cont…
jweeber Jun 16, 2016
5821a8d
added first fucking test for customers controller and it is PASSING
jweeber Jun 16, 2016
e238cae
added two more passing tests weeee
jweeber Jun 16, 2016
b194f8b
Added a show page for just one customer
dri19tcc Jun 16, 2016
a53ef69
Added in a sort by function that can sort by different fields, and ad…
dri19tcc Jun 16, 2016
aa21741
cleaned up code
dri19tcc Jun 16, 2016
a8d7a0a
get /movies working to retrieve all movies. routes created for /:id a…
jweeber Jun 17, 2016
84501a7
model and controller methods for find and sort working for movies.
jweeber Jun 17, 2016
05f7e0a
three tests for movies done and passing
jweeber Jun 17, 2016
dcd0b51
test for finding a movie based on title written and passing
jweeber Jun 17, 2016
db04330
minor movies test revision to use var for title and remove magic string
jweeber Jun 17, 2016
1a848f6
Added in more tests for customers. Added a negative test for giving …
dri19tcc Jun 17, 2016
2205615
Added in negative tests for movies and for customers
dri19tcc Jun 17, 2016
e7f12f1
Took out lower level error
dri19tcc Jun 17, 2016
78b0ef5
added movie_id to schema
jweeber Jun 17, 2016
529da05
find all movies that can be rented works. find rentals by title now w…
jweeber Jun 17, 2016
47c9e4f
changed schema
dri19tcc Jun 17, 2016
63a2dc8
Added in controller testing
dri19tcc Jun 17, 2016
65ad737
Added in controller testing for rentals for show page
dri19tcc Jun 17, 2016
5bdd0d2
Added customer testing for show page
dri19tcc Jun 17, 2016
ff1ca1a
Cleaned up customers controller page
dri19tcc Jun 17, 2016
5d34cc3
Added jasmine-testing so errors will show
dri19tcc Jun 18, 2016
05e2ced
Added rental tests
dri19tcc Jun 18, 2016
b04c9e9
Have all passing tests for all controllers and functions and all mode…
dri19tcc Jun 18, 2016
440cae3
added temporary seed data to test customer routes for current checked…
jweeber Jun 20, 2016
955c5d9
findRentals method in model retrieving rentals data from temp seeded …
jweeber Jun 20, 2016
42f00a0
rental history for customers working with temp seed data
jweeber Jun 20, 2016
2dee49d
created sql file for inner joining rentals, movies, customers. return…
jweeber Jun 20, 2016
cc8267f
trying to get current movies out
dri19tcc Jun 20, 2016
ef51688
Debugging movies rental history
dri19tcc Jun 20, 2016
fdeb7ce
one customer showing up for current rentals.
jweeber Jun 20, 2016
3d331b7
finally got list of customers who currently have specific movie check…
jweeber Jun 20, 2016
eb7550b
Added a checkout date column for rentals
dri19tcc Jun 20, 2016
6d405c5
Cleaned up code
dri19tcc Jun 21, 2016
e1880ae
Added controller testing and adding coverage to git ignore
dri19tcc Jun 21, 2016
fd5b67c
Added model testing
dri19tcc Jun 21, 2016
51fbee5
writing tests for rentals, working on negative tests
jweeber Jun 21, 2016
d474782
Added negative tests
dri19tcc Jun 21, 2016
675cbb0
Cleaned up rental spec code, if using find, no callback error is given
dri19tcc Jun 21, 2016
0a0a408
working on get currently checked out movies customers
jweeber Jun 21, 2016
54b8a52
merging rentals model with removing error handling
jweeber Jun 21, 2016
64f37a0
Took out error handling because no errors passed when using the .find…
dri19tcc Jun 21, 2016
4d4b7e7
finished tests for rentals model so far
jweeber Jun 21, 2016
99b79af
Merge branch 'master' of github.com:jweeber/VideoStoreAPI
dri19tcc Jun 21, 2016
4651ad4
finished tests for customer model
jweeber Jun 21, 2016
9e37fb4
Added more seeding data, added movies route
dri19tcc Jun 21, 2016
3724763
Added a new sql file to query customer rental history, added a new ro…
dri19tcc Jun 21, 2016
2911550
Added an index controller so route testing would be at 100%
dri19tcc Jun 22, 2016
3a665c2
Added current rentals and started on post
dri19tcc Jun 22, 2016
ffa61bc
Adding post route
dri19tcc Jun 22, 2016
2e9d342
Working on checkout posting data
dri19tcc Jun 22, 2016
5d5624f
post to checkout working. we fancy! saving to rentals database as che…
jweeber Jun 22, 2016
7c59385
Rental method for chekcout now successfully reducing inventory
jweeber Jun 22, 2016
5584486
return date calculates and saves to rental database
jweeber Jun 22, 2016
52fcae5
extracting logic from rental checkout method for reusability. added l…
jweeber Jun 23, 2016
3a5c9f3
added router for rental checkin, plus controller method and model met…
jweeber Jun 23, 2016
f035554
got error handling working for when inventory is less than 1
jweeber Jun 23, 2016
2678ec4
Added a find by id method
dri19tcc Jun 23, 2016
a189ac7
Added function to charge a customer 1.00 to rent out. Went into the …
dri19tcc Jun 23, 2016
2fc868d
Made put routes, and renamed functions as put
dri19tcc Jun 23, 2016
935a54c
Changed rental database to false and added to movie inventory when re…
dri19tcc Jun 23, 2016
d5d4db6
Added ; in sql query, renamed so functions matched
dri19tcc Jun 23, 2016
075bed0
made routes and started method for overdue
dri19tcc Jun 24, 2016
f6698f6
overdue rentals model working to return rentals, working on getting i…
jweeber Jun 24, 2016
2e0369e
Found a missing token
dri19tcc Jun 24, 2016
c166224
Added a sql file to join customers and rentals
dri19tcc Jun 24, 2016
2366743
Sql file is working, yay
dri19tcc Jun 24, 2016
e6a0e2e
Finished function to return customers that have late data
dri19tcc Jun 24, 2016
a330a7a
updating
dri19tcc Jun 24, 2016
9cd7d07
merging
jweeber Jun 24, 2016
adab1a0
merge conflict
jweeber Jun 24, 2016
2e97025
fixed customer rental history to order by checkout and show movies
jweeber Jun 24, 2016
50740f6
fixed current rentals by customer to show movies
jweeber Jun 24, 2016
417de7e
fixing sql for movie rental history showing customers
jweeber Jun 24, 2016
4092545
fixed overdue rentals to show info for customer and movies
jweeber Jun 24, 2016
6e8adf2
fixed tests after changing methods in rental model to use sql
jweeber Jun 24, 2016
bb39da2
don't know
dri19tcc Jun 24, 2016
5b51525
merge conflicts
dri19tcc Jun 24, 2016
04e0654
Added a new directory that will hold api json doc, started writing up…
dri19tcc Jun 24, 2016
90e9a3f
tried more tests for rentals. some are just not working out.
jweeber Jun 25, 2016
dcfe8e5
merging tests
jweeber Jun 25, 2016
79d1d86
got another test working so up to 90% coverage for models
jweeber Jun 25, 2016
a8a4603
cleaning up test file
jweeber Jun 25, 2016
32e4fb0
json docs
dri19tcc Jun 26, 2016
182a16b
merging
dri19tcc Jun 26, 2016
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
Empty file removed lib/customers.js
Empty file.
Empty file removed lib/movies.js
Empty file.
Empty file removed lib/rentals.js
Empty file.
14 changes: 2 additions & 12 deletions models/rental.js
Original file line number Diff line number Diff line change
@@ -2,17 +2,8 @@ var app = require('../app')
var db = app.get('db')
var Movie = require('./movie')
var Customer = require('./customer')
var Rental = require('./rental')

// var movieHistory = require('../db/rental_movie_history')

var Rental = function (rental) {
this.id = rental.id
this.customer_id = rental.customer_id
this.movie_id = rental.movie_id
this.status = rental.status
this.return_date = rental.return_date
}
var Rental = function () {}

Rental.all = function (callback) {
db.movies.find (function (error, movies) {
@@ -113,8 +104,7 @@ Rental.checkin = function (title, cust_id, callback) {
}

Rental.overdueRental = function (callback) {
db.overdue_rentals(function (error, customers, movies, rentals) {
console.log(customers)
db.overdue_rentals(function (error, customers) {
callback(null, customers.map (function (customer) {
return customer
}))
60 changes: 58 additions & 2 deletions spec/models/rental.spec.js
Original file line number Diff line number Diff line change
@@ -71,8 +71,6 @@ describe('Rental', function () {
describe("#findCurrent", function () {
it("should return current rentals for a customer", function (done) {
Rental.findCurrent(29, function (error, movie) {
console.log(movie)
expect(movie.length).toEqual(3)
expect(movie[0].id).toEqual(19)
done()
})
@@ -110,5 +108,63 @@ describe('Rental', function () {
})
})

describe("#findHistoryMovies", function () {
it("should return rental history for a movie", function (done) {
Rental.findHistoryMovies('Die Hard', function (error, rentals) {
expect(rentals.length).toEqual(2)
expect(rentals[0].id).toEqual(29)
done()
})
})

it('should throw an error if no rentals found', function (done) {
Rental.findHistoryMovies("bad title", function(error, movie) {
expect(error).toEqual(null)
done()
})
})
})

describe("#find_customers", function () {
it("should return customers who rented a given movie", function (done) {
Rental.find_customers('Die Hard', function (error, customers) {
expect(customers.length).toEqual(2)
expect(customers[0].id).toEqual(19)
done()
})
})

it('should throw an error if no customers found', function (done) {
Rental.findHistoryMovies("bad title", function(error, movie) {
expect(error).toEqual(null)
done()
})
})
})

describe("#checkout", function () {
it("should checkout correct movie and decrease movie inventory when checked out", function (done) {
var preStock;
Rental.find('Speed', function(error, movie) {
preStock = movie[0].inventory
})
Rental.checkout("Speed", 29, function(error, movie){})
Rental.find('Speed', function(error, movie) {
var postStock = movie[0].inventory
expect(movie[0].title).toEqual('Speed')
expect(postStock).toEqual(preStock - 1)
})
done()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job with the tests!!
For a cleaner code I would recommend you to be consistence when you choose to use variables. in line 153 you used var postStock = movie[0].inventory. So I would expect that next you'll have also variable for the movie[0].title.
Or that you just won't use the postStock, and use the raw data in the test.

But other then that - looks great!

})
})

describe("#overdueRental", function () {
it("should return list of customers with overdue rentals", function (done) {
Rental.overdueRental(function (error, customers) {
expect(customers.length).toEqual(2)
})
done()
})
})

})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your coverage is awesome!