Conversation
Media RankerWhat We're Looking For
|
| root "homepages#index" | ||
|
|
||
| resources :works | ||
| resources :users, only: [:index, :show] |
There was a problem hiding this comment.
Good work only generating the routes you need here.
| belongs_to :user | ||
|
|
||
| validates :user, uniqueness: {scope: :work, | ||
| message: "User can only vote on this work one time"} |
There was a problem hiding this comment.
Good work getting this tricky uniqueness scope figured out!
|
|
||
| def self.get_top_ten(category) | ||
| return self.sorted_works(category)[0...10] | ||
| end |
There was a problem hiding this comment.
I love the way the methods in this file build on each other, each providing a small bit of functionality. This is an excellent example of functional decomposition.
| </tr> | ||
| <% Work.sorted_works(category).each do |work| %> | ||
| <tr> | ||
| <td><%= work.votes.count %></td> |
There was a problem hiding this comment.
I'm not a huge fan of calling a model method directly from the view like this - would it be possible to "tee up" this data in the controller?
|
|
||
| describe "login" do | ||
| it "will login user" do | ||
| post login_path, params: @login_data |
There was a problem hiding this comment.
You have two tests here, but these are only covering one behavior mode for this controller action (logging in an existing user). I would probably combine these into one.
However, there are a couple of behavior modes you're not covering:
- Logging in a new user (should create that user)
- Attempting to log in with an invalid username (e.g. empty string) (should fail)
| describe "logout" do | ||
| it "will logout user" do | ||
| perform_login | ||
| post logout_path |
There was a problem hiding this comment.
What happens if no one is logged in?
| describe "upvote" do | ||
| it "disallows guest users voting if they have not logged in" do | ||
| user = users(:kelly) | ||
| work = works(:amelie) |
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?