Skip to content

Earth - Rose Video - Denise and Anya#30

Open
anyatokar wants to merge 51 commits intoAda-C14:masterfrom
dnsrocha:master
Open

Earth - Rose Video - Denise and Anya#30
anyatokar wants to merge 51 commits intoAda-C14:masterfrom
dnsrocha:master

Conversation

@anyatokar
Copy link

Assignment Submission: Video Store API

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

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.

Reflection

Prompt Response
Explain how you came up with the initial design of your ERD, based on the seed data and reading through the API endpoints We looked at the seed data, the seed.rb, and project requirements. The columns/seed file dictated the attributes for the objects. We decided to create a Rental class belonging to Video and Customer. Customer has many rentals and videos through rentals. Video has many rentals and customers through rentals.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. O(n), n being the length of the collection for each, customers and videos. We iterate through the entire list to render the JSON.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. O(n), n being the length of the rentals collection.
Describe a specific set of positive and negative test cases you implemented for a model. A positive case for Video is it can be created when the required attributes are provided. A negative case is when it fails to be created when one of the required attributes isn't provided.
Describe a specific set of positive and negative test cases you implemented for a controller. A positive case for Rental is when both a valid (existing in the system) customer_id and video_id are provided. A negative case is when one (or more) of the required attributes isn't provided or is invalid.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. It responds with a code specifying the error and renders an error message in the response body.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We chose to not create any custom methods, but we could have moved the check-in and check-out methods to the rental model if we didn't want to have all this logic within the controller.

dnsrocha and others added 30 commits December 1, 2020 17:02
had customers instead of rentals - copy paste error
rental validations added but tests commented out for now rentals fixture created
Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Video Store API

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Practices git with at least 10 small commits and meaningful commit messages ✔️
Understands the importance of how APIs handle invalid/erroneous data in their reflection questions
Practices Rails best practices and well-designed separation, and encapsulates business logic around check-out and check-in in models ⚠️ As you noted in your PR questions, you didn't encapsulate business logic in the model methods.
Uses controller tests to ensure quality code for every route, and checks for response status and content, with positive cases and negative cases ⚠️, mostly but you did miss some positive/negative cases
Uses controller tests to ensure correctness for check out and check in requirement, and that checked out counts and inventories appropriately change ✔️, except as noted above

Functional Requirements

Functional Requirement yes/no
All provided smoke tests for Wave 1 pass ✔️
All provided smoke tests for Wave 2 pass ⚠️ Except for checking in. It seems like the smoke tests are finding customers and videos for which there is not a corresponding rental.

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 3+ in Code Review && 2 in Functional Requirements 💚 Nice work

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Descriptive/Readable
Logical/Organized

Summary

Nice work, you hit the main learning goals here. Well done. You can check out my comments, mostly on missing tests and model methods. Otherwise it works!

validates :total_inventory, presence: true
validates :overview, presence: true
validates :release_date, presence: true

Choose a reason for hiding this comment

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

It might make a good idea to have a checkout and check_in model methods to hold the business logic.

# end


def check_out

Choose a reason for hiding this comment

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

These check_out and check_in methods are pretty big. It would be better to abstract out the logic of creating a rental record into a model method.

The controller should focus solely on handling the request and passing business logic to the models.

Comment on lines +13 to +14
required_fields.each do |field|
customer_one[field] = nil

Choose a reason for hiding this comment

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

clever

require "test_helper"

describe Customer do
describe "validations" do

Choose a reason for hiding this comment

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

You are missing validations for uniqueness like for phone number.

Comment on lines +5 to +6
validates :customer_id, presence: true
validates :video_id, presence: true

Choose a reason for hiding this comment

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

Just FYI, by belonging to video and customer, these validations are already on by default.

Comment on lines +6 to +7
validates :available_inventory, presence: true
validates :total_inventory, presence: true

Choose a reason for hiding this comment

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

No validations to ensure that the number in inventory is 0 or positive?

Comment on lines +4 to +9
it "responds with JSON and success" do
get videos_path

expect(response.header['Content-Type']).must_include 'json'
must_respond_with :ok
end

Choose a reason for hiding this comment

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

This should probably be in the describe for index

Comment on lines +4 to +6
# checkout_date:
# due_date:
# status:

Choose a reason for hiding this comment

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

So you don't have similar fields?

returned: false}
}

it "can create a rental check in" do

Choose a reason for hiding this comment

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

No test for invalid check-ins

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

Comments