Conversation
added tests for movies#show and movies#create
Video StoreWhat We're Looking For
|
| customer = Customer.find_by(id: params[:id]) | ||
|
|
||
| if customer | ||
| render status: :ok, json: customer.as_json(only: [:id, :name, :registered_at, :postal_code, :phone, :movies_checked_out_count]) |
There was a problem hiding this comment.
Small style note: not all text editors wrap lines for you. This line is so long that on GitHub I have to scroll horizontally to see all the pieces. You can make this easier to read by putting a newline after any given comma in a statement.
| movie.available_inventory -= 1 | ||
| end | ||
|
|
||
| if rental.save |
There was a problem hiding this comment.
You have a bunch of business logic here! Would it be possible to encapsulate this in a model method? Something like
rental.check_out(customer_id, movie_id)
might be a good interface. That would make this logic easier to test as well.
You're not optimizing for lines of code, you're optimizing for a process that is easy to test and easy to read, and when you mix from different pots like this, both are compromised.
| it "still returns JSON if ID is invalid" do | ||
| get customer_path(-1) | ||
| expect(response.header["Content-Type"]).must_include "json" | ||
| end |
There was a problem hiding this comment.
doesn't look like you check the fields!
| it 'should get the correct path with query title' do | ||
| assert_recognizes({ controller: 'movies', action: 'index', sort: 'title' }, '/movies', sort: 'title') | ||
|
|
||
| get movies_path, params: { sort: 'title' } |
There was a problem hiding this comment.
is it an array? are the fields correct?
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
POST /rentals/check-inendpoint? What does the time complexity depend on? Explain your reasoning.Summary |