Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team MKKRs - Neopetsy #78

Open
wants to merge 256 commits into
base: master
Choose a base branch
from
Open

Team MKKRs - Neopetsy #78

wants to merge 256 commits into from

Conversation

kimvitug05
Copy link

Assignment Submission: bEtsy

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions. These should be answered by all members of your team, not by a single teammate.

Reflection

Prompt Response
Each team member: what is one thing you were primarily responsible for that you're proud of? Kayla: Shopping cart, Ren: Front-end, Bootstrap styling, Dashboard; Madeline: Product controller, Testing and Reviews; Kim: Categories, Model Testing, O-Auth(w/ Ren), Seeding Database
Each team member: what is one thing you were primarily responsible for that you would like targeted feedback on? Kayla: Shopping cart functionality & OrderItem Controller Testing; Ren: Discerning if view logic is too business-logic-heavy; Madeline: Testing for Products Controller and Reviews Controller; Kim: Custom methods for Merchant, Model Testing.
How did your team break up the work to be done? We broke it up by each entity & agreed upon assignments based on the Trello Board (High Priority Items).
How did your team utilize git to collaborate? We utilized branching for key features.
What did your group do to try to keep your code DRY while many people collaborated on it? We utilized fixtures, partials and controller filters.
What was a technical challenge that you faced as a group? We had to refactor shopping cart functionality (towards the end of the project 😬 ) and had to make sure it didn't break other functionality.
What was a team/personal challenge that you faced as a group? Coordination was challenging.
What was your application's ERD? (upload this to Google Drive, change the share settings to viewable by everyone with a link, and include a link) https://dbdiagram.io/d/5fb6bf9e3a78976d7b7ca447
What is your Trello URL? https://trello.com/b/hltwAny6/team-mkkrs-makers
What is the Heroku URL of your deployed application? https://neopetsy-betsy-app.herokuapp.com/

Ren Carothers and others added 28 commits November 24, 2020 23:02
basic review styles, stars function needs help
add products and categories csv
…rom routes. changed if else statement in new method to render bad request if product isn't found.
cleaned up reviews controller/tests
@jmaddox19
Copy link

bEtsy

Y'all, you did it! And your site looks SO GOOD! I hope that you show this off to people! If I were you, I'd be so proud of what y'all built together!

The two primary areas for improvement I see are around putting more business logic into the models (which I see a comment about, so it's good to see you're aware of that) and adding more testing in general. That said, with a shortage of time, I think y'all did get a good amount of testing done :)

In general, there aren't many tests written for custom model tests. They are still marked as covered by SimpleCov but that's only because the controller tests cause those methods to get called. But adding tests for the specific custom methods is still important.

Kayla, great work on the cart! It all looks like it works really well! The main area for improvement I see is around moving more of the logic into model custom methods. As a general rule, if I see more than one or two lines of code in a controller that don't deal with flash, session, or control flow (eg. render, redirect, etc.), I ask myself if I can make it into one or more separate model methods instead. Also, the testing for OrderItemsController that is there looks good. There is room for more edge case testing. I'm glad to see that you have the skeletons for more tests so you are obviously aware of more tests that could be added :)

Ren, the views look really good! I left a few inline comments in places in the views that could be cleaned up a little.

Madeline, the products controller and reviews controller tests look good! The only lines that aren't covered are lines 12-14 of the reviews controller, which can be seen in the SimpleCov report. This could be addressed by adding a test for a product_id that doesn't exist.

Kim, the custom methods in Merchant look good! As I noted above most custom methods in the models aren't tested or aren't tested very thoroughly but I assume that's because there just wasn't enough time.

Again, great work everyone! This is going to be a site that'll be fun to show off for a long time I think!

Functional Requirements: Manual Testing

Workflow yes / no
Before logging in
Browse all products, by category, by merchant ✔️
Leave a review ✔️
Verify unable to create a new product ✔️
After logging in
Create a category ✔️
Create a product in that category with stock 10 ✔️
Add the product you created to your cart ✔️
Add it again (should update quantity) ✔️
Verify unable to increase quantity beyond stock ✔️
Add another merchant's product ✔️
Check out ✔️
Check that stock was reduced ✔️
Change order-item's status on dashboard ✔️
Verify unable to leave a review for your own product ✔️
Verify unable to edit another merchant's product by manually editing URL ✔️
Verify unable to see another merchant's dashboard by manually editing URL ✔️

