Skip to content

A platform for community discussion. Free, open, simple.

FIX: Have file size restriction type return integers (#24989)

Blake Erickson43a6c1b7cc64
diff --git a/lib/site_settings/type_supervisor.rb b/lib/site_settings/type_supervisor.rb
index 151a0c0ec92..04484b8257f 100644
--- a/lib/site_settings/type_supervisor.rb
+++ b/lib/site_settings/type_supervisor.rb
@@ -143,6 +143,8 @@ class SiteSettings::TypeSupervisor
value.to_f
when self.class.types[:integer]
value.to_i
+ when self.class.types[:file_size_restriction]
+ value.to_i
when self.class.types[:bool]
value == true || value == "t" || value == "true"
when self.class.types[:null]
diff --git a/spec/lib/site_settings/type_supervisor_spec.rb b/spec/lib/site_settings/type_supervisor_spec.rb
index d0862f8ef8b..feaac33c4ae 100644
--- a/spec/lib/site_settings/type_supervisor_spec.rb
+++ b/spec/lib/site_settings/type_supervisor_spec.rb
@@ -96,6 +96,9 @@ RSpec.describe SiteSettings::TypeSupervisor do
it "'tag_group_list' should be at the right position" do
expect(SiteSettings::TypeSupervisor.types[:tag_group_list]).to eq(26)
end
+ it "'file_size_restriction' should be at the right position" do
+ expect(SiteSettings::TypeSupervisor.types[:file_size_restriction]).to eq(27)
+ end
end
end
@@ -333,6 +336,16 @@ RSpec.describe SiteSettings::TypeSupervisor do
).to eq(1)
end
+ it "returns an integer for file_size_restriction type" do
+ expect(
+ settings.type_supervisor.to_rb_value(
+ :type_file_size_restriction,
+ "1024",
+ SiteSetting.types[:file_size_restriction],
+ ),
+ ).to eq 1024
+ end
+
it "returns nil value" do
expect(settings.type_supervisor.to_rb_value(:type_null, "1")).to eq nil
expect(settings.type_supervisor.to_rb_value(:type_null, 1)).to eq nil