* 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.
30 lines
962 B
Ruby
30 lines
962 B
Ruby
require 'test_helper'
|
|
|
|
class PoolElementsControllerTest < ActionDispatch::IntegrationTest
|
|
context "The pools posts controller" do
|
|
setup do
|
|
@user = travel_to(1.month.ago) {create(:user)}
|
|
@mod = create(:moderator_user)
|
|
as_user do
|
|
@post = create(:post)
|
|
@pool = create(:pool, :name => "abc")
|
|
end
|
|
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"}
|
|
assert_response :success
|
|
assert_equal([@post.id], @pool.reload.post_ids)
|
|
end
|
|
|
|
should "add a post to a pool once and only once" do
|
|
as_user { @pool.add!(@post) }
|
|
post_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}
|
|
assert_response :success
|
|
assert_equal([@post.id], @pool.reload.post_ids)
|
|
end
|
|
end
|
|
end
|
|
end
|