Skip to content
Extraits de code Groupes Projets
Valider cb9fb0ad rédigé par zhitomirskiyi's avatar zhitomirskiyi
Parcourir les fichiers

IZ local comment destroy

parent 4164ceaf
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -20,4 +20,14 @@ 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,5 +8,8 @@
.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,4 +57,27 @@ 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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter