Skip to content

Conversation

@winirarrazaval
Copy link

Video Store API

Congratulations! You're submitting your assignment!
If you didn't get to the functionality the question is asking about, reply with what you would have done if you had completed it.

Comprehension Questions

Question Answer
Explain how you came up with the design of your ERD, based on the seed data. We made a class for each file , and gave each class the attributes from the seed data. And we wrote the rest of the ERD based on the rest of the requirements.
Describe a set of positive and negative test cases you implemented for a model. In the rental model test we checked that a rental could not be made if in that date range all movie copies are already rented. If there are enough copies on the available inventory then a rental can be made.
Describe a set of positive and negative test cases you implemented for a controller. In the rental controller test we test that the checkin action can be made for a valid movie and customer id and that the rentals return date is set to today. The negative test case, the check in action responds with not found for movie ID and customer ID that DNE.
How does your API respond when bad data is sent to it? It responds with not found when trying to perform an action on a record that does not exist. It responds with bad request when trying to create a new record with data that does not pass the validations.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. In the movie model we created get_available_inventory method to get the current number of available copies of a movie to be able to create a rental.
Do you have any recommendations on how we could improve this project for the next cohort? Make the instructions for postman (smoketest) more clear/demo it in class.
Link to Trello https://trello.com/b/Tu0XuJto/ride-share
Link to ERD https://www.lucidchart.com/invitations/accept/d16d45a0-3afa-41f9-8e0d-bae5892139c1

winirarrazaval and others added 27 commits May 7, 2018 12:13
@droberts-sea
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
Business Logic in Models some - Your RentalsController has a lot of business logic still.
All required endpoints return expected JSON data yes
Requests respond with appropriate HTTP Status Code yes
Errors are reported yes
Testing
Passes all Smoke Tests yes
Model Tests - all relations, validations, and custom functions test positive & negative cases tests for many custom methods are missing, but otherwise looks good.
Controller Tests - URI parameters and data in the request body have positive & negative cases yes - great work!
Overall Good work overall!


if rental.save
customer = Customer.find_by(id: customer_id)
customer.movies_checked_out_count += 1

Choose a reason for hiding this comment

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

All of this work around assigning dates, decreasing movies_checked_out_count, etc. should be encapsulated in one testable model method.

if rental.save
customer = Customer.find_by(id: rental.customer_id)
customer.movies_checked_out_count -= 1
customer.save

Choose a reason for hiding this comment

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

Similarly, all this work ought to be wrapped up in one model method.

def checkin
rental = Rental.find_by(movie_id: params[:movie_id], customer_id: params[:customer_id])

unless rental

Choose a reason for hiding this comment

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

What if this rental has already been returned?

def get_available_inventory
checked_out_count = 0
self.rentals.each do |rental|
if rental.return_date.nil?

Choose a reason for hiding this comment

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

I like that you calculate this on the fly rather than saving it in the DB.

def enough_inventory_for_rent
if movie
count = 0
self.movie.rentals.each do |rent|

Choose a reason for hiding this comment

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

How does this validation interact with returning movies?


it "must respond with bad_request for a movie with no available inventory" do
movie = Movie.first
customer = Customer.first

Choose a reason for hiding this comment

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

Nice!


it "must respond with not_found for a rental that DNE" do

movie_id = Movie.last.id + 1

Choose a reason for hiding this comment

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

What if the rental has already been checked in


end

describe "relationships" do

Choose a reason for hiding this comment

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

There are some custom methods you're not testing here.


it "a rental can not be completed if all copies are rented for a date range" do
movie = Movie.first
customer = Customer.first

Choose a reason for hiding this comment

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

Good work getting a test in on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants