Anne & Dikla - VideoStoreApi - Octos #2
Open
diklaaharoni wants to merge 70 commits intoAda-C9:masterfrom
Open
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.
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.
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.
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.
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.
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.
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.
What if available_inventory is already 0?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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