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

Caroline & Luxi - VideoStoreAPI - Octos #9

Open
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

Lindseyls
Copy link

@Lindseyls Lindseyls commented May 11, 2018

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 created the ERD based on the seed data for customer and movies to store the information provided in the seed data. The rental model was created based on the API Description such as the requirements for check-out and check-in.
Describe a set of positive and negative test cases you implemented for a model. Specifically for the movies validation tests, we tested to see that a movie can be created when valid information was provided. Then for the negative test cases, we checked to see that a movie can't be created when invalid information was provided. Such as, negative inventory and nil values for the title, overview, and release date.
Describe a set of positive and negative test cases you implemented for a controller. Specifically for the rentals controller test on the checkout method, we tested that the movie and customer ids were properly provided through json. We returned error messages and not found response if the movie or customer ids were not provided, or the movie was not available, or the customer had already checked out the movie.
How does your API respond when bad data is sent to it? It provides an error message and a not found or bad request depending on the bad data.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We created a custom model method for Rental to find a existing checked out rental by passing through the movie id and customer id in the parameter. We made this a custom method because we used it in both in the check-in and check-out methods in the controller.
Do you have any recommendations on how we could improve this project for the next cohort? No, we thoroughly enjoyed working together to take what we learned in class and created our own API.
Link to Trello https://trello.com/b/TjrCOIOk/videostoreapi
Link to ERD https://www.lucidchart.com/invitations/accept/a073a9af-8bf7-4640-8755-fd8c091f222b

Lindseyls and others added 30 commits May 7, 2018 12:30
…ckout method. Also, created the routes for rentals
…movie id's. Updated the check_in method in rental_controller.rb to update movie and customer inventory when the movie is checked back in
…hat we created for customer and movie. We updated the customer model with a new method for movies checked out count. Then, we updated the testing for both customer and movie models
…ated the testing for rental.rb and started the testing for the rentals controller
validates :phone, presence: true

def movies_checked_out_count
checked_out_count = Rental.where(customer_id: self.id, check_in: nil).count

Choose a reason for hiding this comment

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

You should be able to determine this using self.rentals rather than going through Rental.where

validates :inventory, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }

def available_inventory
checked_out_count = Rental.where(movie_id: self.id, check_in: nil).count

Choose a reason for hiding this comment

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

Same comment re: going through self.rentals rather than Rental.where


describe CustomersController do
describe "index" do
it "gets all the customers" do

Choose a reason for hiding this comment

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

It might be good to verify that this works when there are lots of customers as well as no customers

@@ -0,0 +1,72 @@
class RentalsController < ApplicationController

RENTAL_LIMIT = 7 #days

Choose a reason for hiding this comment

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

This should really be a part of the model, not the controller.

def check_out
rental = Rental.new(rental_params)
rental.check_out = DateTime.now
rental.due_date = rental.check_out + RENTAL_LIMIT

Choose a reason for hiding this comment

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

Moving the rental constant would probably also lead to moving this logic in the model as well

@kariabancroft
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene Good
Comprehension questions Yes
General
Business Logic in Models Yes, some
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 Yes, nice job
Controller Tests - URI parameters and data in the request body have positive & negative cases Yes, nice job
Overall You did a nice job with the test coverage on this assignment. Overall you hit the major goals, nice job.

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