DEV: Remove usage of min_trust_to_create_topic SiteSetting (#24887)

Using min_trust_to_create_topic and create_topic_allowed_groups together was part of #24740

Now, when plugins specs are fixed, we can safely remove that part of logic.
This commit is contained in:
Krzysztof Kotlarek 2023-12-18 13:39:53 +11:00 committed by GitHub
parent 6de00f89c2
commit 1f72152e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 13 additions and 16 deletions

View File

@ -48,11 +48,8 @@ module TopicGuardian
def can_create_topic?(parent)
is_staff? ||
(
user &&
(
user.trust_level >= SiteSetting.min_trust_to_create_topic.to_i ||
user.in_any_groups?(SiteSetting.create_topic_allowed_groups_map)
) && can_create_post?(parent) && Category.topic_create_allowed(self).any?
user && user.in_any_groups?(SiteSetting.create_topic_allowed_groups_map) &&
can_create_post?(parent) && Category.topic_create_allowed(self).any?
)
end

View File

@ -3,8 +3,8 @@
require "rails_helper"
RSpec.describe NewPostManager do
let(:user) { Fabricate(:newuser) }
let(:admin) { Fabricate(:admin) }
let(:user) { Fabricate(:newuser, refresh_auto_groups: true) }
let(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
describe "when new post containing a poll is queued for approval" do
before { SiteSetting.poll_minimum_trust_level_to_create = 0 }

View File

@ -588,7 +588,7 @@ RSpec.describe PostAction do
expect(post.hidden).to eq(true)
end
it "hide tl0 posts that are flagged as spam by a tl3 user" do
newuser = Fabricate(:newuser)
newuser = Fabricate(:newuser, refresh_auto_groups: true)
post = create_post(user: newuser)
Discourse.stubs(:site_contact_user).returns(admin)

View File

@ -1483,7 +1483,7 @@ RSpec.describe PostsController do
expect(Topic.last.custom_fields).to eq({ "xyz" => "abc" })
end
xit "should add custom fields to topic that is permitted for a non-staff user via the deprecated `meta_data` param" do
it "should add custom fields to topic that is permitted for a non-staff user via the deprecated `meta_data` param" do
sign_in(user)
post "/posts.json",

View File

@ -1,9 +1,9 @@
# frozen_string_literal: true
describe "Composer Post Validations", type: :system do
fab!(:tl0_user) { Fabricate(:user, trust_level: 0) }
fab!(:tl1_user) { Fabricate(:user, trust_level: 1) }
fab!(:tl2_user) { Fabricate(:user, trust_level: 2) }
fab!(:tl0_user) { Fabricate(:user, trust_level: 0, refresh_auto_groups: true) }
fab!(:tl1_user) { Fabricate(:user, trust_level: 1, refresh_auto_groups: true) }
fab!(:tl2_user) { Fabricate(:user, trust_level: 2, refresh_auto_groups: true) }
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic) }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
describe "Composer Preview", type: :system do
fab!(:user) { Fabricate(:user, username: "bob") }
fab!(:user) { Fabricate(:user, username: "bob", refresh_auto_groups: true) }
let(:composer) { PageObjects::Components::Composer.new }
before { sign_in user }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
describe "Composer Form Template Validations", type: :system do
fab!(:user)
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:form_template) do
Fabricate(
:form_template,

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
describe "Uploading files in the composer", type: :system do
fab!(:current_user) { Fabricate(:user) }
fab!(:current_user) { Fabricate(:user, refresh_auto_groups: true) }
let(:modal) { PageObjects::Modals::Base.new }
let(:composer) { PageObjects::Components::Composer.new }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "Dismissing New", type: :system do
fab!(:user)
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
let(:discovery) { PageObjects::Pages::Discovery.new }
let(:topic_list_controls) { PageObjects::Components::TopicListControls.new }