posts: mark media asset as expunged when post is expunged.

Fix it so that when a post is expunged, the media asset is also marked
as expunged. This way the files will be deleted, but the media asset
will still remain as a record of what was expunged. The media asset will
have the md5, width, height, file ext, and file size of the deleted file.
This commit is contained in:
evazion
2021-10-26 02:47:01 -05:00
parent 84212acfae
commit afe5095ee6
4 changed files with 16 additions and 27 deletions

View File

@@ -25,8 +25,7 @@ FactoryBot.define do
image_height { media_file.height }
file_ext { media_file.file_ext }
file_size { media_file.file_size }
before(:create) { |post, evaluator| MediaAsset.upload!(evaluator.media_file) }
media_asset { MediaAsset.upload!(media_file) }
end
end
end

View File

@@ -47,6 +47,12 @@ class PostTest < ActiveSupport::TestCase
assert_raise(StandardError) { @post.file(:original) }
end
should "mark the media asset as expunged" do
@post.expunge!
assert_equal("expunged", @post.media_asset.status)
end
should "remove all favorites" do
@post.expunge!