parent
34179d60db
commit
77fe7a1462
3 changed files with 0 additions and 36 deletions
|
|
@ -20,14 +20,4 @@ class CommentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
target = Comment.where(:diaspora_handle => current_user.diaspora_handle, :id => params[:id]).first
|
||||
|
||||
if target
|
||||
target.destroy
|
||||
end
|
||||
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,8 +8,5 @@
|
|||
.from
|
||||
= link_to post.person.real_name, post.person
|
||||
= markdownify(post.text)
|
||||
- if current_user.owns?(post)
|
||||
.right
|
||||
= link_to t('delete'), comment_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete"
|
||||
%div.time
|
||||
= "#{time_ago_in_words(post.updated_at)} #{t('ago')}"
|
||||
|
|
|
|||
|
|
@ -57,27 +57,4 @@ describe CommentsController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroy' do
|
||||
before do
|
||||
friend_users(user, aspect, user2, aspect2)
|
||||
@post = user2.post :status_message, :message => 'GIANTS', :to => aspect2.id
|
||||
@comment1 = user.comment("yay", :on => @post)
|
||||
@comment2 = user2.comment("gogogo", :on => @post)
|
||||
end
|
||||
|
||||
it 'deletes a comment made by that user' do
|
||||
@post.reload.comments.count.should be 2
|
||||
delete :destroy, :id => @comment1.id
|
||||
Comment.find_by_id(@comment1.id).should be nil
|
||||
@post.reload.comments.count.should be 1
|
||||
end
|
||||
|
||||
it 'does not delete a comment made by another user' do
|
||||
@post.reload.comments.count.should be 2
|
||||
delete :destroy, :id => @comment2.id
|
||||
Comment.find_by_id(@comment2.id).should_not be nil
|
||||
@post.reload.comments.count.should be 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue