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

Yolotzin - Time #54

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

Yolotzin - Time #54

wants to merge 61 commits into from

Conversation

ydunbar
Copy link

@ydunbar ydunbar commented Jun 4, 2020

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. For the Work model I wrote a top_ten method, which takes a category as a parameter and then sorts media of that category by the number of votes it has, and returns the first 10 top rated works.
Describe how you approached testing that model method. What edge cases did you come up with? Given a list of media, up to 10 media should be returned. If one media has the most votes it should be returned first. And edge case would be if there are no media, less than 10 media, if there are media with no votes, or if there is media with tied votes.
What are session and flash? What is the difference between them? Sessions stores information about users that can persist until the user logs out. Flash stores error messages from the last request which can be displayed in the View in the current request cycle or it can persist to the next. They are different in the duration and intention of their use.
What was one thing that you gained more clarity on through this assignment? I gained more clarity on how to handle many-to-many relationships in a Rails schema.
What is the Heroku URL of your deployed application? I've had trouble with trying to host on Heroku, and may need help troubleshooting the errors I'm getting.

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?

ydunbar added 30 commits May 13, 2020 17:20
ydunbar added 28 commits May 20, 2020 15:11
…er, with session routes and ERB login form and current view
@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 ✔️, but not using a flash notice!
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 ✔️
8. Can delete this work successfully ✔️, but you can't delete a work that has votes.
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) ⚠ You don't redirect the user if the work doesn't exist. This causes the site to crash
10. Verify that the "View all users" page lists no users ✔️, yes once I destroyed all your users
Log in --
11. Logging in with a valid name changes the UI to "Logged in as" and "Logout" buttons ⚠ no changes to UI for logged in and logged out users
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 ⚠ App is not 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 ⚠ Extra routes on USersController
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 ⚠ You aren't using view partials nearly enough. See my inline comments.
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 ⚠ instead you have a require_login controller. I strongly suggest using a filter to find the current 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 ⚠ no fixtures :(
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) ⚠ No validations or tests for validations on 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 ⚠ missing tests

Overall Feedback

Overall Feedback Criteria yes/no
Yellow (Approaches Standards) 12+ in Functional Requirements: Manual Testing && 11+ in Code Review, or the instructor judges that this project needs special attention ✔️, some missing requirements in code review. Particularly in testing.

Code Style Bonus Awards

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

Summary

To be clear your testing is very rough. You have a lot of things to work on there. You did get the basic functionality working. Take a look at my inline comments. I'd like you to particularly pay attention to my comments on testing and see what you can do to do better there in the bEtsy project. Maybe take on this responsibility with your team so that you can improve.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Note: You are indenting with 4 spaces instead of 2. At Ada our standard indentation is 2 spaces.

Comment on lines +45 to +49
it "can get the new_work_path" do
get new_work_path

must_respond_with :success
end

Choose a reason for hiding this comment

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

This test is failing because you're requiring the user to log in first before they can get to the form.

This would also require you provide a user fixture.

Suggested change
it "can get the new_work_path" do
get new_work_path
must_respond_with :success
end
it "can get the new_work_path" do
perform_login()
get new_work_path
must_respond_with :success
end

end
end

describe "create" do

Choose a reason for hiding this comment

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

These tests also require the user log in first (See above). Also you should test what happens when a guest user tries to create a work.

# Arrange
invalid_work_id = -1
# Act
get "/works/#{invalid_work_id}"

Choose a reason for hiding this comment

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

Suggested change
get "/works/#{invalid_work_id}"
get work_path(invalid_work_id)

end

def find_work
@work = Work.find_by_id(params[:id])

Choose a reason for hiding this comment

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

You need to do something if the work does not exist.

Suggested change
@work = Work.find_by_id(params[:id])
@work = Work.find_by_id(params[:id])
if @work.nil?
flash[:error] = "That work does not exist"
redirect_to root_path
end

}.must_differ 'Work.count', -1

must_respond_with :redirect

Choose a reason for hiding this comment

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

Suggested change
end

fixtures :all

# Add more helper methods to be used by all tests here...
def perform_login(user = nil)

Choose a reason for hiding this comment

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

👍

Comment on lines +3 to +6
<% @work.errors.each do |column, message| %>
<li>
<strong><%= column.capitalize %></strong> <%= message %>
</li>

Choose a reason for hiding this comment

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

This is better using a flash notice

Comment on lines +3 to +7
<% @work.errors.each do |column, message| %>
<li>
<strong><%= column.capitalize %></strong> <%= message %>
</li>
<% end %>

Choose a reason for hiding this comment

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

Again better using a flash notice.

@@ -0,0 +1,30 @@
class Work < ApplicationRecord
has_many :votes

Choose a reason for hiding this comment

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

If you want to destroy any votes for this work

Suggested change
has_many :votes
has_many :votes, dependent: :destroy

belongs_to :work
belongs_to :user

validates :user_id, uniqueness: { scope: :work_id }

Choose a reason for hiding this comment

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

👍

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