[Git][noosfero/noosfero][master] 2 commits: Updates anti_spam plugin
Antonio Terceiro
gitlab at mg.gitlab.com
Thu Jan 21 09:52:30 BRST 2016
Antonio Terceiro pushed to branch master at Noosfero / noosfero
Commits:
a7da4b68 by Francisco Marcelo de Araújo Lima Júnior at 2016-01-20T16:28:38-02:00
Updates anti_spam plugin
- Updates rakismet version;
- Fixes akismet_data being nil;
- Creates test for rakismet gem behaviour in anti_spam plugin;
- Adds teardown to isolate tests;
Signed-off-by: Antonio Terceiro <terceiro at colivre.coop.br>
Signed-off-by: Francisco Marcelo de Araújo Lima Júnior <francisco.lima-junior at serpro.gov.br>
Signed-off-by: Marcos Ronaldo <marcos.rpj2 at gmail.com>
- - - - -
82cedbd6 by Antonio Terceiro at 2016-01-21T11:50:31+00:00
Merge branch 'AI3284-antispam_fixes' into 'master'
Fixes for anti_spam plugin
fixes for anti_spam plugin
See merge request !766
- - - - -
7 changed files:
- plugins/anti_spam/Gemfile
- − plugins/anti_spam/dependencies.rb
- plugins/anti_spam/lib/anti_spam_plugin.rb
- plugins/anti_spam/lib/anti_spam_plugin/suggest_article_wrapper.rb
- plugins/anti_spam/lib/anti_spam_plugin/wrapper.rb
- plugins/anti_spam/test/unit/anti_spam_plugin/suggest_article_wrapper_test.rb
- plugins/anti_spam/test/unit/anti_spam_plugin/wrapper_test.rb
Changes:
=====================================
plugins/anti_spam/Gemfile
=====================================
--- a/plugins/anti_spam/Gemfile
+++ b/plugins/anti_spam/Gemfile
@@ -1 +1 @@
-gem 'rakismet'
+gem 'rakismet', '~> 1.5.0'
=====================================
plugins/anti_spam/dependencies.rb deleted
=====================================
--- a/plugins/anti_spam/dependencies.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'rakismet'
=====================================
plugins/anti_spam/lib/anti_spam_plugin.rb
=====================================
--- a/plugins/anti_spam/lib/anti_spam_plugin.rb
+++ b/plugins/anti_spam/lib/anti_spam_plugin.rb
@@ -9,7 +9,7 @@ class AntiSpamPlugin < Noosfero::Plugin
end
def self.host_default_setting
- 'api.antispam.typepad.com'
+ 'rest.akismet.com'
end
def check_for_spam(object)
=====================================
plugins/anti_spam/lib/anti_spam_plugin/suggest_article_wrapper.rb
=====================================
--- a/plugins/anti_spam/lib/anti_spam_plugin/suggest_article_wrapper.rb
+++ b/plugins/anti_spam/lib/anti_spam_plugin/suggest_article_wrapper.rb
@@ -1,8 +1,13 @@
class AntiSpamPlugin::SuggestArticleWrapper < AntiSpamPlugin::Wrapper
+
alias_attribute :author, :name
alias_attribute :author_email, :email
alias_attribute :user_ip, :ip_address
- alias_attribute :content, :article_body
+
+ def content
+ article && article[:body]
+ end
+
def self.wraps?(object)
object.kind_of?(SuggestArticle)
=====================================
plugins/anti_spam/lib/anti_spam_plugin/wrapper.rb
=====================================
--- a/plugins/anti_spam/lib/anti_spam_plugin/wrapper.rb
+++ b/plugins/anti_spam/lib/anti_spam_plugin/wrapper.rb
@@ -14,6 +14,7 @@ class AntiSpamPlugin::Wrapper < SimpleDelegator
end
def self.inherited(child)
+ child.rakismet_attrs
wrappers << child
end
end
=====================================
plugins/anti_spam/test/unit/anti_spam_plugin/suggest_article_wrapper_test.rb
=====================================
--- a/plugins/anti_spam/test/unit/anti_spam_plugin/suggest_article_wrapper_test.rb
+++ b/plugins/anti_spam/test/unit/anti_spam_plugin/suggest_article_wrapper_test.rb
@@ -4,7 +4,7 @@ class AntiSpamPlugin::SuggestArticleWrapperTest < ActiveSupport::TestCase
def setup
@suggest_article = SuggestArticle.new(
- :article_body => 'comment body',
+ :article => {:body=> 'comment body'},
:name => 'author',
:email => 'foo at example.com',
:ip_address => '1.2.3.4',
@@ -15,7 +15,7 @@ class AntiSpamPlugin::SuggestArticleWrapperTest < ActiveSupport::TestCase
end
should 'get contents' do
- assert_equal @suggest_article.article_body, @wrapper.content
+ assert_equal @suggest_article.article[:body], @wrapper.content
end
should 'get author name' do
=====================================
plugins/anti_spam/test/unit/anti_spam_plugin/wrapper_test.rb
=====================================
--- a/plugins/anti_spam/test/unit/anti_spam_plugin/wrapper_test.rb
+++ b/plugins/anti_spam/test/unit/anti_spam_plugin/wrapper_test.rb
@@ -2,6 +2,11 @@ require 'test_helper'
require 'anti_spam_plugin/wrapper'
class AntiSpamPluginWrapperTest < ActiveSupport::TestCase
+
+ def teardown
+ AntiSpamPlugin::Wrapper.wrappers = []
+ end
+
should 'use Rakismet::Model' do
wrapped = AntiSpamPlugin::Wrapper.new(mock)
assert_includes wrapped.class.included_modules, Rakismet::Model
@@ -22,4 +27,15 @@ class AntiSpamPluginWrapperTest < ActiveSupport::TestCase
assert AntiSpamPlugin::Wrapper.wrap(5).kind_of?(OddWrapper)
assert AntiSpamPlugin::Wrapper.wrap(6).kind_of?(EvenWrapper)
end
+
+ should 'define rakismet_attrs' do
+ class AnyWrapper < AntiSpamPlugin::Wrapper
+ def self.wraps?(object)
+ true
+ end
+ end
+
+ assert_not_nil AnyWrapper.new(Object.new).send :akismet_data
+ end
+
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/cd3edc920b84d558267fa128f1c53f762ac12ff1...82cedbd645af93f7ce922e4d55b0ccacd580f88a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160121/4a7d16b1/attachment-0001.html>
More information about the Noosfero-dev
mailing list