unliking works right now minus on-page feedback

This commit is contained in:
danielgrippi 2011-05-06 11:38:07 -07:00 committed by Raphael Sofaer
parent 8b081a48b4
commit eadede966f
3 changed files with 5 additions and 4 deletions

View file

@ -43,7 +43,7 @@ class LikesController < ApplicationController
end
def destroy
if @like = Like.where(:id => params[:id], :author_id => current_user.person.id).first
if @like = Like.where(:post_id => params[:post_id], :author_id => current_user.person.id).first
current_user.retract(@like)
respond_to do |format|
format.mobile{ redirect_to @like.post }

View file

@ -45,7 +45,7 @@
- if !current_user.liked?(post)
= link_to t('.like'), likes_path(:positive => 'true', :post_id => post.id ), :method => :post, :class => "like_it", :remote => true
- else
= link_to t('.unlike'), likes_path(:post_id => post.id ), :method => :delete, :class => "like_it", :remote => true
= link_to t('.unlike'), like_path(:post_id => post.id, :id => 'xxx'), :method => :delete, :class => "like_it", :remote => true
/|
/= link_to t('.dislike'), like_path(:positive => 'false', :post_id => post.id), :method => :post, :class => "dislike_it", :remote => true

View file

@ -82,16 +82,17 @@ describe LikesController do
it 'lets a user destroy their like' do
alice.should_receive(:retract).with(@like)
delete :destroy, :format => "js", :id => @like.id
delete :destroy, :format => "js", :post_id => @like.post_id, :id => @like.id
response.status.should == 204
end
it 'does not let a user destroy other likes' do
pending "not really relevant to how we're using the destory method. not totally RESTful right now"
like2 = eve.build_like(true, :on => @message)
like2.save
alice.should_not_receive(:retract)
delete :destroy, :format => "js", :id => like2.id
delete :destroy, :format => "js", :post_id => like2.post_id, :id => like2.id
response.status.should == 403
end
end