FIX: limit the number of custom flags to 50 (#28221)

Admin can create up to 50 custom flags. It is limited for performance reasons.

When the limit is reached "Add button" is disabled and backend is protected by guardian.
This commit is contained in:
Krzysztof Kotlarek
2024-08-06 10:50:12 +10:00
committed by GitHub
parent 2e8273dcb4
commit fc2259d1c8
8 changed files with 52 additions and 3 deletions

View File

@@ -9,7 +9,10 @@ describe "Admin Flags Page", type: :system do
let(:admin_flag_form_page) { PageObjects::Pages::AdminFlagForm.new }
let(:flag_modal) { PageObjects::Modals::Flag.new }
before { sign_in(admin) }
before do
sign_in(admin)
SiteSetting.custom_flags_limit = 1
end
it "allows admin to disable, change order, create, update and delete flags" do
# disable
@@ -69,7 +72,11 @@ describe "Admin Flags Page", type: :system do
"Something Else",
)
admin_flags_page.visit.click_add_flag
admin_flags_page.visit
expect(admin_flags_page).to have_add_flag_button_enabled
admin_flags_page.click_add_flag
admin_flag_form_page
.fill_in_name("Vulgar")
.fill_in_description("New flag description")
@@ -87,6 +94,8 @@ describe "Admin Flags Page", type: :system do
"Vulgar",
)
expect(admin_flags_page).to have_add_flag_button_disabled
topic_page.visit_topic(post.topic).open_flag_topic_modal
expect(flag_modal).to have_choices(
@@ -126,6 +135,8 @@ describe "Admin Flags Page", type: :system do
expect(admin_flags_page).to have_no_flag("tasteless")
expect(admin_flags_page).to have_add_flag_button_enabled
topic_page.visit_topic(post.topic).open_flag_topic_modal
expect(flag_modal).to have_choices(