Conversation
Media RankerWhat We're Looking For
|
| end | ||
|
|
||
| describe "relations" do | ||
| it "will have 0 votes" do |
There was a problem hiding this comment.
probably should be it "can have 0 votes" do
| belongs_to :user | ||
| belongs_to :work | ||
|
|
||
| validates :user, presence: true, uniqueness: { scope: [:work] } |
| render :login_form, status: :bad_request | ||
| end | ||
| end | ||
| if @user.valid? |
There was a problem hiding this comment.
This if statement seems a little extra, maybe if you had an earlier return when the user isn't valid you wouldn't need this if.
| @@ -0,0 +1,22 @@ | |||
| class VotesController < ApplicationController | |||
| def create | |||
There was a problem hiding this comment.
Take a look at how big this method is. I suggest creating a method upvote on the work or user model. That might help you simplify this method a bit.
| @@ -0,0 +1,70 @@ | |||
| class WorksController < ApplicationController | |||
| before_action :find_work, except: [:index, :new, :create] | |||
| @work.destroy | ||
| redirect_to root_path | ||
| else | ||
| head :not_found |
There was a problem hiding this comment.
Maybe instead of head now we should do a redirect with an error message to the user with flash.
| let(:user) { users(:three) } | ||
| let(:work) { works(:one) } | ||
| describe "Votes#create" do | ||
| it "will create a vote if logged in" do |
There was a problem hiding this comment.
You need a test for the action if they're not logged in, and a test for a duplicate vote
| category: "book", | ||
| id: work.id } } | ||
| expect { | ||
| post works_path, params: work_param |
There was a problem hiding this comment.
Wait a minute! this is a post request not a patch!!!!!!
| id: work.id } } | ||
| expect { | ||
| post works_path, params: work_param | ||
| }.must_change "Work.count", 1 |
There was a problem hiding this comment.
Also update shouldn't be changing the count of works!
making changes to test travis ci
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?