Selamawit Ainalem - Amperes#28
Conversation
…ty for a user to submit a new work
… and test for a user to not be able to vote for the same work more than once (test not functioning properly yet.)
…rated date instead
… item on the homepage
…Added another button that will re-direct back to list of all media
… User is alerted to a successful login by a flash message
…tus. Also updated the sessions controller instance method name.
Media RankerWhat We're Looking For
|
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
|
|
||
| <title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title> |
There was a problem hiding this comment.
Maybe change "untitled" to something for your site.
| <%= csrf_meta_tags %> | ||
| </head> | ||
|
|
||
| <section id="intro"> |
There was a problem hiding this comment.
this section should be inside the body element.
|
|
||
| it 'An empty input will violate the presence validation' do | ||
| user = User.new() | ||
| assert_not user.valid? |
There was a problem hiding this comment.
You're mixing assert-style and spec-style testing here.
| end | ||
|
|
||
| it 'must be able to display associated users' do | ||
| vote.users[0].name.must_equal "Noe Body" |
There was a problem hiding this comment.
Since a vote should belong to only one user, this should be.
vote.user.name.must_equal "Noe Body"|
|
||
| end | ||
|
|
||
| it 'will return the highest rated work item' do |
There was a problem hiding this comment.
I would suggest grouping each custom method inside it's own describe block.
I would also test the method when there are no votes in the system.
| belongs_to :user | ||
| belongs_to :work | ||
|
|
||
| validates_uniqueness_of :work_id, :scope => [:user_id] |
| class HomepageController < ApplicationController | ||
| before_action :find_user | ||
| def index | ||
| @votes_hmp = Vote.all |
There was a problem hiding this comment.
You should probably find each group of works by category.
| <section class="top-ten"> | ||
| <h3>Top Movies</h3> | ||
| <ul> | ||
| <%Work.where(category: "Movie").top_ten.each do |top_movie|%> |
There was a problem hiding this comment.
Here "Movie", "Book" and "Album" shouldn't be capitalized!
Also this should be in the controller not the view.
| <th width="100">Upvotes</th> | ||
| </tr> | ||
| </thead> | ||
| <%Work.where(category:'album').each do |album|%> |
There was a problem hiding this comment.
Shouldn't these be ordered by the number of votes?
| session[:user_id] = @username.id | ||
| flash[:success] = "Successfully logged in as exisisting user #{@username.name} with ID #{@username.id}" | ||
| else | ||
| @username = User.create name: params[:user][:name] |
There was a problem hiding this comment.
Some checks to make sure that create worked properly would be better.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?