FIX: generate topic excerpt when moving posts to new topic.

Currently, it's not generating the excerpt by default. We have to trigger the "Rebuild HTML" action to do it.
This commit is contained in:
Vinoth Kannan 2020-08-13 11:30:14 +05:30
parent ef461ffd60
commit 310952fd6a
2 changed files with 9 additions and 1 deletions

View File

@ -49,6 +49,7 @@ class PostMover
DiscourseTagging.tag_topic_by_names(new_topic, Guardian.new(user), tags) DiscourseTagging.tag_topic_by_names(new_topic, Guardian.new(user), tags)
move_posts_to new_topic move_posts_to new_topic
watch_new_topic watch_new_topic
update_topic_excerpt new_topic
new_topic new_topic
end end
enqueue_jobs(topic) enqueue_jobs(topic)
@ -57,6 +58,10 @@ class PostMover
private private
def update_topic_excerpt(topic)
topic.update_excerpt(topic.first_post.excerpt_for_topic)
end
def move_posts_to(topic) def move_posts_to(topic)
Guardian.new(user).ensure_can_see! topic Guardian.new(user).ensure_can_see! topic
@destination_topic = topic @destination_topic = topic

View File

@ -118,7 +118,10 @@ RSpec.describe TopicsController do
result = response.parsed_body result = response.parsed_body
expect(result['success']).to eq(true) expect(result['success']).to eq(true)
expect(result['url']).to eq(Topic.last.relative_url)
new_topic = Topic.last
expect(result['url']).to eq(new_topic.relative_url)
expect(new_topic.excerpt).to eq(p2.excerpt_for_topic)
expect(Tag.all.pluck(:name)).to contain_exactly("tag1", "tag2") expect(Tag.all.pluck(:name)).to contain_exactly("tag1", "tag2")
end end