FIX: replace default welcome topic post with new value from wizard

Previously the text entered in the wizard would be prepended onto the
default first paragraph.
This commit is contained in:
Neil Lalonde
2020-04-01 15:42:36 -04:00
parent b82f6098ce
commit 90fcede832
2 changed files with 44 additions and 3 deletions

View File

@ -18,9 +18,12 @@ class IntroductionUpdater
if previous_value != new_value
revisor = PostRevisor.new(post)
remaining = post.raw.split("\n")[1..-1]
revisor.revise!(@user, raw: "#{new_value}\n#{remaining.join("\n")}")
if post.raw.chomp == I18n.t('discourse_welcome_topic.body', base_path: Discourse.base_path).chomp
revisor.revise!(@user, raw: new_value)
else
remaining = post.raw[previous_value.length..-1]
revisor.revise!(@user, raw: "#{new_value}#{remaining}")
end
end
end