added ads

This commit is contained in:
albert
2010-02-15 17:56:51 -05:00
parent 9f353c32f4
commit 09cca6f631
7 changed files with 254 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
Factory.define(:advertisement) do |f|
f.referral_url "http://google.com"
f.ad_type "vertical"
f.status "active"
f.width 728
f.height 90
f.file_name "google.gif"
end

View File

@@ -0,0 +1,16 @@
require File.dirname(__FILE__) + '/../test_helper'
class AdvertisementTest < ActiveSupport::TestCase
context "An advertisement" do
should "create new hit records" do
ad = Factory.create(:advertisement)
assert_difference("AdvertisementHit.count") do
ad.hit!("0.0.0.0")
end
assert_equal("0.0.0.0", AdvertisementHit.first.ip_addr)
assert_equal(1, AdvertisementHit.first.advertisement_id)
assert_equal(1, ad.hit_sum(1.day.ago, 1.day.from_now))
assert_equal(0, ad.hit_sum(2.days.ago, 1.day.ago))
end
end
end