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:
@@ -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
|
||||
|
||||
@@ -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!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user