tests: fix tests for Rails.cache.

This commit is contained in:
evazion
2017-04-15 21:51:56 -05:00
parent 192190a313
commit c0e5c400a7
46 changed files with 14 additions and 69 deletions

View File

@@ -18,7 +18,6 @@ class ArtistTest < ActiveSupport::TestCase
user = Timecop.travel(1.month.ago) {FactoryGirl.create(:user)}
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -3,7 +3,6 @@ require 'test_helper'
class ArtistUrlTest < ActiveSupport::TestCase
context "An artist url" do
setup do
MEMCACHE.flush_all
CurrentUser.user = FactoryGirl.create(:user)
CurrentUser.ip_addr = "127.0.0.1"
end

View File

@@ -6,7 +6,6 @@ class CommentTest < ActiveSupport::TestCase
user = FactoryGirl.create(:user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -3,7 +3,6 @@ require 'test_helper'
class DmailTest < ActiveSupport::TestCase
context "A dmail" do
setup do
MEMCACHE.flush_all
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "1.2.3.4"

View File

@@ -5,7 +5,6 @@ class FavoriteTest < ActiveSupport::TestCase
user = FactoryGirl.create(:user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Favorite # need to force loading the favorite model
end

View File

@@ -5,7 +5,6 @@ class IpBanTest < ActiveSupport::TestCase
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
end

View File

@@ -7,7 +7,6 @@ class JanitorTrialTest < ActiveSupport::TestCase
@user = FactoryGirl.create(:user)
CurrentUser.user = @admin
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -9,7 +9,6 @@ module Moderator
CurrentUser.ip_addr = "127.0.0.1"
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
FactoryGirl.create(:comment)
MEMCACHE.flush_all
end
teardown do

View File

@@ -6,7 +6,6 @@ class NoteTest < ActiveSupport::TestCase
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -13,7 +13,6 @@ class PoolTest < ActiveSupport::TestCase
end
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
mock_pool_archive_service!
PoolArchive.sqs_service.stubs(:merge?).returns(false)

View File

@@ -6,7 +6,6 @@ class PostAppealTest < ActiveSupport::TestCase
@alice = FactoryGirl.create(:user)
CurrentUser.user = @alice
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Danbooru.config.stubs(:max_appeals_per_day).returns(5)
end

View File

@@ -8,7 +8,6 @@ class PostArchiveTest < ActiveSupport::TestCase
end
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -6,7 +6,6 @@ class PostDisapprovalTest < ActiveSupport::TestCase
@alice = FactoryGirl.create(:moderator_user)
CurrentUser.user = @alice
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -8,7 +8,6 @@ class PostFlagTest < ActiveSupport::TestCase
end
CurrentUser.user = @alice
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
@post = FactoryGirl.create(:post, :tag_string => "aaa")
end

View File

@@ -5,7 +5,6 @@ class PostPrunerTest < ActiveSupport::TestCase
@user = FactoryGirl.create(:admin_user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Timecop.travel(2.weeks.ago) do
@flagger = FactoryGirl.create(:gold_user)

View File

@@ -7,7 +7,6 @@ module PostSets
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
@post_1 = FactoryGirl.create(:post)
@post_2 = FactoryGirl.create(:post)

View File

@@ -8,7 +8,6 @@ module PostSets
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
@post_1 = FactoryGirl.create(:post, :tag_string => "a")
@post_2 = FactoryGirl.create(:post, :tag_string => "b")

View File

@@ -10,7 +10,6 @@ module PostSets
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
mock_pool_archive_service!
start_pool_archive_transaction

View File

@@ -8,7 +8,6 @@ module PostSets
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
@post_1 = FactoryGirl.create(:post, :tag_string => "a")
@post_2 = FactoryGirl.create(:post, :tag_string => "b")

View File

@@ -18,7 +18,6 @@ class PostTest < ActiveSupport::TestCase
end
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
mock_saved_search_service!
end

View File

@@ -8,7 +8,6 @@ class PostVersionTest < ActiveSupport::TestCase
end
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -8,7 +8,6 @@ class PostVoteTest < ActiveSupport::TestCase
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
@post = FactoryGirl.create(:post)
end

View File

@@ -5,7 +5,6 @@ class RelatedTagCalculatorTest < ActiveSupport::TestCase
user = FactoryGirl.create(:user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -5,7 +5,6 @@ class RelatedTagQueryTest < ActiveSupport::TestCase
user = FactoryGirl.create(:user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
context "a related tag query without a category constraint" do

View File

@@ -41,10 +41,6 @@ class SavedSearchTest < ActiveSupport::TestCase
end
context "Fetching the post ids for a search" do
setup do
MEMCACHE.expects(:get).returns(nil)
end
teardown do
FakeWeb.clean_registry
end

View File

@@ -6,13 +6,11 @@ class TagAliasCorrectionTest < ActiveSupport::TestCase
@mod = FactoryGirl.create(:moderator_user)
CurrentUser.user = @mod
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
@post = FactoryGirl.create(:post, :tag_string => "aaa")
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
end
teardown do
MEMCACHE.flush_all
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end

View File

@@ -6,11 +6,9 @@ class TagAliasRequestTest < ActiveSupport::TestCase
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do
MEMCACHE.flush_all
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end

View File

@@ -11,7 +11,6 @@ class TagAliasTest < ActiveSupport::TestCase
CurrentUser.user = user
end
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
mock_saved_search_service!
end

View File

@@ -6,11 +6,9 @@ class TagImplicationRequestTest < ActiveSupport::TestCase
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do
MEMCACHE.flush_all
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end

View File

@@ -7,7 +7,6 @@ class TagImplicationTest < ActiveSupport::TestCase
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
@user = FactoryGirl.create(:user)
MEMCACHE.flush_all
end
teardown do

View File

@@ -5,7 +5,6 @@ class TagSubscriptionTest < ActiveSupport::TestCase
user = FactoryGirl.create(:user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -5,7 +5,6 @@ class TagTest < ActiveSupport::TestCase
user = FactoryGirl.create(:builder_user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do
@@ -32,10 +31,6 @@ class TagTest < ActiveSupport::TestCase
end
context "A tag category fetcher" do
setup do
MEMCACHE.flush_all
end
should "fetch for a single tag" do
FactoryGirl.create(:artist_tag, :name => "test")
assert_equal(Tag.categories.artist, Tag.category_for("test"))
@@ -57,10 +52,6 @@ class TagTest < ActiveSupport::TestCase
end
context "A tag category mapping" do
setup do
MEMCACHE.flush_all
end
should "exist" do
assert_nothing_raised {Tag.categories}
end
@@ -97,10 +88,6 @@ class TagTest < ActiveSupport::TestCase
end
context "A tag" do
setup do
MEMCACHE.flush_all
end
should "be lockable by a moderator" do
@tag = FactoryGirl.create(:tag)
@tag.update_attributes({:is_locked => true}, :as => :moderator)
@@ -123,11 +110,11 @@ class TagTest < ActiveSupport::TestCase
should "reset its category after updating" do
tag = FactoryGirl.create(:artist_tag)
tag.update_category_cache_for_all
assert_equal(Tag.categories.artist, MEMCACHE.get("tc:#{tag.name}"))
assert_equal(Tag.categories.artist, Cache.get("tc:#{tag.name}"))
tag.update_attribute(:category, Tag.categories.copyright)
tag.update_category_cache_for_all
assert_equal(Tag.categories.copyright, MEMCACHE.get("tc:#{tag.name}"))
assert_equal(Tag.categories.copyright, Cache.get("tc:#{tag.name}"))
end
end

View File

@@ -17,7 +17,6 @@ class UploadTest < ActiveSupport::TestCase
user = FactoryGirl.create(:contributor_user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -4,7 +4,6 @@ class UserFeedbackTest < ActiveSupport::TestCase
context "A user's feedback" do
setup do
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -6,7 +6,6 @@ class UserTest < ActiveSupport::TestCase
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
teardown do

View File

@@ -2,7 +2,6 @@ require 'test_helper'
class WikiPageTest < ActiveSupport::TestCase
setup do
MEMCACHE.flush_all
CurrentUser.ip_addr = "127.0.0.1"
end