diff --git a/test/functional/moderator/ip_addrs_controller_test.rb b/test/functional/moderator/ip_addrs_controller_test.rb index eeaf97977..70e7ef6b8 100644 --- a/test/functional/moderator/ip_addrs_controller_test.rb +++ b/test/functional/moderator/ip_addrs_controller_test.rb @@ -4,12 +4,20 @@ module Moderator class IpAddrsControllerTest < ActionController::TestCase context "The ip addrs controller" do setup do + PoolArchive.delete_all + PostArchive.delete_all + @user = FactoryGirl.create(:moderator_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" FactoryGirl.create(:comment) end + teardown do + CurrentUser.user = nil + CurrentUser.ip_addr = nil + end + should "find by ip addr" do get :index, {:search => {:ip_addr => "127.0.0.1"}}, {:user_id => @user.id} assert_response :success diff --git a/test/functional/pools_controller_test.rb b/test/functional/pools_controller_test.rb index 29e5807d9..c19465da5 100644 --- a/test/functional/pools_controller_test.rb +++ b/test/functional/pools_controller_test.rb @@ -130,7 +130,6 @@ class PoolsControllerTest < ActionController::TestCase end should "revert to a previous version" do - assert_equal(2, PoolArchive.count) @pool.reload version = @pool.versions.first assert_equal([@post.id], version.post_ids) diff --git a/test/functional/post_replacements_controller_test.rb b/test/functional/post_replacements_controller_test.rb index d68cfd17f..84b9399a5 100644 --- a/test/functional/post_replacements_controller_test.rb +++ b/test/functional/post_replacements_controller_test.rb @@ -5,7 +5,7 @@ class PostReplacementsControllerTest < ActionController::TestCase setup do Delayed::Worker.delay_jobs = true # don't delete the old images right away - @user = FactoryGirl.create(:user, can_approve_posts: true, created_at: 1.month.ago) + @user = FactoryGirl.create(:moderator_user, can_approve_posts: true, created_at: 1.month.ago) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" @@ -30,10 +30,10 @@ class PostReplacementsControllerTest < ActionController::TestCase assert_difference("@post.replacements.size") do post :create, params, { user_id: @user.id } @post.reload + end - Timecop.travel(Time.now + PostReplacement::DELETION_GRACE_PERIOD + 1.day) do - Delayed::Worker.new.work_off - end + Timecop.travel(Time.now + PostReplacement::DELETION_GRACE_PERIOD + 1.day) do + Delayed::Worker.new.work_off end assert_response :success diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 76e56dc16..624fbd8f3 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -75,6 +75,14 @@ class UsersControllerTest < ActionController::TestCase end context "new action" do + setup do + ENV["RECAPTCHA_SITE_KEY"] = "x" + end + + teardown do + ENV["RECAPTCHA_SITE_KEY"] = nil + end + should "render" do get :new assert_response :success diff --git a/test/test_helper.rb b/test/test_helper.rb index 3d68f98f8..e93d5e0b2 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -51,7 +51,13 @@ class ActionController::TestCase assert_redirected_to(new_sessions_path) end - teardown do + def setup + super + User.any_instance.stubs(:validate_sock_puppets).returns(true) + end + + def teardown + super Cache.clear end end