discourse/spec/lib/theme_settings_manager/objects_spec.rb
Alan Guo Xiang Tan fb0e656cb7
DEV: Refactor subclasses in ThemeSettingsManager to individual files (#25605)
Why this change?

One Ruby class per file improves readability
2024-02-08 12:59:52 +08:00

38 lines
952 B
Ruby

# frozen_string_literal: true
RSpec.describe ThemeSettingsManager::Objects do
fab!(:theme)
before { SiteSetting.experimental_objects_type_for_theme_settings = true }
it "can store a list of objects" do
objects_setting =
described_class.new(
"some_objects_setting",
[{ "title" => "Some title", "description" => "Some description" }],
theme,
schema: {
name: "Some Object",
fields: {
title: {
type: "string",
},
description: {
type: "string",
},
},
},
)
expect(objects_setting.value).to eq(
[{ "title" => "Some title", "description" => "Some description" }],
)
objects_setting.value = [{ title: "title 1", description: "description 1" }]
expect(objects_setting.value).to eq(
[{ "title" => "title 1", "description" => "description 1" }],
)
end
end