-
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
Ampers - Abinnet + Lily #16
base: master
Are you sure you want to change the base?
Conversation
…alidations added; tests need work
… model tests pass
…valid info from yml
…movie model...test failed then passing
…entory; available_inventory works
… with new column set to 0
…ated tests failed then passing
…to send more requests for invalid rentals and confirm movie can be rented
…is code does not test anything in update action
…r method for rental to pass new test
… to confirm video can be renturned
…oprorted customer rental count changed into controller update and create...still needs tests for this new functionality
Video StoreWhat We're Looking For
Seeding doesn't seem to work for me? Running The methods on Same goes for the def self.increment(movie)
if movie.available_inventory < movie.inventory
movie.available_inventory += 1
movie.save
end
end and def increment
if self.available_inventory < self.inventory
self.available_inventory += 1
self.save
end
end Let me know if you can't figure out the answer to this question/the difference between self/class and instance methods. It's pretty important that you can distinguish why an instance method is more appropriate for this In rental_movie = Movie.returnable_movie?(Movie.find_by(id: params[:movie_id])) You're using what's in That method def self.rentable_movie?(id)
movie = Movie.find_by(id: id)
if movie.available_inventory < 1
movie = false
end
return movie
end You're taking in an "id" and then finding an instance of movie with that id Try to stay consistent-- you're doing redundant work here That being said, I'm pleased that the smoke tests all pass. |
rental = Rental.new(rental_data) | ||
end | ||
|
||
if movie && 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 just checked for movie
's truthiness a line above, maybe there's a way to refactor this logic?
render json: {id: rental.id}, status: :ok | ||
else | ||
if rental.nil? | ||
"no available_inventory for 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 is this line doing?
…be updated, also update fixtures with more specific names
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