-
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
Ari/Brenda- Octos- VideoApiMuncher #20
base: master
Are you sure you want to change the base?
Conversation
… for movie and customer.
Video StoreWhat We're Looking For
|
|
||
# TODO: To make this happen automatically | ||
def checkout | ||
@rental = Rental.new(rental_params) |
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.
Since you're not rendering views, you shouldn't need instance variables in your controllers.
self.due_date= (self.checkout_date + 7) | ||
end | ||
|
||
def build_rental |
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.
Nice job switching these from class methods to instance methods per our conversation
new_inventory = self.movie.available_inventory -= 1 | ||
customer_movie_count = self.customer.movies_checked_out_count += 1 | ||
|
||
self.update_attribute(:checked_out, true) |
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.
When you're updating a single property, it is more overhead than necessary to use update_attribute
. You should just set the property directly self.checked_out = true
.
require "test_helper" | ||
|
||
describe Movie do | ||
let(:movie) { Movie.new } |
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.
Looks like you aren't ever using this. While it is in a let
block that will be lazy loaded, you still shouldn't have it if it never used.
|
||
describe Rental do | ||
describe 'relations' do | ||
let(:rental1) { rentals(:rental1) } |
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.
Also looks like you're not using this variable
end | ||
end | ||
describe 'validations' do | ||
it "must be a valid rental" 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.
Will it be valid without a due date?
@@ -0,0 +1,120 @@ | |||
require "test_helper" | |||
|
|||
describe MoviesController 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.
Watch your indentation here
end | ||
|
||
it "gets index with no movies" do | ||
Movie.all.each { |movie| movie.destroy } |
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 can also use destroy_all
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