* Refactored routes some

* Fixed some major bugs with pools and pool versioning
This commit is contained in:
albert
2011-01-21 18:07:34 -05:00
parent cd451109e8
commit 6824e98af3
13 changed files with 101 additions and 51 deletions

View File

@@ -9,7 +9,7 @@ class AdvertisementHitsControllerTest < ActionController::TestCase
should "create a new hit" do
assert_difference("AdvertisementHit.count", 1) do
post :create, {:id => @ad.id}
post :create, {:advertisement_id => @ad.id}
end
assert_redirected_to(@ad.referral_url)
end

View File

@@ -75,15 +75,18 @@ class PoolsControllerTest < ActionController::TestCase
context "revert action" do
setup do
@pool = Factory.create(:pool, :name => "000")
@pool.update_attributes(:name => "111")
@pool.update_attributes(:name => "222")
@pool = Factory.create(:pool, :post_ids => "1")
CurrentUser.ip_addr = "1.2.3.4" # this is to get around the version collation
@pool.update_attributes(:post_ids => "1 2")
CurrentUser.ip_addr = "127.0.0.1"
end
should "revert to a previous version" do
post :revert, {:id => @pool.id, :version_id => @pool.versions(true).first.id}
version = @pool.versions(true).first
assert_equal("1", version.post_ids)
post :revert, {:id => @pool.id, :version_id => version.id}
@pool.reload
assert_equal("000", @pool.name)
assert_equal("1", @pool.post_ids)
end
end
end

View File

@@ -0,0 +1,52 @@
require 'test_helper'
class PoolsPostsControllerTest < ActionController::TestCase
context "The pools posts controller" do
setup do
@user = Factory.create(:user)
@mod = Factory.create(:moderator_user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
@post = Factory.create(:post)
@pool = Factory.create(:pool, :name => "abc")
end
teardown do
CurrentUser.user = nil
end
context "create action" do
should "add a post to a pool" do
post :create, {:pool_id => @pool.id, :id => @post.id, :format => "json"}, {:user_id => @user.id}
@pool.reload
assert_equal([@post.id], @pool.post_id_array)
end
should "add a post to a pool once and only once" do
@pool.add_post!(@post)
post :create, {:pool_id => @pool.id, :id => @post.id, :format => "json"}, {:user_id => @user.id}
@pool.reload
assert_equal([@post.id], @pool.post_id_array)
end
end
context "destroy action" do
setup do
@pool.add_post!(@post)
end
should "remove a post from a pool" do
post :destroy, {:pool_id => @pool.id, :id => @post.id, :format => "json"}, {:user_id => @user.id}
@pool.reload
assert_equal([], @pool.post_id_array)
end
should "do nothing if the post is not a member of the pool" do
@pool.remove_post!(@post)
post :destroy, {:pool_id => @pool.id, :id => @post.id, :format => "json"}, {:user_id => @user.id}
@pool.reload
assert_equal([], @pool.post_id_array)
end
end
end
end

View File

@@ -1,7 +1,7 @@
require File.join(File.dirname(__FILE__), %w(.. test_helper))
class PostModerationDetailControllerTest < ActionController::TestCase
context "A post moderation detail controller" do
class PostModerationControllerTest < ActionController::TestCase
context "A post moderation controller" do
should "" do
ModQueuePost.destroy_all

View File

@@ -1,8 +0,0 @@
require 'test_helper'
class PostModerationDetailsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end