Kiera # Ana lisa - VideoStoreAPI - Octos#19
Kiera # Ana lisa - VideoStoreAPI - Octos#19Krashaune wants to merge 31 commits intoAda-C9:masterfrom
Conversation
…updated movies table with migrations.
…ity of index method.
Video StoreWhat We're Looking For
|
|
|
||
| new_rental = Rental.new(rental_params) | ||
| new_rental[:checkout] = date | ||
| new_rental[:due_date] = date + 7 |
There was a problem hiding this comment.
You should take all of the logic in this controller action and encapsulate it in a model method. Perhaps something like Movie#checkout(customer_id). You could have it raise an exception if there's not enough inventory available, or implement a custom validation on the rental.
| if rental.checked_in | ||
| render json: { | ||
| errors: { | ||
| checked_in: ["Movie has not been checked out."] |
There was a problem hiding this comment.
I like that you're checking for this
|
|
||
| validates :name, presence: true | ||
| validates :phone, presence: true | ||
| validates :phone, length: { is: 14 } |
There was a problem hiding this comment.
You might be over-validating here. Your app probably won't break if the customer's phone number isn't right, so validating it (and testing the validation, and making your tests provide the phone number in the right format) is more trouble than it's worth.
There was a problem hiding this comment.
Same thing goes for many of your model validations.
|
|
||
| it "returns an error for an invalid movie" do | ||
| bad_data = @movie_data.clone() | ||
| bad_data.delete(:title) |
There was a problem hiding this comment.
Good job catching this error case!
| require "test_helper" | ||
|
|
||
| describe CustomersController do | ||
| describe 'index' do |
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