forked from e621ng/e621ng
[Tests] Be explitic about where jobs need to be inlined
This commit is contained in:
parent
d51ad1b812
commit
02a4051031
@ -1,14 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PostReplacementsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
Sidekiq::Testing.inline!
|
||||
end
|
||||
|
||||
teardown do
|
||||
Sidekiq::Testing.fake!
|
||||
end
|
||||
|
||||
context "The post replacements controller" do
|
||||
setup do
|
||||
@user = create(:moderator_user, can_approve_posts: true, created_at: 1.month.ago)
|
||||
|
@ -1,14 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UploadsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
Sidekiq::Testing.inline!
|
||||
end
|
||||
|
||||
teardown do
|
||||
Sidekiq::Testing.fake!
|
||||
end
|
||||
|
||||
context "The uploads controller" do
|
||||
setup do
|
||||
@user = create(:janitor_user)
|
||||
|
@ -56,6 +56,10 @@ class ActiveSupport::TestCase
|
||||
def as(user, ip_addr = "127.0.0.1", &)
|
||||
CurrentUser.scoped(user, ip_addr, &)
|
||||
end
|
||||
|
||||
def with_inline_jobs(&)
|
||||
Sidekiq::Testing.inline!(&)
|
||||
end
|
||||
end
|
||||
|
||||
class ActionDispatch::IntegrationTest
|
||||
|
@ -37,19 +37,13 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
create implication bar -> baz
|
||||
)
|
||||
|
||||
Sidekiq::Testing.inline!
|
||||
|
||||
@bur = create(:bulk_update_request, script: @script)
|
||||
@bur.approve!(@admin)
|
||||
with_inline_jobs { @bur.approve!(@admin) }
|
||||
|
||||
@ta = TagAlias.where(antecedent_name: "foo", consequent_name: "bar").first
|
||||
@ti = TagImplication.where(antecedent_name: "bar", consequent_name: "baz").first
|
||||
end
|
||||
|
||||
teardown do
|
||||
Sidekiq::Testing.fake!
|
||||
end
|
||||
|
||||
should "reference the approver in the automated message" do
|
||||
assert_match(Regexp.compile(@admin.name), @bur.forum_post.body)
|
||||
end
|
||||
|
@ -6,21 +6,15 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
setup do
|
||||
Sidekiq::Testing.inline!
|
||||
@user = create(:user, created_at: 2.weeks.ago)
|
||||
CurrentUser.user = @user
|
||||
Post.__elasticsearch__.create_index!
|
||||
end
|
||||
|
||||
teardown do
|
||||
Sidekiq::Testing.fake!
|
||||
end
|
||||
|
||||
context "Deletion:" do
|
||||
context "Expunging a post" do
|
||||
# That belonged in a museum!
|
||||
setup do
|
||||
Sidekiq::Testing.fake!
|
||||
@upload = UploadService.new(attributes_for(:jpg_upload)).start!
|
||||
@post = @upload.post
|
||||
FavoriteManager.add!(user: @post.uploader, post: @post)
|
||||
@ -279,7 +273,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
c1 = create(:post, parent_id: p1.id)
|
||||
user = create(:privileged_user)
|
||||
FavoriteManager.add!(user: user, post: c1)
|
||||
c1.delete!("test", :move_favorites => true)
|
||||
with_inline_jobs { c1.delete!("test", move_favorites: true) }
|
||||
p1.reload
|
||||
assert(!Favorite.exists?(:post_id => c1.id, :user_id => user.id), "Child should not still have favorites")
|
||||
assert(Favorite.exists?(:post_id => p1.id, :user_id => user.id), "Parent should have favorites")
|
||||
@ -503,10 +497,10 @@ class PostTest < ActiveSupport::TestCase
|
||||
context "with an artist tag that is then changed to copyright" do
|
||||
setup do
|
||||
CurrentUser.user = create(:janitor_user)
|
||||
@post = Post.find(@post.id)
|
||||
@post.update(:tag_string => "art:abc")
|
||||
@post = Post.find(@post.id)
|
||||
@post.update(:tag_string => "copy:abc")
|
||||
with_inline_jobs do
|
||||
@post.update(tag_string: "art:abc")
|
||||
@post.update(tag_string: "copy:abc")
|
||||
end
|
||||
@post.reload
|
||||
end
|
||||
|
||||
@ -1377,7 +1371,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
FavoriteManager.add!(user: @supervoter1, post: @child)
|
||||
FavoriteManager.add!(user: @supervoter1, post: @parent)
|
||||
|
||||
@child.give_favorites_to_parent
|
||||
with_inline_jobs { @child.give_favorites_to_parent }
|
||||
@child.reload
|
||||
@parent.reload
|
||||
end
|
||||
@ -1954,8 +1948,6 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "return no posts when the replacement is not pending anymore" do
|
||||
Sidekiq::Testing.fake!
|
||||
|
||||
post1 = create(:post)
|
||||
upload = UploadService.new(attributes_for(:upload).merge(file: fixture_file_upload("test.gif"), uploader: @user, tag_string: "tst")).start!
|
||||
post2 = upload.post
|
||||
|
@ -1,14 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagAliasTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
Sidekiq::Testing.inline!
|
||||
end
|
||||
|
||||
teardown do
|
||||
Sidekiq::Testing.fake!
|
||||
end
|
||||
|
||||
context "A tag alias" do
|
||||
setup do
|
||||
@admin = create(:admin_user)
|
||||
@ -87,7 +79,7 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
post2 = create(:post, tag_string: "ccc ddd")
|
||||
|
||||
ta = create(:tag_alias, antecedent_name: "aaa", consequent_name: "ccc")
|
||||
ta.approve!(approver: @admin)
|
||||
with_inline_jobs { ta.approve!(approver: @admin) }
|
||||
|
||||
assert_equal("bbb ccc", post1.reload.tag_string)
|
||||
assert_equal("ccc ddd", post2.reload.tag_string)
|
||||
@ -106,8 +98,10 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
should "move existing aliases" do
|
||||
ta1 = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb", status: "pending")
|
||||
ta2 = create(:tag_alias, antecedent_name: "bbb", consequent_name: "ccc", status: "pending")
|
||||
ta1.approve!(approver: @admin)
|
||||
ta2.approve!(approver: @admin)
|
||||
with_inline_jobs do
|
||||
ta1.approve!(approver: @admin)
|
||||
ta2.approve!(approver: @admin)
|
||||
end
|
||||
|
||||
assert_equal("ccc", ta1.reload.consequent_name)
|
||||
end
|
||||
@ -115,7 +109,7 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
should "move existing implications" do
|
||||
ti = create(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb")
|
||||
ta = create(:tag_alias, antecedent_name: "bbb", consequent_name: "ccc")
|
||||
ta.approve!(approver: @admin)
|
||||
with_inline_jobs { ta.approve!(approver: @admin) }
|
||||
|
||||
ti.reload
|
||||
assert_equal("ccc", ti.consequent_name)
|
||||
@ -142,7 +136,7 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
tag1 = create(:tag, name: "aaa", category: 1)
|
||||
tag2 = create(:tag, name: "bbb", category: 0)
|
||||
ta = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
|
||||
ta.approve!(approver: @admin)
|
||||
with_inline_jobs { ta.approve!(approver: @admin) }
|
||||
|
||||
assert_equal(1, tag2.reload.category)
|
||||
end
|
||||
@ -168,13 +162,13 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
|
||||
should "update the topic when processed" do
|
||||
assert_difference("ForumPost.count") do
|
||||
@alias.approve!(approver: @admin)
|
||||
with_inline_jobs { @alias.approve!(approver: @admin) }
|
||||
end
|
||||
end
|
||||
|
||||
should "update the parent post" do
|
||||
previous = @post.body
|
||||
@alias.approve!(approver: @admin)
|
||||
with_inline_jobs { @alias.approve!(approver: @admin) }
|
||||
@post.reload
|
||||
assert_not_equal(previous, @post.body)
|
||||
end
|
||||
@ -187,7 +181,7 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
|
||||
should "update the topic when failed" do
|
||||
TagAlias.any_instance.stubs(:update_blacklists).raises(Exception, "oh no")
|
||||
@alias.approve!(approver: @admin)
|
||||
with_inline_jobs { @alias.approve!(approver: @admin) }
|
||||
@topic.reload
|
||||
@alias.reload
|
||||
|
||||
|
@ -1,14 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagImplicationTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
Sidekiq::Testing.inline!
|
||||
end
|
||||
|
||||
teardown do
|
||||
Sidekiq::Testing.fake!
|
||||
end
|
||||
|
||||
context "A tag implication" do
|
||||
setup do
|
||||
user = create(:admin_user)
|
||||
@ -220,8 +212,10 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
p1 = create(:post, tag_string: "aaa bbb ccc")
|
||||
ti1 = create(:tag_implication, antecedent_name: "aaa", consequent_name: "xxx")
|
||||
ti2 = create(:tag_implication, antecedent_name: "aaa", consequent_name: "yyy")
|
||||
ti1.approve!
|
||||
ti2.approve!
|
||||
with_inline_jobs do
|
||||
ti1.approve!
|
||||
ti2.approve!
|
||||
end
|
||||
|
||||
assert_equal("aaa bbb ccc xxx yyy", p1.reload.tag_string)
|
||||
end
|
||||
@ -236,7 +230,7 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
|
||||
should "update the topic when processed" do
|
||||
assert_difference("ForumPost.count") do
|
||||
@implication.approve!
|
||||
with_inline_jobs { @implication.approve! }
|
||||
end
|
||||
@post.reload
|
||||
@topic.reload
|
||||
|
@ -2,15 +2,10 @@ require 'test_helper'
|
||||
|
||||
class TagTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
Sidekiq::Testing.inline!
|
||||
@janitor = create(:janitor_user)
|
||||
CurrentUser.user = @janitor
|
||||
end
|
||||
|
||||
teardown do
|
||||
Sidekiq::Testing.fake!
|
||||
end
|
||||
|
||||
context ".trending" do
|
||||
setup do
|
||||
Tag.stubs(:trending_count_limit).returns(0)
|
||||
@ -213,7 +208,7 @@ class TagTest < ActiveSupport::TestCase
|
||||
assert_equal(0, post.tag_count_character)
|
||||
|
||||
tag = Tag.find_by_normalized_name('test')
|
||||
tag.update_attribute(:category, 4)
|
||||
with_inline_jobs { tag.update_attribute(:category, 4) }
|
||||
assert_equal tag.errors.full_messages, []
|
||||
post.reload
|
||||
assert_equal(0, post.tag_count_general)
|
||||
|
@ -1,14 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UserDeletionTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
Sidekiq::Testing.inline!
|
||||
end
|
||||
|
||||
teardown do
|
||||
Sidekiq::Testing.fake!
|
||||
end
|
||||
|
||||
context "an invalid user deletion" do
|
||||
context "for an invalid password" do
|
||||
setup do
|
||||
@ -50,7 +42,7 @@ class UserDeletionTest < ActiveSupport::TestCase
|
||||
@user.update(email: "ted@danbooru.com")
|
||||
|
||||
@deletion = UserDeletion.new(@user, "password")
|
||||
@deletion.delete!
|
||||
with_inline_jobs { @deletion.delete! }
|
||||
@user.reload
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user