diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 46c56fd0b..fd8e77063 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -32,7 +32,7 @@ class LikesController < ApplicationController end def destroy - if @like = Like.where(:post_id => params[:post_id], :author_id => current_user.person.id).first + if @like = Like.where(:id => params[:id], :author_id => current_user.person.id).first current_user.retract(@like) else respond_to do |format| diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 6e5a0d216..ee99e5339 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -81,19 +81,18 @@ describe LikesController do end it 'lets a user destroy their like' do - alice.should_receive(:retract).with(@like) - delete :destroy, :format => "js", :post_id => @like.post_id, :id => @like.id - response.should be_success + expect { + delete :destroy, :format => "js", :post_id => @like.post_id, :id => @like.id + }.should change(Like, :count).by(-1) 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", :post_id => like2.post_id, :id => like2.id - response.status.should == 403 + expect { + delete :destroy, :format => "js", :post_id => like2.post_id, :id => like2.id + }.should_not change(Like, :count) end end end