Commit 79d66909685530f4fab929e547e3ae1af0fefeff

Authored by Rodrigo Souto
1 parent 440535cf

comment: remove comment_as_thread method

This method was removed by ca5ebf95375cd5dbb80a047dc79f4c31e36df899
and was mistakenly included on this merge
4ad91064632c8c1f5483a559d158d96b93e1a3c6 due to this fix
70c90e476a2a263639d13654564b8ea9db30a911. Also its tests weren't
removed.
test/unit/comment_test.rb
@@ -285,35 +285,6 @@ class CommentTest < ActiveSupport::TestCase @@ -285,35 +285,6 @@ class CommentTest < ActiveSupport::TestCase
285 assert_equal [c1,c3], c.reload.children 285 assert_equal [c1,c3], c.reload.children
286 end 286 end
287 287
288 - should "return activities comments as a thread" do  
289 - person = fast_create(Person)  
290 - a = TextileArticle.create!(:profile => person, :name => 'My article', :body => 'Article body')  
291 - c0 = Comment.create!(:source => a, :body => 'My comment', :author => person)  
292 - c1 = Comment.create!(:reply_of_id => c0.id, :source => a, :body => 'bla', :author => person)  
293 - c2 = Comment.create!(:reply_of_id => c1.id, :source => a, :body => 'bla', :author => person)  
294 - c3 = Comment.create!(:reply_of_id => c0.id, :source => a, :body => 'bla', :author => person)  
295 - c4 = Comment.create!(:source => a, :body => 'My comment', :author => person)  
296 - result = a.activity.comments_as_thread  
297 - assert_equal c0, result[0]  
298 - assert_equal [c1, c3], result[0].replies  
299 - assert_equal [c2], result[0].replies[0].replies  
300 - assert_equal c4, result[1]  
301 - assert result[1].replies.empty?  
302 - end  
303 -  
304 - should "return activities comments when some comment on thread is spam" do  
305 - person = fast_create(Person)  
306 - a = TextileArticle.create!(:profile => person, :name => 'My article', :body => 'Article body')  
307 - c0 = Comment.create(:source => a, :body => 'Root comment', :author => person)  
308 - c1 = Comment.create(:reply_of_id => c0.id, :source => a, :body => 'c1', :author => person)  
309 - spam = Comment.create(:spam => true, :reply_of_id => c0.id, :source => a, :body => 'spam', :author => person)  
310 - c2 = Comment.create(:reply_of_id => spam.id, :source => a, :body => 'c2', :author => person)  
311 - result = a.activity.comments_as_thread  
312 - assert_equal c0, result[0]  
313 - assert_equal [c1], result[0].replies  
314 - assert_equal c2, result[1]  
315 - end  
316 -  
317 should 'provide author url for authenticated user' do 288 should 'provide author url for authenticated user' do
318 author = Person.new 289 author = Person.new
319 author.expects(:url).returns('http://blabla.net/author') 290 author.expects(:url).returns('http://blabla.net/author')
vendor/plugins/action_tracker_has_comments/init.rb
@@ -11,23 +11,5 @@ Rails.configuration.to_prepare do @@ -11,23 +11,5 @@ Rails.configuration.to_prepare do
11 type, id = (self.target_type == 'Article' ? ['Article', self.target_id] : [self.class.to_s, self.id]) 11 type, id = (self.target_type == 'Article' ? ['Article', self.target_id] : [self.class.to_s, self.id])
12 "source_type = '#{type}' AND source_id = '#{id}' AND spam IS NOT TRUE AND reply_of_id IS NULL" 12 "source_type = '#{type}' AND source_id = '#{id}' AND spam IS NOT TRUE AND reply_of_id IS NULL"
13 end 13 end
14 -  
15 - def comments_as_thread  
16 - result = {}  
17 - root = []  
18 - self.comments.each do |c|  
19 - c.replies = []  
20 - result[c.id] ||= c  
21 - if c.reply_of_id.nil?  
22 - root << c  
23 - elsif result[c.reply_of_id]  
24 - result[c.reply_of_id].replies << c  
25 - else # Comment is a reply but the reply is not being displayed - is spam, for example  
26 - root << c  
27 - end  
28 - end  
29 - root  
30 - end  
31 -  
32 end 14 end
33 end 15 end