-
Notifications
You must be signed in to change notification settings - Fork 25
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
base: master
Are you sure you want to change the base?
Conversation
…d updated the testing for each method
…ated customers_controller_test.rb
…ckout method. Also, created the routes for rentals
…em to Gemfile but did not install
…te rental model validation tests
…d movie and customer validations
…mer business logic methods
…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
…oller to display available inventory
…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
… rental controller
…rental#checkout controller method
validates :phone, presence: true | ||
|
||
def movies_checked_out_count | ||
checked_out_count = Rental.where(customer_id: self.id, check_in: nil).count |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Video StoreWhat We're Looking For
|
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