-
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
Anne & Dikla - VideoStoreApi - Octos #2
base: master
Are you sure you want to change the base?
Conversation
generated customer model
…movie_id on rental
…ues upon creation
Video StoreWhat We're Looking For
|
def check_in | ||
|
||
rental = Rental.find_by(rental_params) | ||
if rental.save |
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 haven't changed the rental - why are you saving it here?
rental = Rental.find_by(rental_params) | ||
if rental.save | ||
rental.movie.increase_available_inventory | ||
rental.customer.decrease_movies_checked_out_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.
All of this work could be wrapped up in one method, maybe something like Rental.check_in
if rental.save | ||
rental.movie.reduce_available_inventory | ||
puts rental.customer.movies_checked_out_count | ||
rental.customer.increase_movies_checked_out_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.
Doing all this work should be in one method in the model. Maybe even something like Movie#check_out(customer_id)
|
||
it "creates a new customer" do | ||
before_customer_count = Customer.count | ||
post customers_url, params: { customer: customer_data } |
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.
What about if the customer data is bad?
describe "decrease_movies_checked_out_count" do | ||
it "decrease_movies_checked_out_count" do | ||
@customer = Customer.create( | ||
name: "Movie Watcher", |
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.
What if the movies_checked_out_count
is currently 0?
describe "reduce_available_inventory" do | ||
it "reduce_available_inventory" do | ||
@movie = Movie.create( | ||
title: "test movie", |
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.
What if available_inventory is already at the total inventory?
describe "increase_available_inventory" do | ||
it "increase_available_inventory" do | ||
@movie = Movie.create( | ||
title: "test movie", |
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.
What if available_inventory is already 0?
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