Skip to content

Commit

Permalink
FIX: Have file size restriction type return integers (#24989)
Browse files Browse the repository at this point in the history
  • Loading branch information
oblakeerickson committed Dec 20, 2023
1 parent 22d4fbf commit 43a6c1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/site_settings/type_supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def to_rb_value(name, value, override_type = nil)
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]
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/site_settings/type_supervisor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
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

Expand Down Expand Up @@ -333,6 +336,16 @@ def self.schema
).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
Expand Down

0 comments on commit 43a6c1b

Please sign in to comment.