Skip to content

Conversation

@marikoja
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. I created a class method called ordered_works in my work model. This method take a parameter of category and then sorts the works in the category by number of votes. The method returns an array of works sorted from highest vote count to lowest.
Describe how you approached testing that model method. What edge cases did you come up with? To create my tests I started with a valid input and then removed one thing at time to break the thing in question. for validations of user_name I tested edge cases of nil, an empty string, and a duplicate name.
What are session and flash? What is the difference between them? Session and flash are similar notices provided to the user but flash is not cached in the browser data.
Describe a controller filter you wrote. I use a controller filter called current_user to find the user that is currently logged in.
What was one thing that you gained more clarity on through this assignment? This project has helped me gain a somewhat better understanding of a lot of rails. Overall I feel much more comfortable knowing where to begin a rails project and how to maintain productivity throughout.
What is the Heroku URL of your deployed application? https://media-ranker-ampers-ma.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort? This project was challenging all around but mostly overwhelming due to the deadline. I wish I had had a better understanding of flash, sessions and testing.

marikoja and others added 27 commits April 9, 2018 16:22
…ace for top media, and top ten for each category
…ks show pages. Oh and nested routes for votes create.
…er is informed of what errors occured based on validations.
…ted user show view, probably other shit too.
…ique to category. Users must be logged in to vote.
@CheezItMan
Copy link

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene "GAHHHH SPELLING who needs it? oh me if I want to use heroku," made me crack up. Overall good hygiene.
Comprehension questions Check, flash is only cached for 1 request.
General
Rails fundamentals (RESTful routing, use of named paths) You have extra route defined for users.
Semantic HTML Well done
Errors are reported to the user Yes, but you've got problems reporting errors on works to the user.
Business logic lives in the models Check, well done with the method in the Work model.
Models are thoroughly tested, including relations, validations and any custom logic You have pretty good tests, I left some comments on tests and validations. You need to do more edge-case testing on custom methods and you can validate that the category is a limited set of options.
Wave 1 - Media
Splash page shows the three media categories Check
Basic CRUD operations on media are present and functional If I try to create or update a work it crashes.
Wave 2 - Users and Votes
Users can log in and log out Check
The ID of the current user is stored in the session Check
Individual user pages and the user list are present Check
A user cannot vote for the same media more than once Check
All media lists are ordered by vote count Check
Splash page contains a media spotlight Check
Media pages contain lists of voting users Check
Wave 3 - Styling
Foundation is used appropriately Check
Look and feel is similar to the original It look similar, not exact, but fairly similar
Overall Pretty good, you've got some issues with testing custom methods and reporting errors, I left notes in your code on some actions that crash your site. You hit all the major learning goal and showed a lot of mastery here.


root 'welcomes#index'

resources :users

Choose a reason for hiding this comment

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

Do you need all the routes for users?

redirect_to work_path(@work.id)
else
flash.now[:alert] = @work.errors
render :new

Choose a reason for hiding this comment

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

You need to set @valid_categories before trying to render :new

<% flash[:alert].each do |field, message| %>
<li>
<strong><%= field %>: </strong>
<%= message.join('') %>

Choose a reason for hiding this comment

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

This join is causing works error messages to crash the site.

session[:user_id] = @user.id
flash[:success] = "Welcome back #{@user.user_name}"
else
@user = User.create user_name: params[:user][:user_name]

Choose a reason for hiding this comment

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

You need to check to verify that create worked! I tried to log in with a blank username and got a "welcome" message! :p

belongs_to :user
belongs_to :work

validates :user, uniqueness: {scope: :work, message: "You have already voted for this title."}

Choose a reason for hiding this comment

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

🥇


def self.ordered_works(category)
works = Work.all.where(category: category).to_a
return works.sort_by {|work| -work.vote_count}

Choose a reason for hiding this comment

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

👍

class Work < ApplicationRecord
has_many :votes

validates :category, presence: {message: "Must provide a category"}

Choose a reason for hiding this comment

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

I would also ensure that the category can only be, "album", "book" or "movie"

end
end

describe 'ordered_works' do

Choose a reason for hiding this comment

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

You also need to test when:

  1. There are no works
  2. There are no votes
  3. One category has no votes.

#
describe 'media_spotlight' do
it "returns the work with the higest vote count" do
Work.media_spotlight.must_equal works(:work_one)

Choose a reason for hiding this comment

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

Again, what happens when there are no votes?

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