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

swEtsy - Lina, Kareha, Sophie, Richelle #81

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

Conversation

r-spiel
Copy link

@r-spiel r-spiel commented Nov 26, 2020

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? Richelle - user logic and pages. Sophie - product, frontend and navigation. Kareha - testing, cart model logic. Lina - cartitems & reviews.
Each team member: what is one thing you were primarily responsible for that you would like targeted feedback on? Richelle - would love feedback on user model methods, I feel like I repeated some logic and there must be a better way. Sophie - drying up controller logic (products & applications controller), putting controller actions in the right place, refactoring to custom model methods. When should we use view helpers? Kareha - update status cart test. Lina - would like feedback on testing cartitems/cart & reviews.
How did your team break up the work to be done? We started out discuss which parts of the project people were interested in and Sophie decided to take Products, Lina and Kareha worked together on cart logic intially and then split it up. Richelle worked on User.
How did your team utilize git to collaborate? We did a lot of pull requests and daily merge parties after Standup so that we would all branch off of the same master branch. We each made sure to branch off when working on new features. We used the github merge conflict resolution tool which was very helpful. We all feel more confident dealing with merge conflicts.
What did your group do to try to keep your code DRY while many people collaborated on it? We utilized fixtures whenever possible in testing. We communicated and used each other's methods. We could use feedback on this as well.
What was a technical challenge that you faced as a group? TODAY. We had issues after deploying to heroku, we were able to log in initially for some reason, and then anytime someone logged out, they not able to log in again. Ansel helped us find out that the callback URL in github's auth had https, and had to be changed to be http. Weird! Then we uncommented something in the config and are back to https. Woah! (~richelle)
What was a team/personal challenge that you faced as a group? Our standups were a little long. But only Sophie was bothered by this ;PPPP. We all DO feel that we worked well as a group, and supported each other. "communication skills on point" ~ Lina "A week to remember and a special time" ~ Sophie "Best group project ever" ~ Kareha "What a lovely group, I would love to work professionally with any one of them" ~ Richelle
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://lucid.app/lucidchart/47401575-5a07-4c03-a1d7-8693d8dc7673/edit?page=0_0#?folder_id=home&browser=icon
What is your Trello URL? https://trello.com/b/ajlHwVd9/betsy-lina-sophie-kareha-richelle
What is the Heroku URL of your deployed application? https://swetsy.herokuapp.com/

agesak and others added 30 commits November 20, 2020 17:19
…view page- added $ sign and round to 2 decimal places
@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!

Richelle, the user model tests are very thorough! In general, it's considered much more ok to repeat yourself in tests than it would in the app code. That said, there is some excessive thoroughness in some of the User model tests that make them more work to write and actually make them less thorough tests. See my inline comments in user_test.rb for details.

Sophie, for the most part the controllers look plenty DRY! There are a couple places in the controllers where I suggest areas for improvement. See my inline comments in the controllers for details.

Kareha, sorry, I honestly struggle to understand what "update status cart test" meant so am not sure how to give targeted feedback.

Lina, all the testing you mentioned you wanted feedback on looks great to me!

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 Stock didn't get 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 ✔️
Routes
No un-needed routes generated (check reviews) ✔️
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 ✔️
No excessive business logic ✔️ Yes, amazing job of creating lots of useful methods in the models!
Business logic that ought to live in the model
Add / remove / update product on order ✔️ Not for this specific thing but I frankly disagree that you need it. The code is quite succinct as is :)
Checkout -> decrease inventory ✔️
Merchant's total revenue ✔️
Find all orders for this merchant (instance method on Merchant) ✔️
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
✔️ There's no model method for these things but plenty of thorough model testing
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
✔️
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)
✔️
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
✔️

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 +9 to +11
if @cart_item.qty < product_inventory
@cart_item.qty += 1
@cart_item.save

Choose a reason for hiding this comment

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

This is not a large amount of code but is is a small example of "business logic" that could have it's own model method.

Comment on lines +20 to +23
if @cart_item.qty > 1
@cart_item.qty -= 1
end
@cart_item.save

Choose a reason for hiding this comment

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

This is not a large amount of code but is is a small example of "business logic" that could have it's own model method.

@@ -0,0 +1,72 @@
class User < ApplicationRecord

Choose a reason for hiding this comment

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

Great helper methods here!

@@ -0,0 +1,42 @@
class Cart < ApplicationRecord

Choose a reason for hiding this comment

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

Great helper methods here!

@@ -0,0 +1,49 @@
class Product < ApplicationRecord

Choose a reason for hiding this comment

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

Great helper methods here!

Comment on lines +141 to +157
if pending_revenue == 0
expect(pending_revenue).must_equal 0
else
expect(pending_revenue).must_be_kind_of Float
end

if paid_revenue == 0
expect(paid_revenue).must_equal 0
else
expect(paid_revenue).must_be_kind_of Float
end

if complete_revenue == 0
expect(complete_revenue).must_equal 0
else
expect(complete_revenue).must_be_kind_of Float
end

Choose a reason for hiding this comment

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

I will say that this is definitely more work than you should need to do for a test. For testing, unlike in app code, you do have full control over the user and their current values so you should be able to setup the user in a specific way (eg. where values == 0 or values != 0) and shouldn't need to write if statements about those preconditions.

Happy to talk more about this if this brief explanation doesn't make sense.

Comment on lines +197 to +201
expect(pending_items_count).must_be_kind_of Integer
expect(paid_items_count).must_be_kind_of Integer
expect(complete_items_count).must_be_kind_of Integer

total_by_status = pending_items_count + paid_items_count + complete_items_count

Choose a reason for hiding this comment

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

This is another example where you should be able to make more explicit assumptions than this test is making. You can and should hardcode specific values for what each of these values should be based on the way the user is arranged.

The way this test is written, if the pending_items_count isn't being calculated correctly, the test will still pass.

In general you should rarely need to do any real math or if statements in tests.

Comment on lines +182 to +184
expect(pending_revenue).must_equal 0
expect(paid_revenue).must_equal 0
expect(complete_revenue).must_equal 0

Choose a reason for hiding this comment

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

This is great! A good example of expecting very specific values. This sort of expectation can be applied to values besides 0 as well. Hope that helps

Comment on lines +81 to +96
if @current_cart.products.include?(@product)
# find the cart item
cart_item = current_cart.cartitems.find_by(product_id: @product.id)
# check if there is enough inventory
if cart_item.qty < @product.inventory
cart_item.qty += 1
flash[:success] = "Successfully added to cart"
else
# not enough inventory
flash[:error] = "Sorry, not enough inventory"
end
else
# create a new cart item if it doesn't exist
cart_item = Cartitem.new(cart: @current_cart, product: @product, qty: 1, cost: @product.cost )
flash[:success] = "Successfully added to cart"
end

Choose a reason for hiding this comment

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

This could all be a method in the cart model, something like cart.add(product). It will return true if it could successfully add it to the cart and false otherwise. The appropriate flash message could be displayed accordingly from this controller.

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