remove advertisement code

This commit is contained in:
r888888888
2017-02-21 13:33:20 -08:00
parent f4d9f76646
commit 6c9d5e4f9a
24 changed files with 1 additions and 704 deletions

View File

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

View File

@@ -1,17 +0,0 @@
require 'test_helper'
class AdvertisementHitsControllerTest < ActionController::TestCase
context "An advertisement hits controller" do
setup do
@ad = FactoryGirl.create(:advertisement)
@advertiser = FactoryGirl.create(:admin_user)
end
should "create a new hit" do
assert_difference("AdvertisementHit.count", 1) do
post :create, {:advertisement_id => @ad.id}
end
assert_redirected_to(@ad.referral_url)
end
end
end

View File

@@ -1,58 +0,0 @@
require 'test_helper'
class AdvertisementsControllerTest < ActionController::TestCase
context "An advertisement controller" do
setup do
@ad = FactoryGirl.create(:advertisement)
@advertiser = FactoryGirl.create(:admin_user)
end
should "get the new page" do
get :new, {}, {:user_id => @advertiser.id}
assert_response :success
end
should "get the edit page" do
get :edit, {:id => @ad.id}, {:user_id => @advertiser.id}
assert_response :success
end
should "get the index page" do
get :index, {}, {:user_id => @advertiser.id}
assert_response :success
end
should "get the show page" do
get :show, {:id => @ad.id}, {:user_id => @advertiser.id}
assert_response :success
end
should "create an ad" do
assert_difference("Advertisement.count", 1) do
post :create, {:advertisement => FactoryGirl.attributes_for(:advertisement)}, {:user_id => @advertiser.id}
end
ad = Advertisement.last
assert_redirected_to(advertisement_path(ad))
end
should "update an ad" do
post :update, {:id => @ad.id, :advertisement => {:width => 100}}, {:user_id => @advertiser.id}
ad = Advertisement.last
assert_equal(100, ad.width)
assert_redirected_to(advertisement_path(ad))
end
should "delete an ad" do
assert_difference("Advertisement.count", -1) do
post :destroy, {:id => @ad.id}, {:user_id => @advertiser.id}
end
assert_redirected_to(advertisements_path)
end
should "block non-advertisers" do
regular_user = FactoryGirl.create(:user)
get :index, {}, {:user_id => regular_user.id}
assert_response(403)
end
end
end

View File

@@ -1,32 +0,0 @@
require 'test_helper'
require 'helpers/upload_test_helper'
class AdvertisementTest < ActiveSupport::TestCase
include UploadTestHelper
context "An advertisement" do
setup do
Danbooru.config.stubs(:advertisement_path).returns("/tmp")
@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.to_s)
assert_equal(@ad.id, 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