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.
32 lines
801 B
Ruby
32 lines
801 B
Ruby
FactoryBot.define do
|
|
factory(:post) do
|
|
md5 { SecureRandom.hex(32) }
|
|
uploader
|
|
uploader_ip_addr {"127.0.0.1"}
|
|
tag_string {"tag1 tag2"}
|
|
tag_count {2}
|
|
tag_count_general {2}
|
|
file_ext {"jpg"}
|
|
image_width {1500}
|
|
image_height {1000}
|
|
file_size {2000}
|
|
rating {"q"}
|
|
source { FFaker::Internet.http_url }
|
|
media_asset { build(:media_asset) }
|
|
|
|
factory(:post_with_file) do
|
|
transient do
|
|
filename { "test.jpg" }
|
|
media_file { MediaFile.open("test/files/#{filename}") }
|
|
end
|
|
|
|
md5 { media_file.md5 }
|
|
image_width { media_file.width }
|
|
image_height { media_file.height }
|
|
file_ext { media_file.file_ext }
|
|
file_size { media_file.file_size }
|
|
media_asset { MediaAsset.upload!(media_file) }
|
|
end
|
|
end
|
|
end
|