mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FIX: TopicEmbed.import should update title and author
This commit is contained in:
parent
a2bc2ca08f
commit
0cc4b42180
@ -73,7 +73,13 @@ class TopicEmbed < ActiveRecord::Base
|
||||
post = embed.post
|
||||
# Update the topic if it changed
|
||||
if post && post.topic && content_sha1 != embed.content_sha1
|
||||
post.revise(user, { raw: absolutize_urls(url, contents) }, skip_validations: true, bypass_rate_limiter: true)
|
||||
post_revision_args = {
|
||||
raw: absolutize_urls(url, contents),
|
||||
user_id: user.id,
|
||||
title: title,
|
||||
}
|
||||
|
||||
post.revise(user, post_revision_args, skip_validations: true, bypass_rate_limiter: true)
|
||||
embed.update_column(:content_sha1, content_sha1)
|
||||
end
|
||||
end
|
||||
|
@ -82,6 +82,18 @@ describe Jobs::PollFeed do
|
||||
expect { poller.poll_feed }.to change { Topic.count }.by(1)
|
||||
expect(Topic.last.user).to eq(feed_author)
|
||||
end
|
||||
|
||||
it "updates the post if it had been polled" do
|
||||
embed_url = 'https://blog.discourse.org/2017/09/poll-feed-spec-fixture'
|
||||
post = TopicEmbed.import(Fabricate(:user), embed_url, 'old title', 'old content')
|
||||
|
||||
expect { poller.poll_feed }.to_not change { Topic.count }
|
||||
|
||||
post.reload
|
||||
expect(post.topic.title).to eq('Poll Feed Spec Fixture')
|
||||
expect(post.raw).to include('<p>This is the body & content. </p>')
|
||||
expect(post.user).to eq(feed_author)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,8 +41,12 @@ describe TopicEmbed do
|
||||
end
|
||||
|
||||
it "Supports updating the post" do
|
||||
post = TopicEmbed.import(user, url, title, "muhahaha new contents!")
|
||||
new_user = Fabricate(:user)
|
||||
|
||||
post = TopicEmbed.import(new_user, url, title, "muhahaha new contents!")
|
||||
|
||||
expect(post.cooked).to match(/new contents/)
|
||||
expect(post.user).to eq(new_user)
|
||||
end
|
||||
|
||||
it "Should leave uppercase Feed Entry URL untouched in content" do
|
||||
|
Loading…
Reference in New Issue
Block a user