mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Unable to move pm to public topic (#24903)
* FIX: guard against empty category_ids when creating small action post for changing of category Co-authored-by: Kelvin Tan <kelv@discourse.org>
This commit is contained in:
parent
5417c4fac0
commit
7aeb5d6012
|
@ -154,7 +154,9 @@ class PostRevisor
|
|||
end
|
||||
|
||||
def self.create_small_action_for_category_change(topic:, user:, old_category:, new_category:)
|
||||
return if !SiteSetting.create_post_for_category_and_tag_changes
|
||||
if !old_category || !new_category || !SiteSetting.create_post_for_category_and_tag_changes
|
||||
return
|
||||
end
|
||||
|
||||
topic.add_moderator_post(
|
||||
user,
|
||||
|
|
|
@ -291,6 +291,17 @@ RSpec.describe PostRevisor do
|
|||
),
|
||||
)
|
||||
end
|
||||
|
||||
describe "with PMs" do
|
||||
fab!(:pm) { Fabricate(:private_message_topic) }
|
||||
let(:first_post) { create_post(user: admin, topic: pm, allow_uncategorized_topics: false) }
|
||||
fab!(:category) { Fabricate(:category, topic_count: 1) }
|
||||
it "Does not create a category change small_action post when converting to a topic" do
|
||||
expect do
|
||||
TopicConverter.new(first_post.topic, admin).convert_to_public_topic(category.id)
|
||||
end.to change { category.reload.topic_count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user