-
Notifications
You must be signed in to change notification settings - Fork 13
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
Liv, Hannah, Corinna - Time&Space #30
base: master
Are you sure you want to change the base?
Conversation
merge from testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LIV: I love how you divided your tests into what you can do unauthenticated and what you can do authenticated. This is a great way to use login from the test helper. Overall, I feel like your tests are quite clean and make good use of this test_helper method and fixtures. If there are specific places where you thought it could be DRYer, I'd be happy to chat about it. In general, tests are the one place not to worry too much about DRYness.
CORINNA: I left in an in-line comment about the controller filter conundrum. It's ok to not use controller filters if you're not writing the same code more than a couple times. Again, if there are specific places in the tests, I'd be happy to chat about how you might be able to write a test_helper method to make things more concise.
HANNAH: Great use of controller filters and custom model methods. I left one in-line comment of a small amount of logic you could consider putting in the model.
end | ||
|
||
def ordered | ||
@order = Order.find_by(id: params['id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per your question, it's ok to not have a controller filter here since this code is only repeated twice. You could chose to use a controller filter for the 'id' one and not the 'format' one.
product = Product.find_by(id: params["format"]).inventory | ||
|
||
|
||
session[:cart].each do |item| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider whether you can move any of this logic to a model method.
quantity = params["quantity"].to_i | ||
|
||
session[:cart].each do |item| | ||
if item['product_id'] == product.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider whether you can move any of this logic to a model method.
return | ||
end | ||
|
||
if item["product_id"] == params['format'].to_i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this business logic to the model.
@shipped_revenue = 0 | ||
@shipped_count = 0 | ||
|
||
Order.all.each do |order| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These calculations should be done in custom model methods.
order.order_items.each do |item| | ||
merchant_product = Product.find_by(id: item.product_id) | ||
|
||
if session[:user_id] == merchant_product.user_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic seems like it could go into the merchant model so that you could use something like merchant.orders
|
||
|
||
def index | ||
@products = Product.where(active: true).order(:name).paginate(:page=>params[:page],:per_page=>15) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could consider during some of this work in a custom model method such as active_sorted_products
.
@@ -0,0 +1,66 @@ | |||
class Product < ApplicationRecord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great use of custom model methods
return order_total | ||
end | ||
|
||
def self.get_items(merchant_products) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this method! Do you use it?
@@ -0,0 +1,15 @@ | |||
<div class="products__index_product-container item"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great use of a partial view
bEtsyFunctional Requirements: Manual Testing
Major Learning Goals/Code Review
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
Overall FeedbackOnly the person who submitted the PR will get an email about this feedback. Please let the rest of your team know about it. |
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
CORINNA: using session to store our cart, including updating quantities and eventually creating an order.
HANNAH: Deployment. This time, I deployed early and often (every day). Especially, implementing OAuth on Heroku is something I learned and I’m proud of!
CORINNA: Places where I could use additional test helpers or move methods to make the code cleaner and more efficient. I struggled to use things like before_action because my params often changed from ['id'] to ['format'] so accommodating for that, etc.
HANNAH: products_contoller & model! I mainly worked on products related controllers like ‘reviews_controller’ and ‘category_controller’. I made sure to use before_action, around_action to make my code DRY.
before_action
andaround_action
to dry our code.