Sha256: 146e5e0f20f61c4d7f1d18127e377db5c2a3d3c20044faee5e78264cfa9b3f37

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

require 'dns_mock'

class TrackbackTest < Test::Unit::TestCase
  fixtures :contents, :blacklist_patterns, :blogs

  def test_incomplete
    tb = Trackback.new
    tb.blog_name = "Blog name"
    tb.title = "Title"
    tb.excerpt = "Excerpt"

    assert ! tb.save
    assert tb.errors.invalid?('url')

    tb.url = "http://foo.com"
    assert tb.save
    assert tb.errors.empty?
    assert tb.guid.size > 15
    assert !tb.spam?
  end

  def test_reject_spam_rbl
    tb = Trackback.new do |tb|
      tb.blog_name = "Spammer"
      tb.title = "Spammy trackback"
      tb.excerpt = %{This is just some random text. <a href="http://chinaaircatering.com">without any senses.</a>. Please disregard.}
      tb.url = "http://buy-computer.us"
      tb.ip = "212.42.230.206"
    end

    assert tb.spam?
  end

  def test_reject_spam_pattern
    tb = Trackback.new do |tb|
      tb.blog_name = "Another Spammer"
      tb.title = "Spammy trackback"
      tb.excerpt = "Texas hold-em poker crap"
    end
    assert tb.spam?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
typo-4.0.2 test/unit/trackback_test.rb
typo-4.0.1 test/unit/trackback_test.rb
typo-4.0.3 test/unit/trackback_test.rb