support pool version archive

This commit is contained in:
Albert Yi
2016-12-14 18:09:45 -08:00
parent 3c038f76f9
commit ee4ebce4d7
22 changed files with 300 additions and 64 deletions

View File

@@ -1,6 +1,9 @@
require 'test_helper'
require 'helpers/pool_archive_test_helper'
class PoolsControllerTest < ActionController::TestCase
include PoolArchiveTestHelper
context "The pools controller" do
setup do
Timecop.travel(1.month.ago) do
@@ -10,9 +13,12 @@ class PoolsControllerTest < ActionController::TestCase
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
@post = FactoryGirl.create(:post)
mock_pool_archive_service!
start_pool_archive_transaction
end
teardown do
rollback_pool_archive_transaction
CurrentUser.user = nil
end
@@ -99,10 +105,10 @@ class PoolsControllerTest < ActionController::TestCase
end
should "revert to a previous version" do
assert_equal(2, PoolVersion.count)
assert_equal(2, PoolArchive.count)
@pool.reload
version = @pool.versions.first
assert_equal("#{@post.id}", version.post_ids)
assert_equal([@post.id], version.post_ids)
post :revert, {:id => @pool.id, :version_id => version.id}, {:user_id => @mod.id}
@pool.reload
assert_equal([@post.id], @pool.post_id_array)
@@ -111,7 +117,7 @@ class PoolsControllerTest < ActionController::TestCase
should "not allow reverting to a previous version of another pool" do
@pool2 = FactoryGirl.create(:pool)
post :revert, { :id => @pool.id, :version_id => @pool2.versions(true).first.id }, {:user_id => @user.id}
post :revert, { :id => @pool.id, :version_id => @pool2.versions.first.id }, {:user_id => @user.id}
@pool.reload
assert_not_equal(@pool.name, @pool2.name)