jobs: drop favgroup expunge job.

Make `Post#expunge!` remove favgroups synchronously.
This commit is contained in:
evazion
2019-08-16 20:49:34 -05:00
parent 798d524e60
commit 817f5ecf9c
3 changed files with 10 additions and 8 deletions

View File

@@ -41,6 +41,7 @@ class PostTest < ActiveSupport::TestCase
@upload = UploadService.new(FactoryBot.attributes_for(:jpg_upload)).start!
@post = @upload.post
Favorite.add(post: @post, user: @user)
create(:favorite_group).add!(@post.id)
end
teardown do
@@ -63,6 +64,12 @@ class PostTest < ActiveSupport::TestCase
assert_equal(0, Favorite.for_user(@user.id).where("post_id = ?", @post.id).count)
end
should "remove all favgroups" do
assert_equal(1, FavoriteGroup.for_post(@post.id).count)
@post.expunge!
assert_equal(0, FavoriteGroup.for_post(@post.id).count)
end
should "decrement the uploader's upload count" do
assert_difference("@post.uploader.reload.post_upload_count", -1) do
@post.expunge!