Skip to content

Conversation

@marshi23
Copy link

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

Question Answer
Explain how you came up with the design of your ERD, based on the seed data. The seed data was helpful to know what data we needed to input to our tables and columns.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. O(n) because it depends on the length of customers or movies in the db.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. Constant because we're returning a JSON response that it was successful or unsuccessful.
Describe a set of positive and negative test cases you implemented for a model. we tested for the validity of a movie given the required fields and then tested it without the required fields
Describe a set of positive and negative test cases you implemented for a controller. In our rental controller we test that the check-out path works with a valid input params and one without.
How does your API respond when bad data is sent to it? It responds with a 404 bad request status
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We have a checkout! class method in our rental model that takes in movie and customer ids. It adjusts and creates a rental object, makes note of the date, assigns a return date, updates the movie's inventory and the customer's movies_checked_out count.
Do you have any recommendations on how we could improve this project for the next cohort? Do this before API muncher, explain using postman better in relations to creating custom APIs
Link to Trello https://trello.com/b/RZ6m8bHB
Link to ERD https://www.lucidchart.com/invitations/accept/7b052de5-82d0-49e6-bb27-bba6572e18f8
Summary We feel like we learned alot on this project, especially because we had enough project time to understand the concepts.

@CheezItMan
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene Good number of commits and good commit messages
Comprehension questions Check, I would say O(n) for checkin and check-out because you have to find the customer and movie. You also should not return 404, for invalid data. Instead a bad request would make an appropriate response in some cases.
General
Business Logic in Models Check, but you could have more in the customer and movie models.
All required endpoints return expected JSON data Check
Requests respond with appropriate HTTP Status Code Check
Errors are reported Not always, see my inline notes
Testing
Passes all Smoke Tests You're not passing tests revolving around available inventory, and the movies checked out.
Model Tests - all relations, validations, and custom functions test positive & negative cases You do not have tests for your relationships or custom methods in Rental. Your testing is pretty thin here as well.
Controller Tests - URI parameters and data in the request body have positive & negative cases You need to test negative cases here. Like creating a movie with invalid parameters.
Overall You hit most of the learning goals here. You need to do a better job of testing throughly, adding more business logic in the models, and better matching the smoke tests.


def create
@movie = Movie.new(movie_params)
@movie.save!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should return a json response if the move wasn't able to be saved. Provide error messages.

rental = Rental.checkout!(rental_params[:customer_id], rental_params[:movie_id])
render json: { ok: true, message: 'Checkout successful!' }, status: :ok
else
render json: { ok: false, message: 'Unable to checkout' },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't be a not found but rather a bad request.

end

rescue ArgumentError
render json: { ok: false, message: 'Unable to checkout: movie or customer does not exist' }, status: :not_found

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, not_found is probably not the right response here.


it "has rentals" do

movie.rentals.new

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line trying to accomplish?


movie.rentals.new

expect (movie.rentals.length).must_be :>=, 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a test that rentals is a collection of Rental instances.


end

it 'creates a movie given correct params' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

negative cases?

}

post rentals_checkout_path(rental.id), {:params => rental_params}
rental.reload

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need negative cases as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants