mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
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:

committed by
GitHub

parent
1017820012
commit
702d0620d7
@ -24,6 +24,8 @@ RSpec.describe TopicCreator do
|
||||
}
|
||||
end
|
||||
|
||||
before { Group.refresh_automatic_groups! }
|
||||
|
||||
describe "#create" do
|
||||
context "with topic success cases" do
|
||||
before do
|
||||
@ -49,7 +51,7 @@ RSpec.describe TopicCreator do
|
||||
end
|
||||
|
||||
context "with regular user" do
|
||||
before { SiteSetting.min_trust_to_create_topic = TrustLevel[0] }
|
||||
before { SiteSetting.create_topic_allowed_groups = Group::AUTO_GROUPS[:trust_level_0] }
|
||||
|
||||
it "should be possible for a regular user to create a topic" do
|
||||
expect(TopicCreator.create(user, Guardian.new(user), valid_attrs)).to be_valid
|
||||
@ -215,7 +217,7 @@ RSpec.describe TopicCreator do
|
||||
|
||||
it "lets new user create a topic if they don't have sufficient trust level to tag topics" do
|
||||
SiteSetting.min_trust_level_to_tag_topics = 1
|
||||
new_user = Fabricate(:newuser)
|
||||
new_user = Fabricate(:newuser, refresh_auto_groups: true)
|
||||
topic =
|
||||
TopicCreator.create(
|
||||
new_user,
|
||||
@ -502,8 +504,8 @@ RSpec.describe TopicCreator do
|
||||
expect(TopicCreator.create(user, Guardian.new(user), pm_valid_attrs)).to be_valid
|
||||
end
|
||||
|
||||
it "min_trust_to_create_topic setting should not be checked when sending private message" do
|
||||
SiteSetting.min_trust_to_create_topic = TrustLevel[4]
|
||||
it "create_topic_allowed_groups setting should not be checked when sending private message" do
|
||||
SiteSetting.create_topic_allowed_groups = Group::AUTO_GROUPS[:trust_level_4]
|
||||
expect(TopicCreator.create(user, Guardian.new(user), pm_valid_attrs)).to be_valid
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user