Skip to content

Conversation

@hanalways
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. In the work model I wrote an instance method entries with an argument category where it would return the array of records in the category sorted by highest vote count.
Describe how you approached testing that model method. What edge cases did you come up with? If publication year for a work was after the current year.
What are session and flash? What is the difference between them? flash only hangs around for 1 request cycle and session lasts until the browser closed (the session ends), or until it’s set to nil manually.
What was one thing that you gained more clarity on through this assignment? Testing controllers and how routes are directing request/responses.
What is the Heroku URL of your deployed application? hanaworks.heroku-app,.com (NOT WORKING)
Do you have any recommendations on how we could improve this project for the next cohort? Oof, more in class project time. Encouragement to directly apply the things in lecture to the project at hand? I felt myself completely zoning out in so many lectures and having a hard time staying focused. I know that it was stage 2, but some of the things I learned in class I wanted to implement immediately but got backburnered (session and flash) and then some lessons felt not necessarily immediately applicable to the project (application helpers). The whole lesson on prettifying time passed felt really disjointed from the project.

@droberts-sea
Copy link

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
Rails fundamentals (RESTful routing, use of named paths) some extra routes generated
Views are well-organized (DRY, use of semantic HTML, use of partials) yes - good work!
Errors are reported to the user sometimes - this is definitely worth working on! Doing a good job of reporting errors is not just good for your users, it will make your life as a developer much easier.
Business logic lives in the models yes
Models are thoroughly tested, including relations, validations and any custom logic Would love to see test cases for the entries and top_ten methods. What happens when there are no works, or no votes? What if there are more or less than 10 works?
Controllers are thoroughly tested, including the login/logout process and multi-step workflows like voting for a work mostly - see inline
Wave 1 - Media
Splash page shows the three media categories yes
Basic CRUD operations on media are present and functional yes - You can't delete a work that has votes! This is because you've created a link between the two tables at the database level, and deleting the work would leave behind invalid votes. You might want to check out the dependent argument to has_many.
Wave 2 - Users and Votes
Users can log in and log out yes
The ID of the current user is stored in the session yes
A user cannot vote for the same media more than once yes
All media lists are ordered by vote count yes
Splash page contains a media spotlight yes, but it displays a random work instead of the top-voted one
Wave 3 - Users and Votes
Media pages contain lists of voting users yes
Individual user pages and the user list are present User list doesn't work. Individual user pages are there but vote lists are empty.
Optional - Styling
Bootstrap is used appropriately yes
Look and feel is similar to the original this gets pretty close
Overall Good work overall. While this submission has some rough edges, the core functionality matches the demo site and it is clear to me that the learning goals for this project were met. Keep up the hard work!

<td><%= work.publication_year %></td>
<td>
<%= button_to "Upvote", new_vote_path(work), method: :post %>
</td>

Choose a reason for hiding this comment

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

This button doesn't seem to work. You might want create_vote_path(@work)

root "homepage#index"
get "/", to: "homepages#index"

resources :works, :users, :votes

Choose a reason for hiding this comment

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

I don't think you need all 7 RESTful routes for users and votes.

else
flash[:error] = "A problem occured"

redirect_back(fallback_location: root_path)

Choose a reason for hiding this comment

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

It would be good to give a little more information here about what went wrong, both for the user and for you as the engineer working on the product.

def vote
if session[:user_id]
voter_id = session[:user_id]
vote = Vote.new(user_id: voter_id, work_id: @work.id)

Choose a reason for hiding this comment

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

You have controller actions for both votes#create and works#vote. Probably only one of these is needed (I think votes#create is the one used by the app).

def create
@vote = Vote.new(
user_id: 1,
work_id: params[:work_id]

Choose a reason for hiding this comment

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

Instead of setting user_id to 1 here, you should set it to session[:user_id].

As is, every vote always comes from user 1 instead of whoever is logged in.


def self.top_ten(category)
return entries(category)[0..9]
end

Choose a reason for hiding this comment

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

I love the way the methods in this file build on each other, each providing a small bit of functionality. This is an excellent example of functional decomposition.

<% Work.categories.each do |category| %>
<div class="col">
<p class="column head">Top <%= category.capitalize %>s</p>
<% Work.top_ten(category).each do |work| %>

Choose a reason for hiding this comment

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

Great work keeping this view DRY.

describe HomepageController do
# it "must be a real test" do
# flunk "Need real tests"
# end

Choose a reason for hiding this comment

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

Looks like this was forgotten. Aside from the nominal case, there's an interesting edge case when there are no works, since the spotlight section might fail to render.

it "will create new user" do
user_data = {
user: {
username: "new user",

Choose a reason for hiding this comment

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

Good work getting both of the success cases here. There is also a failure case you're missing: what if the user can't be created? For example, if the username is "".

describe VotesController do
# it "must be a real test" do
# flunk "Need real tests"
# end

Choose a reason for hiding this comment

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

There are some interesting test cases around voting that I wish you had had time to address.

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