mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
At the moment there is no way in the UI to convert a category to nested replies. This introduces a backfill button and UI to show admin the current state (using category custom field). Screenshots pretty much tell the story: <img width="1483" height="1187" alt="Screenshot 2026-07-02 at 10 08 23 AM" src="https://github.com/user-attachments/assets/532bd7d2-8aae-455a-9744-aee0f3ac5b82" /> <img width="1498" height="1247" alt="Screenshot 2026-07-02 at 10 08 38 AM" src="https://github.com/user-attachments/assets/a1382732-8b72-4526-a770-72b6452b56bb" /> <img width="1460" height="1220" alt="Screenshot 2026-07-02 at 10 08 58 AM" src="https://github.com/user-attachments/assets/b4113347-c760-4f66-b947-988c270750a6" />
48 lines
1.4 KiB
Ruby
Vendored
48 lines
1.4 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe CategorySetting do
|
|
it { is_expected.to belong_to(:category) }
|
|
|
|
it do
|
|
is_expected.to validate_numericality_of(:num_auto_bump_daily)
|
|
.only_integer
|
|
.is_greater_than_or_equal_to(0)
|
|
.allow_nil
|
|
end
|
|
|
|
it do
|
|
is_expected.to validate_numericality_of(:auto_bump_cooldown_days)
|
|
.only_integer
|
|
.is_greater_than_or_equal_to(0)
|
|
.allow_nil
|
|
end
|
|
|
|
describe "nested replies conversion state" do
|
|
fab!(:category)
|
|
|
|
it "clears the conversion custom field when nested replies are disabled" do
|
|
category.category_setting.update!(nested_replies_default: true)
|
|
category.mark_nested_replies_conversion_completed!
|
|
|
|
expect { category.category_setting.update!(nested_replies_default: false) }.to change {
|
|
category.reload.nested_replies_conversion_completed?
|
|
}.from(true).to(false)
|
|
|
|
expect(
|
|
CategoryCustomField.exists?(
|
|
category_id: category.id,
|
|
name: NestedReplies::CONVERSION_COMPLETED_CUSTOM_FIELD,
|
|
),
|
|
).to eq(false)
|
|
end
|
|
|
|
it "keeps the conversion custom field when nested replies stay enabled" do
|
|
category.category_setting.update!(nested_replies_default: true)
|
|
category.mark_nested_replies_conversion_completed!
|
|
|
|
expect { category.category_setting.update!(auto_bump_cooldown_days: 2) }.not_to change {
|
|
category.reload.nested_replies_conversion_completed?
|
|
}
|
|
end
|
|
end
|
|
end
|