Skip to content

trees: Mira & Natalie#18

Open
NatalieTapias wants to merge 38 commits intoAda-C12:masterfrom
calopter:master
Open

trees: Mira & Natalie#18
NatalieTapias wants to merge 38 commits intoAda-C12:masterfrom
calopter:master

Conversation

@NatalieTapias
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. We decided that a rental consisted of a customer_id, movie_id, checkout date, and due date based on the user stories that we received. We also managed to perform a few migrations to track data that the smoke tests expected to be present (movies_checked_out_count for customer and currently_available for movie). We decided that a customer may have many rentals. A movie may be rented many times. A rental only has one customer and one movie.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. O(1) I believe it is a constant time complexity because we are returning the entire table. We are not performing a search or a lookup for customers and movies endpoints.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. This is a database lookup using two parameters. The time complexity is O(n).
Describe a set of positive and negative test cases you implemented for a model. Positive tests for the model: when we looked at checkout, we expected the customer’s movies_checked_out would increase upon checkout. Negative test cases: when there is no more available movie inventory the model method “checkout” returns false.
Describe a set of positive and negative test cases you implemented for a controller. Positive test case for rental controller: when we checked out a movie that was available with a valid customer, the db will store a rental, responds with json, and status is ok. A negative case for the rental controller is that when a customer doesn’t exist, the response is bad_request and the database shouldn’t change.
How does your API respond when bad data is sent to it? We respond with a json that contains the error messages and bad_request status.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. Checkin is one of our custom model methods. It handily increments the movie available_inventory and decrements the customer’s movie_checked_out_count. That allowed us to test that functionality separately from the controller logic (whether or not the request data matches a rental in the database).
Do you have any recommendations on how we could improve this project for the next cohort? It would be nice if the smoke tests matched the readme requirements. Specifically where incrementing/decrementing customer and movie data upon checkout. Also, have the smoke tests match the fields listed in the readme to return when calling show or index.
Link to Trello https://trello.com/b/g5hOOC9d/videostoreapi
Link to ERD https://www.lucidchart.com/documents/edit/8e8ee0ef-5d9f-48d1-93ff-5921c1df4d40/0_0
Summary

@CheezItMan
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene Granular commits, good commit messages and both members contributing
Comprehension questions Check, I would suggest your index actions are O(n) since you need to access each item.
General
Business Logic in Models You've added the check-in and check-out functionality here, well done.
All required endpoints return expected JSON data Check
Requests respond with appropriate HTTP Status Code Mostly yes
Errors are reported Check
Testing
Passes all Smoke Tests Check
Model Tests - all relations, validations, and custom functions test positive & negative cases Some missing tests, and some assert-style tests. Some improvements would be good here.
Controller Tests - URI parameters and data in the request body have positive & negative cases Some improvements here, but overall not bad.
Overall Nice work, you hit the learning goals here. You do have some improvements needed in testing, but otherwise this is well done. Congrats, you're done with Rails!

end
end

def checkout

Choose a reason for hiding this comment

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

👍

if movie
render json: movie.as_json(only: [:id, :release_date, :title, :overview, :inventory, :available_inventory]), status: :ok
else
render json: {"errors" => {"id" => ["Movie with id #{params[:id]} not found."]}}

Choose a reason for hiding this comment

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

status code?

@@ -0,0 +1,11 @@
require "test_helper"

describe Customer do

Choose a reason for hiding this comment

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

No validation tests?

Only testing having many rentals?

end

it 'can make a movie with a title' do
assert @movie.valid?

Choose a reason for hiding this comment

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

These kinds of assertions work, but they're not in the style we're doing at Ada. So I'd suggest conforming to the spec-style testing.

Suggested change
assert @movie.valid?
expect(@movie.valid?).must_equal true


end

it 'is invalid and returns errors when movie has no availability' do

Choose a reason for hiding this comment

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

Just noting the incomplete test. It's good you were thinking about this.

must_respond_with :ok
end

it 'responds with an array of customer hashes' do

Choose a reason for hiding this comment

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

What about when there are no customers?

must_respond_with :ok
end

it 'responds with an array of movie hashes' do

Choose a reason for hiding this comment

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

What about when there are no movies?

require "test_helper"

describe RentalsController do
describe "checkout" do

Choose a reason for hiding this comment

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

What about when there are no movies available for rental.

end

describe "checkin" do
it "wont_change the db and responds ok for an existing customer and movie" do

Choose a reason for hiding this comment

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

Suggested change
it "wont_change the db and responds ok for an existing customer and movie" do
it "wont_change the Rental count in the db and responds ok for an existing customer and movie" do

expect {
post checkin_path, params: checkin_params
}.wont_change "Rental.count"

Choose a reason for hiding this comment

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

You should also check to verify if the movie is updated properly.

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.

3 participants