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

Time - Angela #44

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

Time - Angela #44

wants to merge 103 commits into from

Conversation

angethuy
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. My IceCream model has a "by_category" scope for retrieving ice creams matching a given category.
Describe how you approached testing that model method. What edge cases did you come up with? I added my custom methods towards the end of my process and did not allot myself enough time to do thorough testing. Currently, the only model test for "by_category" retrieves the only fixture that matches the given category and makes sure that the result count is as expected (all whopping 1 of it). Future to-do includes testing for edge cases of: what happens when there are no records that match the scope? What happens when we somehow request a category that is not a valid category as defined by our class constant?
What are session and flash? What is the difference between them? Session and flash are rails-provided Hash-ish structures that allow us to store useful data throughout the lifetime of our application. Anything stored in session persists until 1) user quits their browser session and clears their cache (dependent on browser behavior), 2) the app manually deletes items from session or clears session completely. In contrast, data stored in flash remain only until the next response cycle.
What was one thing that you gained more clarity on through this assignment? I gained more clarity on: 1) juggling variables between models, classes, and views, 2) custom forms, 3) helpers vs partials, 4) testing with let/before, 5) TURBOLINKS IS SOMETIMES PAINFUL, 6) redirecting back vs redirecting to referrer (and how it's a funny typo!), 7) custom routes, 8) models without controllers.
What is the Heroku URL of your deployed application? https://shrouded-dawn-42890.herokuapp.com

Assignment Submission: Media Ranker

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Prompt Response
What was a custom model method you wrote? What was it responsible for doing?
Describe how you approached testing that model method. What edge cases did you come up with?
What are session and flash? What is the difference between them?
What was one thing that you gained more clarity on through this assignment?
What is the Heroku URL of your deployed application?

@CheezItMan
Copy link

Media Ranker

Functional Requirements: Manual Testing

Criteria yes/no
Before logging in --
1. On index page, there are at most 10 pieces of media on three lists, and a Media Spotlight ✔️
2. Can go into a work's show page ✔️
3. Verify unable to vote on a work, and get a flash message ✔️
4. Can edit this work successfully, and get a flash message ✔️
5. Can go to "View all media" page and see three lists of works, sorted by vote ✔️
6. Verify unable to create a new work when the form is empty, and details about the validation errors are visible to the user through a flash message ✔️
7. Can create a new work successfully. Note the URL for this work's show page ✔️, however you have a weird link text in the flash notice
8. Can delete this work successfully ✔️
9. Going back to the URL of this deleted work's show page produces a 404 or some redirect behavior (and does not try to produce a broken view) ⚠ This fails because you have a find and not find_by in your filter.
10. Verify that the "View all users" page lists no users ✔️
Log in --
11. Logging in with a valid name changes the UI to "Logged in as" and "Logout" buttons ✔️
12. Your username is listed in "View all users" page ✔️
13. Verify that number of votes determines the Media Spotlight ✔️
14. Voting on several different pieces of media affects the "Votes" tables shown in the work's show page and the user's show page ✔️
15. Voting on the same work twice produces an error and flash message, and there is no extra vote ✔️
Log out --
16. Logging out showed a flash message and changed the UI ✔️
17. Logging in as a new user creates a new user ✔️
18. Logging in as an already existing user has a specific flash message ✔️

Major Learning Goals/Code Review

Criteria yes/no
1. Sees the full development cycle including deployment, and the app is deployed to Heroku ✔️
2. Practices full-stack development and fulfilling story requirements: the styling, look, and feel of the app is similar to the original Media Ranker ✔️
3. Practices git with at least 25 small commits and meaningful commit messages ✔️

Previous Rails learning, Building Complex Model Logic, DRYing up Rails Code

Criteria yes/no
4. Routes file uses resources for works ✔️
5. Routes file shows intention in limiting routes for voting, log-in functionality, and users ✔️
6. The homepage view, all media view, and new works view use semantic HTML ✔️
7. The homepage view, all media view, and new works view use partials when appropriate ✔️
8. The model for media (likely named work.rb) has_many votes ✔️
9. The model for media has methods to describe business logic, specifically for top ten and top media, possibly also for getting works by some category ✔️
10. Some controller, likely the ApplicationController, has a controller filter for finding a logged in user ✔️
11. Some controller, likely the WorksController, has a controller filter for finding a work ✔️
12. The WorksController uses strong params ✔️
13. The WorksController's code style is clean, and focused on working with requests, responses, params, session, flash ✔️

Testing Rails Apps

Criteria yes/no
14. There are valid fixtures files used for users, votes, and works ✔️
15. User model has tests with sections on validations (valid and invalid) and relationships (has votes) ✔️
16. Vote model has tests with sections on validations (valid and invalid) and relationships (belongs to a user, belongs to a vote) ✔️
17. Work model has tests with sections on validations (valid and invalid) and relationships (has votes) ✔️
18. Work model has tests with a section on all business logic methods in the model, including their edge cases ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 14+ in Functional Requirements: Manual Testing && 14+ in Code Review ✔️

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

Summary

Nicely 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

Choose a reason for hiding this comment

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

A render is not a redirect. That's why this is failing.

@@ -0,0 +1,104 @@
class IceCreamsController < ApplicationController

Choose a reason for hiding this comment

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

Interesting that you did this as both an API and a web application.

@@ -0,0 +1,14 @@
Rails.application.routes.draw do

Choose a reason for hiding this comment

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

Nicely done here.

end

describe "custom methods" do
it "retrieves all records matching a given category filter" do

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

You should also have a test on a validation that the combination user and ice_cream_id are unique.

Comment on lines +67 to +69
def set_user
@user = User.find(params[:id])
end

Choose a reason for hiding this comment

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

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]

Choose a reason for hiding this comment

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

This is an assert-style test instead of using the expect style.

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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| %>

Choose a reason for hiding this comment

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

To be able to properly update an icecream you should leave off the url.

Suggested change
<%= 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])

Choose a reason for hiding this comment

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

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants