mirror of
https://github.com/discourse/discourse.git
synced 2024-12-06 07:16:17 +08:00
a440e15291
Why this change? Objects type for theme settings is no longer considered experimental so we are dropping the site setting.
34 lines
901 B
Ruby
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
|