* Refactored PostSet, splitting it into PostSets::Post and PostSets::Favorite

* Additional functional tests
This commit is contained in:
albert
2010-12-01 17:21:05 -05:00
parent f8ab736677
commit 39dd2e277a
20 changed files with 342 additions and 198 deletions

View File

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

View File

@@ -1,4 +1,58 @@
require 'test_helper'
class AdvertisementsControllerTest < ActionController::TestCase
context "An advertisement controller" do
setup do
@ad = Factory.create(:advertisement)
@advertiser = Factory.create(:admin_user)
end
should "render the new page" do
get :new, {}, {:user_id => @advertiser.id}
assert_response :success
end
should "render the edit page" do
get :edit, {:id => @ad.id}, {:user_id => @advertiser.id}
assert_response :success
end
should "render the index page" do
get :index, {}, {:user_id => @advertiser.id}
assert_response :success
end
should "render 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 => Factory.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 = Factory.create(:user)
get :index, {}, {:user_id => regular_user.id}
assert_redirected_to("/static/access_denied")
end
end
end

View File

@@ -1,8 +1,26 @@
require 'test_helper'
class ArtistVersionsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
context "An artist versions controller" do
setup do
CurrentUser.user = Factory.create(:user)
CurrentUser.ip_addr = "127.0.0.1"
@artist = Factory.create(:artist)
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
should "render the index page" do
get :index
assert_response :success
end
should "render the index page when searching for something" do
get :index, {:search => {:name_equals => @artist.name}}
assert_response :success
end
end
end