Skip to content

Commit

Permalink
send permalink info to Akismet
Browse files Browse the repository at this point in the history
  • Loading branch information
ehoch committed Sep 19, 2013
1 parent 0ebcd72 commit 17c9e1c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,3 +1,4 @@
* Add Akistmet permalink attribute [Eric Hochberger]
* Clean up gemspec and load paths [Steven Harman]
* Add Akismet is_test param [Steven Harman]
* Add Akismet user_role attribute [Steven Harman]
Expand Down
4 changes: 2 additions & 2 deletions lib/rakismet/model.rb
Expand Up @@ -14,7 +14,7 @@ class << self; attr_accessor :akismet_attrs; end
module ClassMethods
def rakismet_attrs(args={})
self.akismet_attrs ||= {}
[:comment_type, :author, :author_url, :author_email, :content, :user_role].each do |field|
[:comment_type, :author, :author_url, :author_email, :content, :user_role, :permalink].each do |field|
# clunky, but throwing around +type+ will break your heart
fieldname = field.to_s =~ %r(^comment_) ? field : "comment_#{field}".intern
self.akismet_attrs[fieldname] = args.delete(field) || field
Expand Down Expand Up @@ -64,7 +64,7 @@ def akismet_data
elsif !mapped_field.nil? && respond_to?(mapped_field)
send(mapped_field)
elsif not [:comment_type, :author, :author_email,
:author_url, :content, :user_role,
:author_url, :content, :user_role, :permalink,
:user_ip, :referrer,
:user_agent].include?(mapped_field)
# we've excluded any fields that appear to
Expand Down
4 changes: 2 additions & 2 deletions spec/models/custom_params_spec.rb
Expand Up @@ -2,7 +2,7 @@

MAPPED_PARAMS = { :comment_type => :type2, :author => :author2, :content => :content2,
:author_email => :author_email2, :author_url => :author_url2,
:user_role => :user_role2 }
:user_role => :user_role2, :permalink => :permalink2 }

class CustomAkismetModel
include Rakismet::Model
Expand All @@ -12,7 +12,7 @@ class CustomAkismetModel

describe CustomAkismetModel do
it "should override default mappings" do
[:comment_type, :author, :author_url, :author_email, :content, :user_role].each do |field|
[:comment_type, :author, :author_url, :author_email, :content, :user_role, :permalink].each do |field|
fieldname = field.to_s =~ %r(^comment_) ? field : "comment_#{field}".intern
CustomAkismetModel.akismet_attrs[fieldname].should eql(MAPPED_PARAMS[field])
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/rakismet_model_spec.rb
Expand Up @@ -8,7 +8,7 @@
end

it "should have default mappings" do
[:comment_type, :author, :author_email, :author_url, :content, :user_role].each do |field|
[:comment_type, :author, :author_email, :author_url, :content, :user_role, :permalink].each do |field|
fieldname = field.to_s =~ %r(^comment_) ? field : "comment_#{field}".intern
AkismetModel.akismet_attrs[fieldname].should eql(field)
end
Expand Down

0 comments on commit 17c9e1c

Please sign in to comment.