<commit_before>class SuggestArticle < Task

  validates_presence_of :target_id
  validates_presence_of :email, :name, :if => Proc.new { |task| task.requestor.blank? }
  validates_associated :article_object

  settings_items :email, :type => String
  settings_items :name, :type => String
  settings_items :ip_address, :type => String
  settings_items :user_agent, :type => String
  settings_items :referrer, :type => String
  settings_items :article, :type => Hash, :default => {}

  after_create :schedule_spam_checking

  def schedule_spam_checking
    self.delay.check_for_spam
  end

  include Noosfero::Plugin::HotSpot

  def sender
    requestor ? "#{requestor.name}" : "#{name} (#{email})"
  end

  def article_object
    if @article_object.nil?
      @article_object = article_type.new(article.merge({:profile => target}).except(:type))
      if requestor.present?
        @article_object.author = requestor
      else
        @article_object.author_name = name
      end
    end
    @article_object<commit_msg>Fix suggest article tests<commit_after>class SuggestArticle < Task

  validates_presence_of :target_id
  validates_presence_of :email, :name, :if => Proc.new { |task| task.requestor.blank? }
  validates_associated :article_object

  settings_items :email, :type => String
  settings_items :name, :type => String
  settings_items :ip_address, :type => String
  settings_items :user_agent, :type => String
  settings_items :referrer, :type => String
  settings_items :article, :type => Hash, :default => {}

  after_create :schedule_spam_checking

  def schedule_spam_checking
    self.delay.check_for_spam
  end

  include Noosfero::Plugin::HotSpot

  def sender
    requestor ? "#{requestor.name}" : "#{name} (#{email})"
  end

  def article_object
    if @article_object.nil?
      @article_object = article_type.new(article.merge(target.present? ? {:profile => target} : {}).except(:type))
      if requestor.present?
        @article_object.author = requestor
      else
        @article_object.author_name = name
      end
    end
    @article_object
{'fraction_non_alphanumeric': 0.10998552821997105, 'fraction_numerical': 0.0, 'mean_word_length': 4.070904645476773, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2986589', 'n_tokens_mistral': 673, 'n_tokens_neox': 647, 'n_words': 146}