REVERT: DEV: should ignore missing post uploads when a user export destroyed

Reverts 793915fe6a. We no longer need this since we're destroying each posts in commit 028121b95b.
This commit is contained in:
Vinoth Kannan 2019-07-25 19:41:25 +05:30
parent 7e0eeed292
commit 2ba4de2d45
2 changed files with 0 additions and 26 deletions

View File

@ -5,16 +5,8 @@ class UserExport < ActiveRecord::Base
belongs_to :upload, dependent: :destroy
belongs_to :topic, dependent: :destroy
around_destroy :ignore_missing_post_uploads
DESTROY_CREATED_BEFORE = 2.days.ago
def ignore_missing_post_uploads
post_ids = upload.post_uploads.pluck(:post_id)
yield
post_ids.each { |post_id| PostCustomField.create!(post_id: post_id, name: Post::MISSING_UPLOADS_IGNORED, value: "t") }
end
def self.remove_old_exports
UserExport.where('created_at < ?', DESTROY_CREATED_BEFORE).find_each do |user_export|
UserExport.transaction do

View File

@ -41,22 +41,4 @@ RSpec.describe UserExport do
expect(Topic.exists?(id: topic_2.id)).to eq(true)
end
end
describe '#destroy!' do
it 'should create post custom field for ignored missing uploads' do
upload = Fabricate(:upload, created_at: 3.days.ago)
export = UserExport.create!(
file_name: "test",
user: user,
upload_id: upload.id,
created_at: 3.days.ago
)
post = Fabricate(:post, raw: "![#{upload.original_filename}](#{upload.short_url})")
post.link_post_uploads
export.destroy!
expect(PostCustomField.exists?(post_id: post.id, name: Post::MISSING_UPLOADS_IGNORED)).to eq(true)
end
end
end