FIX: when creating linked topics make sure they belong to same category (#11188)

This PR fixes a bug where the newly created linked topic was being
assigned "uncategorized" category. Now we'll assign linked topics the
same category as that of parent topic.

Meta reference: https://meta.discourse.org/t/linked-topics-splitting-and-managing-megatopics/168992/10?u=techapj
This commit is contained in:
Arpit Jalan
2020-11-11 00:44:27 +05:30
committed by GitHub
parent 00b41437b0
commit fec9d6e578
2 changed files with 6 additions and 2 deletions

View File

@@ -11,7 +11,8 @@ describe Jobs::CreateLinkedTopic do
context 'with a post' do
fab!(:topic) { Fabricate(:topic) }
fab!(:category) { Fabricate(:category) }
fab!(:topic) { Fabricate(:topic, category: category) }
fab!(:post) do
Fabricate(:post, topic: topic)
end
@@ -48,6 +49,7 @@ describe Jobs::CreateLinkedTopic do
expect(topic.posts.last.raw).to include(I18n.t('create_linked_topic.small_action_post_raw', new_title: "[#{new_topic.title}](#{new_topic.url})"))
expect(new_topic.title).to include(I18n.t("create_linked_topic.topic_title_with_sequence", topic_title: raw_title, count: 2))
expect(new_topic.first_post.raw).to include(topic.url)
expect(new_topic.category.id).to eq(category.id)
expect(new_topic.topic_users.count).to eq(3)
expect(new_topic.topic_users.pluck(:notification_level)).to contain_exactly(muted, tracking, watching)
expect(linked_topic.topic_id).to eq(new_topic.id)