Open
Conversation
…re no works in database
… vote count. added buttons at bottom page for works_path
…html code in work details page to display votes per work and table of users and date voted
…model method that returns user associated with session user id
This reverts commit 442ffdf.
…d on the website to the user
… invalid work and in the update action, and to return a not found if the work doesn't exist in the destroy action
Media RankerWhat We're Looking For
|
CheezItMan
reviewed
May 9, 2019
| puts "Created work: #{media.inspect}" | ||
| end | ||
| end | ||
| puts "Added #{media.count} work records" |
There was a problem hiding this comment.
Notice that this variable was instantiated inside the forEach loop, and so doesn't have scope here at the puts line.
| expect { | ||
| post work_votes_path(work.id) | ||
| }.must_change "Vote.count", 1 | ||
| must_redirect_to root_path |
There was a problem hiding this comment.
This test is failing because creating a new vote redirects you to the work's show path.
| list_all_movies = Work.media_votes("movie") | ||
| expect(list_all_movies[0]).must_equal monkey | ||
| expect(list_all_movies[1]).must_equal works(:avengers) | ||
| expect(list_all_movies[2]).must_equal works(:random8) |
|
|
||
| describe "#user" do | ||
| it "finds the user associated with a user id" do | ||
| expect(User.user(user_valid.id)).must_equal user_valid |
There was a problem hiding this comment.
I'm not sure what this user method is doing that you couldn't do with User.find
| end | ||
|
|
||
| describe "#vote_count" do | ||
| it "returns the number of votes taken by a given user" do |
There was a problem hiding this comment.
It would also be good to have a test when the user has no votes.
| end | ||
| end | ||
|
|
||
| describe "update" do |
| @@ -0,0 +1,16 @@ | |||
| Rails.application.routes.draw do | |||
| # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | |||
| resources :works, only: [:index, :new, :create, :show, :edit, :update, :destroy] | |||
|
|
||
| resources :users, only: [:index, :show] | ||
|
|
||
| resources :works do |
| <th scope ="col">Voted On</th> | ||
| </thead> | ||
| <tbody> | ||
| <%@user.works.each do |work|%> |
There was a problem hiding this comment.
Could you use this kind of table in a partial?
| has_many :votes | ||
| has_many :works, through: :votes | ||
|
|
||
| def self.user(user_id) |
There was a problem hiding this comment.
I'm not sure the point of this method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?