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

This commit is contained in:
Blake Erickson 2023-12-20 10:17:10 -07:00 committed by GitHub
parent 22d4fbf59c
commit 43a6c1b7cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -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]

View File

@ -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