Ampers Steffany#40
Conversation
…ex view to display votes for each publication
Media RankerWhat We're Looking For
|
| end | ||
|
|
||
| def create | ||
| @publication = Publication.new(publication_params) |
There was a problem hiding this comment.
What about errors/flash notices here and in the update, destroy etc actions?
| end | ||
|
|
||
| def show | ||
| @user = User.find(params[:id]) |
There was a problem hiding this comment.
You should probably have some error handling here incase you can't find that specific user.
| @publication.save ? (redirect_to publication_path(@publication[:id])) : (render :new) | ||
| end | ||
|
|
||
| def destroy |
There was a problem hiding this comment.
shouldn't I need to be logged in to delete, upvote, update or create a work?
| post '/login', to: 'sessions#create', as: 'login' | ||
| delete '/logout', to: 'sessions#destroy', as: 'logout' | ||
|
|
||
| resources :votes |
There was a problem hiding this comment.
Do you need all the routes here for votes? I think you should only have a route to create a vote, maybe nested under publications You wouldn't need a route for index, or new
| <%= csrf_meta_tags %> | ||
| <link rel="shortcut icon" type="image/x-icon" href="https://media-ranker-2-0.herokuapp.com/assets/favicon-910822ff6cd5f6d37119171c4b716f1d4e5fe0e8ad5e408627659ebf8d7f16b1.ico", alt: "site logo, an owl"> | ||
| </head> | ||
| <header class="page-header"> |
There was a problem hiding this comment.
The header, and main must be inside the body element.
| describe Publication do | ||
|
|
||
| describe 'publication' do | ||
|
|
There was a problem hiding this comment.
You also need to have a test that a valid publication is valid, maybe using a fixture.
| end | ||
| end | ||
|
|
||
| describe 'self.find_votes' do |
There was a problem hiding this comment.
You also need to test edge-cases, maybe where a work has no votes, or there are no votes in the system, etc.
|
|
||
| it "requires a name" do | ||
| user = users(:bob) | ||
| user.name = "" |
There was a problem hiding this comment.
Odd, I was able to log into the site without giving my name, so something is strange here. Maybe you need to make sure that user.name must not be nil
| number_votes = Publication.find_votes(publication.category) | ||
| number_votes.length.must_equal 2 | ||
| end | ||
| end |
There was a problem hiding this comment.
What about testing the spotlight, and highest?
| session[:user_id] = @user.id | ||
| flash[:success] = "Successfully logged in as existing user #{@user.name}." | ||
| else | ||
| @user = User.create(name: params[:user][:name]) |
There was a problem hiding this comment.
You should have a check here to see if the create worked. What if someone tried to login with a space in their name?
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?