A platform for community discussion. Free, open, simple.
FIX: Embedded topics couldn't update their titles
Robin Ward56a23c68f198
diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rbindex 1947a3c6401..64c39c527cf 100644--- a/app/models/topic_embed.rb+++ b/app/models/topic_embed.rb@@ -92,12 +92,10 @@ class TopicEmbed < ActiveRecord::Baseendif content_sha1 != embed.content_sha1- post.revise(- user,- { raw: absolutize_urls(url, contents) },- skip_validations: true,- bypass_rate_limiter: true- )+ changes = { raw: absolutize_urls(url, contents) }+ changes[:title] = title if title.present?++ post.revise(user, changes, skip_validations: true, bypass_rate_limiter: true)embed.update!(content_sha1: content_sha1)endenddiff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rbindex f15f55fff8f..59510b90bb3 100644--- a/spec/models/topic_embed_spec.rb+++ b/spec/models/topic_embed_spec.rb@@ -46,8 +46,9 @@ describe TopicEmbed doit "Supports updating the post content" doexpect do- TopicEmbed.import(user, url, title, "muhahaha new contents!")+ TopicEmbed.import(user, url, "New title received", "muhahaha new contents!")end.to change { topic_embed.reload.content_sha1 }+ expect(topic_embed.topic.title).to eq("New title received")expect(topic_embed.post.cooked).to match(/new contents/)end