-
Notifications
You must be signed in to change notification settings - Fork 15
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
DanDeeLions - Edges - Fibonoshi #26
base: master
Are you sure you want to change the base?
Conversation
…additions and bug fixes
…n it comes to add new info
"karina fixing applicaiton "
bEtsyPushpa: I would like feedback on merchant controller and model testing, and logic flow for that controller and model.
Anibel: I was primarily responsible for Order model and controller actions. While we were able to address some of the related user stories, I felt like it was a little “hack-ey” (i.e. having to create custom validations, creating instances of multiple classes in a single action, etc.). What’s the right way to do this?
Carly: The Product piece (from controller, model, views, relationships, and nesting).
Katrina: The reviews controller logic. It was a little tricky having the reviews on the same page, and my code wasn’t as DRY as I thought it should be, but wanted to get it working and felt crunched for time, so I think I would like to get feedback on how to DRY up that controller.
# Instance method inside of Product
def can_be_reviewed_by(merchant)
return true unless merchant
return merchant.id == merchant_id
end
# In the ReviewsController
def create
product = Product.find_by(id: params[:id])
if product.nil?
# not found
elsif product.can_be_reviewed_by(@logged_in_merchant)
# Create review, try to save, set flash
else
# Unauthorized! Set flash, redirect
end
end Only the person who submitted the PR will get an email about this feedback. Please let the rest of your team know about it. |
def status_change | ||
@product = Product.find_by(id: params[:id]) | ||
|
||
if @product.nil? |
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.
Since this action operates on a product, it might make more sense in the ProductsController.
return [*1..12] | ||
end | ||
|
||
def self.years |
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 self methods should probably be view helpers.
|
||
def product_name | ||
return self.product.name | ||
end |
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 don't know that saying order.product_name
is any easier than order.product.name
.
@order_item = OrderItem.find_by(id: params[:id]) | ||
|
||
@order_item.status ? @order_item.update_attribute(:status, false) : @order_item.update_attribute(:status, true) | ||
|
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.
Line 66 could be rewritten:
@order_item.status = !@order_item.status
it 'responds with bad_request if attempting to update an order_item that does not belong to the cart of the current user' do | ||
order_item_setup | ||
|
||
# Arrange: First OrderItem is not associated with current user |
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.
Nice! I like this test case, and I like that you thought to check this in the controller.
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