-
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
Time - Haben #34
base: master
Are you sure you want to change the base?
Time - Haben #34
Conversation
Media RankerFunctional Requirements: Manual Testing
Major Learning Goals/Code Review
Previous Rails learning, Building Complex Model Logic, DRYing up Rails Code
Testing Rails Apps
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
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.
Great job overall! Your implementation matches the demo site very closely, and the learning goals for this assignment were definitely met. Controller filters, partial views, flash, session, custom routes, custom model methods -- there's so much good stuff in there! I've left a few in-line comments for you to review. Keep up the hard work!
require "test_helper" | ||
|
||
describe WorksController do | ||
let(:work) { works(:one) } |
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.
These tests produced a number of errors. I think to access a variable when using let
, you don't use the @
symbol.
Minitest::UnexpectedError: ActionController::UrlGenerationError: No route matches {:action=>"edit", :controller=>"works", :id=>nil}, missing required keys: [:id]
test/controllers/works_controller_test.rb:30:in `block (2 levels) in <main>'
it "is invalid if title is nil" do | ||
@work.title = nil | ||
result = @work.valid? | ||
expect(work.category).must_equal "album" |
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 produced an error. Looks like you're missing an @
. Whoops!
expect(work.category).must_equal "album" | |
expect(@work.category).must_equal "album" |
@@ -0,0 +1,16 @@ | |||
<section class="top-ten__list-container"> |
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.
Great use of partial views to DRY up your code.
class Work < ApplicationRecord | ||
has_many :votes | ||
has_many :users, through: :votes | ||
validates :title, presence: true, uniqueness: { scope: :category } |
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 work getting this tricky uniqueness
scope figured out!
has_many :users, through: :votes | ||
validates :title, presence: true, uniqueness: { scope: :category } | ||
|
||
def self.books |
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.
Consider whether you could DRY this up with a single method such as get_by_category(category)
vote_4 = Vote.create(user_id: user1, work_id: work3) | ||
end | ||
|
||
it "spotlight" 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.
Be specific about what you are testing here. Makes sure it chooses the correct Work. What if two works are tied? This should probably be a separate test of an edge case. What if no works have been voted on?
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
top_ten
andspotlight
were methods I created to get the top 10 voted works and also it displays the most voted work out of the 3 categories.session
andflash
? What is the difference between them?