Commit 82cedbd645af93f7ce922e4d55b0ccacd580f88a
Exists in
master
and in
15 other branches
Merge branch 'AI3284-antispam_fixes' into 'master'
Fixes for anti_spam plugin fixes for anti_spam plugin See merge request !766
Showing
7 changed files
with
27 additions
and
6 deletions
Show diff stats
plugins/anti_spam/Gemfile
plugins/anti_spam/dependencies.rb
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -require 'rakismet' |
plugins/anti_spam/lib/anti_spam_plugin.rb
plugins/anti_spam/lib/anti_spam_plugin/suggest_article_wrapper.rb
| 1 | 1 | class AntiSpamPlugin::SuggestArticleWrapper < AntiSpamPlugin::Wrapper |
| 2 | + | |
| 2 | 3 | alias_attribute :author, :name |
| 3 | 4 | alias_attribute :author_email, :email |
| 4 | 5 | alias_attribute :user_ip, :ip_address |
| 5 | - alias_attribute :content, :article_body | |
| 6 | + | |
| 7 | + def content | |
| 8 | + article && article[:body] | |
| 9 | + end | |
| 10 | + | |
| 6 | 11 | |
| 7 | 12 | def self.wraps?(object) |
| 8 | 13 | object.kind_of?(SuggestArticle) | ... | ... |
plugins/anti_spam/lib/anti_spam_plugin/wrapper.rb
plugins/anti_spam/test/unit/anti_spam_plugin/suggest_article_wrapper_test.rb
| ... | ... | @@ -4,7 +4,7 @@ class AntiSpamPlugin::SuggestArticleWrapperTest < ActiveSupport::TestCase |
| 4 | 4 | |
| 5 | 5 | def setup |
| 6 | 6 | @suggest_article = SuggestArticle.new( |
| 7 | - :article_body => 'comment body', | |
| 7 | + :article => {:body=> 'comment body'}, | |
| 8 | 8 | :name => 'author', |
| 9 | 9 | :email => 'foo@example.com', |
| 10 | 10 | :ip_address => '1.2.3.4', |
| ... | ... | @@ -15,7 +15,7 @@ class AntiSpamPlugin::SuggestArticleWrapperTest < ActiveSupport::TestCase |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | should 'get contents' do |
| 18 | - assert_equal @suggest_article.article_body, @wrapper.content | |
| 18 | + assert_equal @suggest_article.article[:body], @wrapper.content | |
| 19 | 19 | end |
| 20 | 20 | |
| 21 | 21 | should 'get author name' do | ... | ... |
plugins/anti_spam/test/unit/anti_spam_plugin/wrapper_test.rb
| ... | ... | @@ -2,6 +2,11 @@ require 'test_helper' |
| 2 | 2 | require 'anti_spam_plugin/wrapper' |
| 3 | 3 | |
| 4 | 4 | class AntiSpamPluginWrapperTest < ActiveSupport::TestCase |
| 5 | + | |
| 6 | + def teardown | |
| 7 | + AntiSpamPlugin::Wrapper.wrappers = [] | |
| 8 | + end | |
| 9 | + | |
| 5 | 10 | should 'use Rakismet::Model' do |
| 6 | 11 | wrapped = AntiSpamPlugin::Wrapper.new(mock) |
| 7 | 12 | assert_includes wrapped.class.included_modules, Rakismet::Model |
| ... | ... | @@ -22,4 +27,15 @@ class AntiSpamPluginWrapperTest < ActiveSupport::TestCase |
| 22 | 27 | assert AntiSpamPlugin::Wrapper.wrap(5).kind_of?(OddWrapper) |
| 23 | 28 | assert AntiSpamPlugin::Wrapper.wrap(6).kind_of?(EvenWrapper) |
| 24 | 29 | end |
| 30 | + | |
| 31 | + should 'define rakismet_attrs' do | |
| 32 | + class AnyWrapper < AntiSpamPlugin::Wrapper | |
| 33 | + def self.wraps?(object) | |
| 34 | + true | |
| 35 | + end | |
| 36 | + end | |
| 37 | + | |
| 38 | + assert_not_nil AnyWrapper.new(Object.new).send :akismet_data | |
| 39 | + end | |
| 40 | + | |
| 25 | 41 | end | ... | ... |