discourse/spec/system/new_category_spec.rb
David Taylor b620031b8d
FIX: Possible crash during category creation (#35277)
In a couple of places, we were calling `site.updateCategory` with an
existing category model instance. This was then passed to
`.setProperties`. `setProperties` then tries to set all sorts of weird
things, including overriding functions in the model like `init()`.

This commit adds an assertion on `updateCategory` to stop that
happening, and updates a couple of call sites to pass a pojo instead.

Also updates the test fixture for category creation, since it was
missing a load of newer attributes. Previously this wasn't noticed
because a model instance was being re-used.

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2025-10-08 12:31:16 +01:00

25 lines
858 B
Ruby

# frozen_string_literal: true
describe "New Category", type: :system do
fab!(:admin)
let(:category_page) { PageObjects::Pages::Category.new }
before { sign_in(admin) }
it "should create category with 0 in minimum_required_tags column when not defined" do
category_page.visit_new_category
category_page.find(".edit-category-tab-general input.category-name").fill_in(
with: "New Category",
)
category_page.find(".edit-category-nav .edit-category-tags a").click
category_page.find(".edit-category-tab-tags #category-minimum-tags").click
category_page.save_settings
expect(page).to have_current_path("/c/new-category/edit/general")
category_page.find(".edit-category-nav .edit-category-tags a").click
expect(category_page.find(".edit-category-tab-tags #category-minimum-tags").value).to eq("0")
end
end