From f60a0173f1a5fdd67d445b718bc009de58704b42 Mon Sep 17 00:00:00 2001 From: Lucas Melo Date: Fri, 22 Nov 2013 16:46:58 -0300 Subject: [PATCH] action_tracker: show only non spam comments --- test/functional/profile_controller_test.rb | 11 +++++++++++ vendor/plugins/action_tracker_has_comments/init.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index 5178911..1da470c 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -1344,6 +1344,17 @@ class ProfileControllerTest < ActionController::TestCase assert_tag :tag => 'span', :content => '(removed user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-removed'} end + should 'not display spam comments in wall' do + UserStampSweeper.any_instance.stubs(:current_user).returns(profile) + article = TinyMceArticle.create!(:profile => profile, :name => 'An article about spam\'s nutritional attributes') + comment = Comment.create!(:author => profile, :title => 'Test Comment', :body => 'This article makes me hungry', :source_id => article.id, :source_type => 'Article') + comment.spam! + login_as(profile.identifier) + get :index, :profile => profile.identifier + + assert !/This article makes me hungry/.match(@response.body), 'Spam comment was shown!' + end + should 'display comment in wall from non logged users' do UserStampSweeper.any_instance.stubs(:current_user).returns(profile) article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') diff --git a/vendor/plugins/action_tracker_has_comments/init.rb b/vendor/plugins/action_tracker_has_comments/init.rb index 07985db..e5a7abf 100644 --- a/vendor/plugins/action_tracker_has_comments/init.rb +++ b/vendor/plugins/action_tracker_has_comments/init.rb @@ -7,7 +7,7 @@ Rails.configuration.to_prepare do def conditions_for_comments type, id = (self.target_type == 'Article' ? ['Article', self.target_id] : [self.class.to_s, self.id]) - "source_type = '#{type}' AND source_id = '#{id}'" + "source_type = '#{type}' AND source_id = '#{id}' AND spam IS NOT TRUE" end def comments_as_thread -- libgit2 0.21.2