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...?)
|
beccaelenzil
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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_tenandspotlightwere methods I created to get the top 10 voted works and also it displays the most voted work out of the 3 categories.sessionandflash? What is the difference between them?