mirror of
https://github.com/diaspora/diaspora.git
synced 2026-04-29 03:01:03 -04:00
Post deletion now deletes comments
This commit is contained in:
@@ -23,6 +23,7 @@ class Post
|
||||
after_save :notify_friends
|
||||
|
||||
before_destroy :propagate_delete
|
||||
after_destroy :destroy_comments
|
||||
|
||||
def self.stream
|
||||
Post.sort(:created_at.desc).all
|
||||
@@ -43,6 +44,10 @@ class Post
|
||||
|
||||
|
||||
protected
|
||||
def destroy_comments
|
||||
comments.each{|c| c.destroy}
|
||||
end
|
||||
|
||||
def propagate_delete
|
||||
Retraction.for(self).notify_friends
|
||||
end
|
||||
|
||||
@@ -83,5 +83,15 @@ describe Post do
|
||||
(message.to_xml.to_s.include? @user.email).should == true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'deletion' do
|
||||
it 'should delete a posts comments on delete' do
|
||||
post = Factory.create(:status_message, :person => @user)
|
||||
@user.comment "hey", :on=> post
|
||||
post.destroy
|
||||
Post.all(:id => post.id).empty?.should == true
|
||||
Comment.all(:text => "hey").empty?.should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user