Major Learning Goals/Code Review

Criteria yes / no
90% reported coverage for all controller and model classes using SimpleCov I see 78% (due to testing missing in OrdersController and OrderItemsController)
Routes
No un-needed routes generated (check reviews) See inline comment in routes.rb
Routes not overly-nested (check products and merchants) ✔️
Merchant dashboard and cart page use a non-parameterized routes (should pull merchant or cart ID from session) ✔️
Controllers
Controller-filter to require login is applied to all merchant-specific actions (update/add item, add category, view merchant dashboard, etc.) - filter method is not duplicated across multiple files ✔️
Helper methods or filters to find logged-in user, cart, product, etc ✔️ Yes, with the exception of the OrdersController
No excessive business logic ✔️ Yes, with the exception of the OrdersController
Business logic that ought to live in the model
Add / remove / update product on order
Checkout -> decrease inventory
Merchant's total revenue ✔️
Selected Model Tests
Add item to cart:
- Can add a good product
- Can't add a product w/o enough stock
- Can't add a retired product
- Can't add to an order that's not in cart mode
- Logic specific to this implementation
This logic doesn't live in the model. Some of this testing exists in OrderItemsController but no edge cases
Get orders for this merchant:
- Includes all orders from this merchant
- Doesn't include orders from another merchant
- Orders are not included more than once
- Does something reasonable when there are no orders for this merchant
Also not in the model.
Selected Controller Tests
Add item to cart:
- Empty cart (should be created)
- Cart already exists (should add to same order)
- Product already in cart (should update quantity)
- Bad product ID, product is retired, quantity too high, or something like that (error)
Only nominal cases are tested
Leave a review:
- Works when not logged in
- Works when logged in as someone other than the product's merchant
- Doesn't work if logged in as this product's merchant
- Doesn't work if validations fail
✔️ Most of this testing is present :)

Code Style Bonus Awards

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

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

Overall Feedback

Only the person who submitted the PR will get an email about this feedback. Please let the rest of your team know about it.

Comment on lines +47 to +52
# standard RESTFUL routes
resources :categorizations
resources :order_items #TODO: If you don't need all of these, I just need to be able to update order_item
resources :orders
resources :reviews
resources :products, except: [:delete] #TODO: I think this one is redundant

Choose a reason for hiding this comment

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

The routes all look good until these lines. There are several of the 7 restful routes that aren't supported by these controllers so there's no need to add routes for them.

end

def checkout
@order = Order.find_by(id: session[:order_id])

Choose a reason for hiding this comment

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

This would be a good candidate for a little controller filter

Comment on lines +31 to +37
if [email protected]?
@order.order_items.each do |item|
item.product.quantity += item.quantity
item.product.save
item.destroy
end
end

Choose a reason for hiding this comment

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

This is code that would be great as a model method.

@cart_total = get_total
end

#should be in model--but...no time to refactor.

Choose a reason for hiding this comment

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

Agreed :)

</section>

<section class="display-products-container">
<%= render partial: 'products/product-grid', locals: { products: @categorization.products.where(active: true) } %>

Choose a reason for hiding this comment

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

This is one little example of something that could be cleaned up slightly by making a @products variable in the controller with the value @categorization.products.where(active: true) so that you can just reference the variable from the view.

Comment on lines +4 to +5
logged_in_merchant_has_order_items: @login_user && @order.extract_merchant_order_items(@login_user.id).any?,
merchant_items: @login_user ? @order.extract_merchant_order_items(@login_user.id) : []

Choose a reason for hiding this comment

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

these two boolean values could be computed in the controller and assigned variable names to clean up this a little


<section class="display-products-container">
<% if @login_user %>
<%= render partial: 'product-grid', locals: { products: @products.where.not(merchant_id: @login_user.id, active: false) } %>

Choose a reason for hiding this comment

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

This is another good example where a variable assignment could happen in the controller to clean this up

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.

5 participants