Files
danbooru/test/unit/advertisement_test.rb
albert 17881068e1 * Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3
* Fixed tests
2012-06-01 19:22:58 -04:00

29 lines
899 B
Ruby

require 'test_helper'
class AdvertisementTest < ActiveSupport::TestCase
context "An advertisement" do
setup do
@ad = FactoryGirl.create(:advertisement, :file => upload_jpeg("#{Rails.root}/test/files/test.jpg"))
end
teardown do
FileUtils.rm_f(Dir.glob("#{Rails.root}/public/images/advertisements/*.jpg"))
end
should "create new hit records" do
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
should "know its preview height and preview width" do
assert_equal(100, @ad.preview_width)
assert_equal(67, @ad.preview_height)
end
end
end