discourse/spec/models/theme_setting_spec.rb
Alan Guo Xiang Tan a440e15291
DEV: Remove experimental_objects_type_for_theme_settings site setting (#26507)
Why this change?

Objects type for theme settings is no longer considered experimental so
we are dropping the site setting.
2024-04-04 12:01:31 +08:00

34 lines
901 B
Ruby

# frozen_string_literal: true
RSpec.describe ThemeSetting do
fab!(:theme)
context "for validations" do
it "should be invalid when json_value size is greater than the maximum allowed size" do
json_value = { "key" => "value" }
bytesize = json_value.to_json.bytesize
expect(bytesize).to eq(15)
stub_const(ThemeSetting, "MAXIMUM_JSON_VALUE_SIZE_BYTES", bytesize - 1) do
theme_setting =
ThemeSetting.new(
name: "test",
data_type: ThemeSetting.types[:objects],
theme:,
json_value:,
)
expect(theme_setting.valid?).to eq(false)
expect(theme_setting.errors[:json_value]).to contain_exactly(
I18n.t(
"theme_settings.errors.json_value.too_large",
max_size_megabytes: (bytesize - 1) / 1024 / 1024,
),
)
end
end
end
end