DEV: Convert min_trust_to_create_topic to groups (#24740)

This change converts the min_trust_to_create_topic site setting to
create_topic_allowed_groups.

See: https://meta.discourse.org/t/283408

- Hides the old setting
- Adds the new site setting
- Add a deprecation warning
- Updates to use the new setting
- Adds a migration to fill in the new setting if the old setting was
changed
- Adds an entry to the site_setting.keywords section
- Updates tests to account for the new change
- After a couple of months, we will remove the min_trust_to_create_topicsetting entirely.

Internal ref: /t/117248
This commit is contained in:
Krzysztof Kotlarek
2023-12-13 14:50:13 +11:00
committed by GitHub
parent 1017820012
commit 702d0620d7
41 changed files with 169 additions and 76 deletions

View File

@ -4,7 +4,7 @@ RSpec.describe TopicsBulkAction do
fab!(:topic)
describe "#dismiss_topics" do
fab!(:user) { Fabricate(:user, created_at: 1.days.ago) }
fab!(:user) { Fabricate(:user, created_at: 1.days.ago, refresh_auto_groups: true) }
fab!(:category)
fab!(:topic2) { Fabricate(:topic, category: category, created_at: 60.minutes.ago) }
fab!(:topic3) { Fabricate(:topic, category: category, created_at: 120.minutes.ago) }
@ -156,7 +156,10 @@ RSpec.describe TopicsBulkAction do
context "when the user can edit the topic" do
context "with 'create_revision_on_bulk_topic_moves' setting enabled" do
before { SiteSetting.create_revision_on_bulk_topic_moves = true }
before do
SiteSetting.create_revision_on_bulk_topic_moves = true
Group.refresh_automatic_groups!
end
it "changes the category, creates a post revision and returns the topic_id" do
old_category_id = topic.category_id
@ -195,7 +198,10 @@ RSpec.describe TopicsBulkAction do
end
context "with 'create_revision_on_bulk_topic_moves' setting disabled" do
before { SiteSetting.create_revision_on_bulk_topic_moves = false }
before do
SiteSetting.create_revision_on_bulk_topic_moves = false
Group.refresh_automatic_groups!
end
it "changes the category, doesn't create a post revision and returns the topic_id" do
tba =
@ -415,6 +421,7 @@ RSpec.describe TopicsBulkAction do
SiteSetting.tagging_enabled = true
SiteSetting.min_trust_level_to_tag_topics = 0
topic.tags = [tag1, tag2]
Group.refresh_automatic_groups!
end
it "can change the tags, and can create new tags" do
@ -483,6 +490,7 @@ RSpec.describe TopicsBulkAction do
SiteSetting.tagging_enabled = true
SiteSetting.min_trust_level_to_tag_topics = 0
topic.tags = [tag1, tag2]
Group.refresh_automatic_groups!
end
it "can append new or existing tags" do
@ -553,6 +561,7 @@ RSpec.describe TopicsBulkAction do
SiteSetting.tagging_enabled = true
SiteSetting.min_trust_level_to_tag_topics = 0
topic.tags = [tag1, tag2]
Group.refresh_automatic_groups!
end
it "can remove all tags" do