FIX: topic links were getting dropped when post is rebaked

This commit is contained in:
Arpit Jalan 2017-01-30 14:12:05 +05:30
parent 28e8d32d53
commit 19f7beaa2c
4 changed files with 13 additions and 17 deletions

View File

@ -33,11 +33,17 @@ module Jobs
Rails.logger.warn("Cooked post processor in FATAL state, bypassing. You need to urgently restart sidekiq\norig: #{orig_cooked}\nrecooked: #{recooked}\ncooked: #{cooked}\npost id: #{post.id}")
else
post.update_column(:cooked, cp.html)
extract_links(post)
post.publish_change_to_clients! :revised
end
end
end
# onebox may have added some links, so extract them now
def extract_links(post)
TopicLink.extract_from(post)
QuotedPost.extract_from(post)
end
end
end

View File

@ -35,16 +35,9 @@ class CookedPostProcessor
optimize_urls
pull_hotlinked_images(bypass_bump)
grant_badges
extract_links
end
end
# onebox may have added some links, so extract them now
def extract_links
TopicLink.extract_from(@post)
QuotedPost.extract_from(@post)
end
def has_emoji?
(@doc.css("img.emoji") - @doc.css(".quote img")).size > 0
end

View File

@ -602,16 +602,6 @@ describe CookedPostProcessor do
end
context "extracts links" do
let(:post) { Fabricate(:post, raw: "sam has a blog at https://samsaffron.com") }
it "always re-extracts links on post process" do
TopicLink.destroy_all
CookedPostProcessor.new(post).post_process
expect(TopicLink.count).to eq(1)
end
end
context "grant badges" do
let(:cpp) { CookedPostProcessor.new(post) }

View File

@ -46,6 +46,13 @@ describe Jobs::ProcessPost do
expect(post.cooked).not_to match(/http/)
end
it "always re-extracts links on post process" do
post.update_columns(raw: "sam has a blog at https://samsaffron.com")
TopicLink.destroy_all
Jobs::ProcessPost.new.execute(post_id: post.id)
expect(TopicLink.count).to eq(1)
end
end