-
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
Kiera # Ana lisa - VideoStoreAPI - Octos #19
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job catching this error case!
require "test_helper" | ||
|
||
describe CustomersController do | ||
describe 'index' 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.
What about show
and create
?
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