Time - Angela#44
Conversation
Media RankerFunctional Requirements: Manual Testing
Major Learning Goals/Code Review
Previous Rails learning, Building Complex Model Logic, DRYing up Rails Code
Testing Rails Apps
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
SummaryNicely done you satisfied all the learning goals and several more advanced features. Nice work getting an API working and scope functioning. Well done. There are a few bugs, so check out my comments in your code. Otherwise outstanding work. |
| assert_no_difference("IceCream.count") do | ||
| patch ice_cream_url(ice_cream), params: { ice_cream: { base_flavor: ice_cream.base_flavor, brand: ice_cream.brand, category: ice_cream.category, description: ice_cream.description, name: nil } } | ||
| end | ||
| must_redirect_to edit_ice_cream_url |
There was a problem hiding this comment.
A render is not a redirect. That's why this is failing.
| @@ -0,0 +1,104 @@ | |||
| class IceCreamsController < ApplicationController | |||
There was a problem hiding this comment.
Interesting that you did this as both an API and a web application.
| @@ -0,0 +1,14 @@ | |||
| Rails.application.routes.draw do | |||
| end | ||
|
|
||
| describe "custom methods" do | ||
| it "retrieves all records matching a given category filter" do |
There was a problem hiding this comment.
You should also have a test when there are no ice creams in the category.
| @@ -0,0 +1,22 @@ | |||
| require "test_helper" | |||
|
|
|||
| describe Vote do | |||
There was a problem hiding this comment.
You should also have a test on a validation that the combination user and ice_cream_id are unique.
| def set_user | ||
| @user = User.find(params[:id]) | ||
| end |
There was a problem hiding this comment.
Since you're using this method in two controllers you can move it to the ApplicationController and both would inherit it.
| end | ||
|
|
||
| must_redirect_to ice_cream_url(IceCream.last) | ||
| assert_equal "Successfully added new ice cream: <a href=\"/ice_creams/#{IceCream.last.id}\">#{IceCream.last.name}</a>.", flash[:success] |
There was a problem hiding this comment.
This is an assert-style test instead of using the expect style.
There was a problem hiding this comment.
Also why do you have a link in here?
| get login_url, headers: { HTTP_REFERER: ref_path } | ||
| end | ||
|
|
||
| it "sets existing user to session and redirects to referer" do |
There was a problem hiding this comment.
You should also have a test with an invalid user name.
| @@ -0,0 +1,39 @@ | |||
| <section> | |||
| <%= form_with model: @ice_cream, url: ice_creams_path do |f| %> | |||
There was a problem hiding this comment.
To be able to properly update an icecream you should leave off the url.
| <%= form_with model: @ice_cream, url: ice_creams_path do |f| %> | |
| <%= form_with model: @ice_cream do |f| %> |
| private | ||
| # Use callbacks to share common setup or constraints between actions. | ||
| def set_ice_cream | ||
| @ice_cream = IceCream.find(params[:id]) |
There was a problem hiding this comment.
I very much suggest you use find_by or rescue the exception. If I try to go to a deleted icecream I get an exception!
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?Assignment Submission: Media Ranker
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
sessionandflash? What is the difference between them?