Conversation
made new empty api app
baseline with test route
added gems needed for testing and error views
generated models for movies and customers
Modify models
Model tests
Add controllers
Bt update rentals test
added some tests
wrote controller action for rental create and updated tests
updated tests and controller logic
Rental logic inventory
Update rental controller test
Update customer custom method
WIP overdue action in rental controller
… due date of next available movie
Sandbox overdue
Video StoreWhat We're Looking For
|
bbbriana
left a comment
There was a problem hiding this comment.
Overall great job! I didn't find any glaring issues or anything, keep up the great work 💯
| validates :title, presence: true | ||
| validates :overview, presence: true | ||
| validates :release_date, presence: true, format: { with: /\A\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\z/, message: "must be in YYYY-MM-DD format" } | ||
| validates :inventory, presence: true, numericality: { only_integer: true, greater_than: 0} |
There was a problem hiding this comment.
Really great job with the validations!
| if movie.available_inventory <= 0 | ||
| rentals = Rental.where(movie_id: movie.id) | ||
| earliest = rentals.min_by { |rental| rental.due_date} | ||
| errors.add(:availability, "Sorry, this movie is not in stock. One is due back on #{earliest.due_date}") |
There was a problem hiding this comment.
Noting the earliest due date is a nice touch 👍
| @@ -0,0 +1,146 @@ | |||
| require "test_helper" | |||
There was a problem hiding this comment.
Yay tests! I dig how thorough these ones are 🎉
|
|
||
| one: | ||
| title: Titanic | ||
| overview: ship disaster |
| overdue_rentals = [] | ||
| customer_ids.each do |id| | ||
| customer = Customer.find_by_id(id) | ||
| hash = Hash.new |
There was a problem hiding this comment.
For consistency you could do {} (since you do [] for a new array)...but this is me completely nitpicking bc you did such a great job 😁
| end | ||
|
|
||
| def overdue | ||
| #what is the syntax for a conditional for due date? |
| end | ||
|
|
||
| def valid_due_date | ||
| if due_date.class != Date |
There was a problem hiding this comment.
How do you take in the due date? Would checking if the due date is too far in the future (like if I tried to check something out for 2183721983 years) be necessary?
|
|
||
| # Ignore Byebug command history file. | ||
| .byebug_history | ||
| /coverage/ |
There was a problem hiding this comment.
Could also ignore that pesky .DS_Store
|
|
||
|
|
||
| # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | ||
| gem 'rails', '~> 5.0.2' |
There was a problem hiding this comment.
Ohhh that's why some of this looks weird to me, shiny new rails! ✨ (we used 4.2)
|
|
||
| def check_inventory | ||
| if movie | ||
| if movie.available_inventory <= 0 |
There was a problem hiding this comment.
Would the avail inventory ever go below 0?
rpavilanis
left a comment
There was a problem hiding this comment.
Fantastic job - it looks like you both went above and beyond the requirements and learned a lot about building an API. nice work. :)
|
|
||
|
|
||
| # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | ||
| gem 'rails', '~> 5.0.2' |
| # Windows does not include zoneinfo files, so bundle the tzinfo-data gem | ||
| gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] | ||
|
|
||
| group :development do |
There was a problem hiding this comment.
It looks like you have two 'group :development do' sections - you could combine them to clean up the Gemfile.
|
|
||
| # update later after adding rental | ||
| def movies_checked_out_count | ||
| return rentals.where(returned: false).length |
There was a problem hiding this comment.
Nice job pulling out business logic into models. Good work on being thorough with validations.
| value(response).must_be :success? | ||
| end | ||
|
|
||
| end |
There was a problem hiding this comment.
Wow, I can tell that you really put a lot of time into writing thorough tests. Nice job testing edge cases as well.
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