Commit f60a0173f1a5fdd67d445b718bc009de58704b42
Committed by
Rodrigo Souto
1 parent
73479a2c
Exists in
master
and in
22 other branches
action_tracker: show only non spam comments
AI2784 Conflicts: vendor/plugins/action_tracker_has_comments/init.rb
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
test/functional/profile_controller_test.rb
| ... | ... | @@ -1344,6 +1344,17 @@ class ProfileControllerTest < ActionController::TestCase |
| 1344 | 1344 | assert_tag :tag => 'span', :content => '(removed user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-removed'} |
| 1345 | 1345 | end |
| 1346 | 1346 | |
| 1347 | + should 'not display spam comments in wall' do | |
| 1348 | + UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | |
| 1349 | + article = TinyMceArticle.create!(:profile => profile, :name => 'An article about spam\'s nutritional attributes') | |
| 1350 | + comment = Comment.create!(:author => profile, :title => 'Test Comment', :body => 'This article makes me hungry', :source_id => article.id, :source_type => 'Article') | |
| 1351 | + comment.spam! | |
| 1352 | + login_as(profile.identifier) | |
| 1353 | + get :index, :profile => profile.identifier | |
| 1354 | + | |
| 1355 | + assert !/This article makes me hungry/.match(@response.body), 'Spam comment was shown!' | |
| 1356 | + end | |
| 1357 | + | |
| 1347 | 1358 | should 'display comment in wall from non logged users' do |
| 1348 | 1359 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
| 1349 | 1360 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') | ... | ... |
vendor/plugins/action_tracker_has_comments/init.rb
| ... | ... | @@ -7,7 +7,7 @@ Rails.configuration.to_prepare do |
| 7 | 7 | |
| 8 | 8 | def conditions_for_comments |
| 9 | 9 | type, id = (self.target_type == 'Article' ? ['Article', self.target_id] : [self.class.to_s, self.id]) |
| 10 | - "source_type = '#{type}' AND source_id = '#{id}'" | |
| 10 | + "source_type = '#{type}' AND source_id = '#{id}' AND spam IS NOT TRUE" | |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | def comments_as_thread | ... | ... |