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

branches - Diana Caroline Kelsey Steph #92

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

Conversation

stupendousC
Copy link

bEtsy

Congratulations! You're submitting your assignment! These comprehension questions should be answered by all members of your team, not by a single teammate.

Comprehension Questions

Question Answer
Each team member: what is one thing you were primarily responsible for that you're proud of? Diana- products & category and figuring out the join table relationship. Caroline- SEEDS, merchant dashboard, checkout fucntionality . Kelsey- Teamwork<3. Steph- reviews
Each team member: what is one thing you were primarily responsible for that you would like targeted feedback on? Caroline - CSS, artistic direction. Kelsey- OrderItems controller tests. Diana- product controller tests. Steph- test
How did your team break up the work to be done? We started by assiging each person a model to be responsible for-. We also did pair programming. We kept communicating to make sure that we weren't overlapping with what we were working on, and that we shared our code when we needed to collaborate.
How did your team utilize git to collaborate? We made sure to make pull requests when we merge to master. We faced some difficulties in the merging process but we learned how to effectively troubleshoot the issue and learned that communication is key when working together on a project.
What did your group do to try to keep your code DRY while many people collaborated on it? We continuously communicated by reviewing each others code and providing feedback on how we can refactor
What was a technical challenge that you faced as a group? GIT
What was a team/personal challenge that you faced as a group? GIT
What was your application's ERD? (include a link) https://www.lucidchart.com/documents/edit/a871d432-6b90-4a8d-b284-cbca4fb9e5df/0_0. we also made revisions on paper
What is your Trello URL? https://trello.com/b/UradqFZT/betsy-board
What is the Heroku URL of your deployed application? https://mighty-ducks.herokuapp.com

stupendousC and others added 30 commits October 28, 2019 15:58
working on viewing products by merchant id
Diana weekend updates to merchant dashboard
@jmaddox19
Copy link

bEtsy

What We're Looking For

Manual testing

Workflow yes / no
Deployed to Heroku x
Before logging in
Browse all products, by category, by merchant x
Leave a review x
Verify unable to create a new product x
After logging in
Create a category yes! And love that the dropdown didn't include the category until I added an item to the category
Create a product in that category with stock 10 x
Add the product you created to your cart x
Add it again (should update quantity) x
Verify unable to increase quantity beyond stock x
Add another merchant's product x
Check out x
Check that stock was reduced the "add to cart" button disappeared when the item is out of stock. It'd be good to have clear messaging to the user about being out of stock as well
Change order-item's status on dashboard x
Verify unable to leave a review for your own product x
Verify unable to edit another merchant's product by manually editing URL x
Verify unable to see another merchant's dashboard by manually editing URL x

Code Review

Area yes / no
Routes
No un-needed routes generated (check reviews) a few extras but there's definitely some intentionality shown (see code comment)
Routes not overly-nested (check products and merchants) x
Merchant dashboard and cart page use a non-parameterized routes (should pull merchant or cart ID from session) The dashboard and cart routes do require a parameterized route even though the parameter doesn't appear to be used. If this is unclear to y'all, it's worth taking the time to understand it.
Controllers
Controller-filter to require login by default The "require_login" method is written in 3 different controllers. If it were in the ApplicationController it could be used by any controller without rewriting it.
Helper methods or filters to find logged-in user, cart, product, etc x
No excessive business logic There is some in the order_items_controller. See code comments.
Business logic that ought to live in the model
Add / remove / update product on order no, as mentioned above
Checkout -> decrease inventory
Merchant's total revenue No, I don't think this is calculated or displayed to the user.
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 | These tests are on the order_items_controller rather than the order_item 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) | yes!
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 | no edge case testing (see PR comment)

Overall Feedback

Great work overall! You've built a fully functional web store from top to bottom. This represents a huge amount of work, and you should be proud of yourselves!.

I am particularly impressed by the way that the website looks and feels quite usable and clean and much of the testing is quite thorough.

I do see some room for improvement around clarity on what code belongs in a controller and what belongs in a model. Also, clarity on when parameterized routes are useful.

bEtsy is a huge project on a very short timeline, and this feedback should not at all diminish the magnitude of what you've accomplished. Keep up the hard work!

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

get "/orders/checkout", to: "orders#checkout", as: "checkout"

resources :orders do
resources :order_items

Choose a reason for hiding this comment

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

this could stand to be limited with an "only" param

Comment on lines +7 to +27
# for merchants' eyes only
# sending only the relevant order_items and orders
@order_items = OrderItem.by_merchant(session[:merchant_id])
@orders = @order_items.map { |order_item| order_item.order }
@orders.uniq!


# if merchant wants to FILTER BY ORDER STATUS
@statuses = %w[ALL SHIPPED PAID PENDING]
if params[:status_selected]
statuses_index = params[:status_selected].to_i

# @orders and @order_items will get filtered depending on status selected
@database_status = @statuses[statuses_index].downcase
if @database_status == "all"
# leave @order_items as is
return
else
@order_items = @order_items.find_all { |order_item| order_item.status == @database_status }
@orders = @order_items.map { |order_item| order_item.order }
@orders.uniq!

Choose a reason for hiding this comment

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

Most of this is business logic that should live in models. As a rule of thumb, when I see more than a line or two that isn't related to control flow (render, redirect, etc.) or defining variables for views, I'm going to feel inclined to put the code in a model.

Choose a reason for hiding this comment

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

Also almost all of these variable aren't used by the view and therefore shouldn't be instance variables.

Choose a reason for hiding this comment

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

Also also, when refactoring this code to move most of it to the model, I would not just move it to one method in the model; I would figure out how to break it into several small methods.
In general, IMO, if a method is more than 30ish lines, it's worth considering how it could be broken down into smaller methods.

Comment on lines +17 to +26
it "A Product Can Have Many Reviews" do
product = products(:p1)
test_review_one = Review.create(rating: 1, comment:"It sucks!", product_id: product.id)
test_review_two = Review.create(rating: 5, comment:"wow!", product_id: product.id)
get new_product_review_path(product.id)

must_respond_with :success
expect(test_review_one.comment).must_include "It sucks!"
expect(test_review_two.comment).must_include "wow"
end

Choose a reason for hiding this comment

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

This is a model test but it's in the controller test file.

require "test_helper"

describe ReviewsController do
describe "create" do

Choose a reason for hiding this comment

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

create could stand to have some edge case testing

@@ -0,0 +1,164 @@
require "test_helper"
describe OrderItemsController do

Choose a reason for hiding this comment

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

As I mention in another comment, there's a logic in this controller that belongs in the model. That said, the testing here is very well-written and thorough!

Comment on lines +5 to +21
describe "#index action" do
it "responds with success when there is at least one Product saved" do
new_product = products(:p1)

get products_path

must_respond_with :success
expect(Product.count).must_be :>, 0
end

it "responds with success when there are products to show " do
get products_path

must_respond_with :success
expect(Product.count).must_equal 5
end
end

Choose a reason for hiding this comment

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

These tests are actually testing the same condition. (The arrange in the 1st test isn't actually changing the db.) An interesting edge case would be to delete all the products and make sure the page still responds the way you want it to.

@@ -0,0 +1,278 @@
class OrdersController < ApplicationController

Choose a reason for hiding this comment

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

I wrote the below comment on the index action but wanted to say it applied to almost every method in 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
5 participants