-
Notifications
You must be signed in to change notification settings - Fork 47
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
Sockets - Cyndi #34
base: master
Are you sure you want to change the base?
Sockets - Cyndi #34
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
|
puts "Created work: #{media.inspect}" | ||
end | ||
end | ||
puts "Added #{media.count} work records" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is apparently the wrong work
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be good to have a test when the user has no votes.
end | ||
end | ||
|
||
describe "update" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good tests for update
@@ -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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do only:
, you use all routes.
|
||
resources :users, only: [:index, :show] | ||
|
||
resources :works do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another set of routes for works
?
<th scope ="col">Voted On</th> | ||
</thead> | ||
<tbody> | ||
<%@user.works.each do |work|%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the point of this method.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
session
andflash
? What is the difference between them?