discourse/spec/models/admin_dashboard_section_spec.rb
Natalie Tay 8d43a7c5d7
DEV: Persist dashboard configuration in table and *not* on closure of the dialog (#40546)
The configuration used to be saved as a pipe-separated value in site
settings, with only the enabled ones. This meant there would be no order
kept if something is disabled as they were simply omitted from the site
setting.

This commit moves us to a DB table to save the settings so order can be
kept. Also, the change is committed immediately now instead of on
closure of the modal. It is also smart about not refreshing when
toggling "off" or rearranging.
2026-06-04 10:53:59 +08:00

25 lines
771 B
Ruby
Vendored

# frozen_string_literal: true
describe AdminDashboardSection do
before { described_class.delete_all }
it "requires a section_id" do
expect(described_class.new(position: 0, visible: true)).not_to be_valid
end
it "requires a position" do
expect(described_class.new(section_id: "highlights", visible: true)).not_to be_valid
end
it "enforces a unique section_id" do
described_class.create!(section_id: "highlights", position: 0, visible: true)
expect {
described_class.create!(section_id: "highlights", position: 1, visible: true)
}.to raise_error(ActiveRecord::RecordInvalid)
end
it "is valid with all attributes" do
expect(described_class.new(section_id: "highlights", position: 0, visible: false)).to be_valid
end
end