Open
Conversation
Media RankerWhat We're Looking For
|
CheezItMan
reviewed
Oct 18, 2017
| output.must_be_instance_of Hash | ||
| end | ||
|
|
||
| it "should return values that are arrays" do |
There was a problem hiding this comment.
I would also test that they are in the proper order...
| validates :title, presence: true | ||
| validates :title, uniqueness: true | ||
|
|
||
| def self.all_works_by_title |
There was a problem hiding this comment.
Shouldn't this be by the # of votes?
| let(:work) { Work.new } | ||
| let(:vote_1) { votes(:vote_1)} | ||
|
|
||
| it "must have a valid work and user to be valid" do |
There was a problem hiding this comment.
I would also add a test to verify that two votes can't have the same work_id and user_id.
So a user can't vote for the same work twice.
| describe MainPageController do | ||
| it "should get index" do | ||
| get main_page_index_url | ||
| value(response).must_be :success? |
There was a problem hiding this comment.
you could instead do:
must_respond_with :success
| post login_path, params: {username: "alyssa"} | ||
| }.must_change 'User.count', 1 | ||
| must_respond_with :redirect | ||
| must_redirect_to root_path |
There was a problem hiding this comment.
I would also test:
id = find_by(username: 'alyssa').id
id.must_equal session[:user_id]| proc { | ||
| post login_path, params: {username: nil} | ||
| }.must_change 'User.count', 0 | ||
| flash[:error].must_equal "User not logged in successfully" |
|
|
||
| describe SessionsController do | ||
|
|
||
| it "going to the login_form page is successful" do |
| }.must_change 'Vote.count', 0 | ||
| must_respond_with :redirect | ||
| must_redirect_to work_path(works(:anti).id) | ||
| flash[:error].must_equal "You've already upvoted this!" |
There was a problem hiding this comment.
I would also have a test voting for a work that doesn't exist, or voting if not logged in.
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?