-
Notifications
You must be signed in to change notification settings - Fork 14
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
Pipes - Iuliia, Eva, Lindsey, Rebecca - Betsy #66
base: master
Are you sure you want to change the base?
Conversation
Categoriesproducts
…of OrderItems to proceed
Reviews tests
Review model tests
Order merchant view
Fix total cost
fixed all the tests but one
Change layout for 404 page
bEtsyWhat We're Looking For
IMPORTANT: Whoever submitted the PR (and thus will get the notification about this feedback) should share this with their teammates. |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
|
||
<title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title> | ||
|
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 stuff in the <title>
tag doesn't seem to have worked - the title of your page is always "Untitled".
resources :products, only: [:index] | ||
end | ||
|
||
resources :merchants do |
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.
All of these resources :merchants
blocks could be consolidated.
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.
Also, many of these routes only work for the currently logged in merchant. To me this implies that the merchant ID in the URL is redundant, and you could take this information from the session instead.
@order.order_items.each do |item| | ||
@product = Product.find(item.product_id) | ||
@product.stock -= item.quantity | ||
@product.save |
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 should be checking the return value of .save
here.
return false | ||
else | ||
return true | ||
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.
Because this method is used as a controller filter, you don't need the return
here - in fact, the return value is never read. Just redirecting is enough to make sure the action won't be run.
def consoldate_order_items(order_id, product_id, quantity) | ||
@order_items = OrderItem.where(order_id: order_id) | ||
product_id = product_id.to_i | ||
quantity = quantity.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.
I like that you've separated this out into its own method!
This functionality might be a good candidate for a model method, perhaps an instance method on Order
. You would have to rework the way you report status to the user a bit.
params[:order].each do |key, value| | ||
if value == "" | ||
flash[:status] = :failure | ||
flash[:message] = "Any of required fields can't be empty" |
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 seems like a job for validations. Maybe a Payment
needs to be a separate model, and an Order
optionally has_one
Payment
.
flash[:message] = "Any of required fields can't be empty" | ||
redirect_to edit_order_path(@order) | ||
return | ||
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.
Instead of doing a redirect_to
here you should use render
, so that data the user has entered will stay in the form to get fixed.
|
||
describe CategoriesController do | ||
describe "correct logged in user" do | ||
before do |
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 very much like the pattern of splitting these tests into 3 sub-categories.
#Assert | ||
#1. gave the order a cart | ||
OrderItem.first.order_id.wont_equal nil | ||
#2. set the session order 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.
Good organization
merchant: eva | ||
|
||
two: | ||
name: product2 |
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.
Pro tip: you can use ERB in your fixture files!
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