tests: fix post and pool version tests helpers.
* Fix the pool version SQS service to always be mocked before every test. Before we had to manually set it up before every test dealing with pool versions. * Fix it so that we reconnect to the post/pool version databases before every test. Before using $ARCHIVE_DATABASE_URL to set the database url failed because environment variables weren't loaded by dotenv yet when connections were first established.
This commit is contained in:
@@ -3,8 +3,6 @@ require 'test_helper'
|
||||
class PoolElementsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The pools posts controller" do
|
||||
setup do
|
||||
mock_pool_archive_service!
|
||||
start_pool_archive_transaction
|
||||
@user = travel_to(1.month.ago) {create(:user)}
|
||||
@mod = create(:moderator_user)
|
||||
as_user do
|
||||
@@ -13,10 +11,6 @@ class PoolElementsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
teardown do
|
||||
rollback_pool_archive_transaction
|
||||
end
|
||||
|
||||
context "create action" do
|
||||
should "add a post to a pool" do
|
||||
post_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}
|
||||
|
||||
@@ -3,30 +3,17 @@ require 'test_helper'
|
||||
class PoolVersionsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The pool versions controller" do
|
||||
setup do
|
||||
mock_pool_archive_service!
|
||||
start_pool_archive_transaction
|
||||
@user = create(:user)
|
||||
end
|
||||
|
||||
teardown do
|
||||
rollback_pool_archive_transaction
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
as_user do
|
||||
@pool = create(:pool)
|
||||
end
|
||||
@pool = as(@user) { create(:pool) }
|
||||
@user_2 = create(:user)
|
||||
@user_3 = create(:user)
|
||||
|
||||
CurrentUser.scoped(@user_2, "1.2.3.4") do
|
||||
@pool.update(:post_ids => "1 2")
|
||||
end
|
||||
|
||||
CurrentUser.scoped(@user_3, "5.6.7.8") do
|
||||
@pool.update(:post_ids => "1 2 3 4")
|
||||
end
|
||||
as(@user_2) { @pool.update(post_ids: "1 2") }
|
||||
as(@user_3) { @pool.update(post_ids: "1 2 3 4") }
|
||||
|
||||
@versions = @pool.versions
|
||||
end
|
||||
|
||||
@@ -3,10 +3,6 @@ require 'test_helper'
|
||||
class PoolsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The pools controller" do
|
||||
setup do
|
||||
mock_pool_archive_service!
|
||||
PoolVersion.sqs_service.stubs(:merge?).returns(false)
|
||||
start_pool_archive_transaction
|
||||
|
||||
travel_to(1.month.ago) do
|
||||
@user = create(:user)
|
||||
@mod = create(:moderator_user)
|
||||
@@ -17,10 +13,6 @@ class PoolsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
teardown do
|
||||
rollback_pool_archive_transaction
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
should "list all pools" do
|
||||
get pools_path
|
||||
|
||||
Reference in New Issue
Block a user