-
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
ports - sav #36
base: master
Are you sure you want to change the base?
ports - sav #36
Conversation
Media RankerWhat We're Looking For
|
end | ||
|
||
describe "relations" do | ||
it "will have 0 votes" 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.
probably should be it "can have 0 votes" do
belongs_to :user | ||
belongs_to :work | ||
|
||
validates :user, presence: true, uniqueness: { scope: [: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.
Nice!
render :login_form, status: :bad_request | ||
end | ||
end | ||
if @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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] |
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.
Nice a filter!
@work.destroy | ||
redirect_to root_path | ||
else | ||
head :not_found |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
session
andflash
? What is the difference between them?