Skip to content

Commit

Permalink
Fix rails 7 deprecation warnings
Browse files Browse the repository at this point in the history
Fixes the following deprecation warnings:
DEPRECATION WARNING: Time#to_s(:db) is deprecated. Please use Time#to_fs(:db) instead. (called from block (2 levels) in add_metric_rollups_for at /Users/joerafaniello/Code/manageiq/spec/support/chargeback_helper.rb:43)
DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_fs(:human_size) instead. (called from block in build_disk_message at /Users/joerafaniello/Code/manageiq/app/models/vm_reconfigure_task.rb:43)
DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_fs(:human_size) instead. (called from block (3 levels) in <main> at /Users/joerafaniello/Code/manageiq/spec/models/vm_reconfigure_task_spec.rb:45)
DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_fs(:human_size) instead. (called from block (3 levels) in <main> at /Users/joerafaniello/Code/manageiq/spec/models/vm_reconfigure_task_spec.rb:58)
DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_fs(:human_size) instead. (called from block (3 levels) in <main> at /Users/joerafaniello/Code/manageiq/spec/models/vm_reconfigure_task_spec.rb:59)
  • Loading branch information
jrafanie committed Jul 11, 2024
1 parent 0937672 commit 2617908
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/vm_reconfigure_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def self.build_message(options, key, message, modifier = nil)

def self.build_disk_message(options)
if options[:disk_add].present?
disk_sizes = options[:disk_add].collect { |d| d["disk_size_in_mb"].to_i.megabytes.to_s(:human_size) + ", Type: " + d["type"].to_s }
disk_sizes = options[:disk_add].collect { |d| d["disk_size_in_mb"].to_i.megabytes.to_fs(:human_size) + ", Type: " + d["type"].to_s }
"Add Disks: #{options[:disk_add].length} : #{disk_sizes.join(", ")} "
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_ar_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def attribute_for_inspect(attr_name)
if value.kind_of?(String) && value.length > 50
"#{value[0..50]}...".inspect
elsif value.kind_of?(Date) || value.kind_of?(Time)
%("#{value.to_s(:db)}")
%("#{value.to_fs(:db)}")
else
value.inspect
end
Expand Down
6 changes: 3 additions & 3 deletions spec/models/vm_reconfigure_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
context "Single Disk add " do
let(:request_options) { {:disk_add => [{"disk_size_in_mb" => "33", "persistent" => "true", "type" => "thin"}.with_indifferent_access]} }
let(:description_partial) do
"Add Disks: 1 : #{request.options[:disk_add][0]["disk_size_in_mb"].to_i.megabytes.to_s(:human_size)}, Type: " \
"Add Disks: 1 : #{request.options[:disk_add][0]["disk_size_in_mb"].to_i.megabytes.to_fs(:human_size)}, Type: " \
"#{request.options[:disk_add][0]["type"]} "
end

Expand All @@ -55,8 +55,8 @@
{"disk_size_in_mb" => "44", "persistent" => "true", "type" => "thick"}.with_indifferent_access]}
end
let(:description_partial) do
"Add Disks: 2 : #{request.options[:disk_add][0]["disk_size_in_mb"].to_i.megabytes.to_s(:human_size)}, Type: " \
"#{request.options[:disk_add][0]["type"]}, #{request.options[:disk_add][1]["disk_size_in_mb"].to_i.megabytes.to_s(:human_size)}, Type: " \
"Add Disks: 2 : #{request.options[:disk_add][0]["disk_size_in_mb"].to_i.megabytes.to_fs(:human_size)}, Type: " \
"#{request.options[:disk_add][0]["type"]}, #{request.options[:disk_add][1]["disk_size_in_mb"].to_i.megabytes.to_fs(:human_size)}, Type: " \
"#{request.options[:disk_add][1]["type"]} "
end

Expand Down
2 changes: 1 addition & 1 deletion spec/support/chargeback_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def add_metric_rollups_for(resources, range, step, metric_rollup_params, trait =
base_values
end

record_values << "(#{values}, '#{time.to_s(:db)}')"
record_values << "(#{values}, '#{time.to_fs(:db)}')"
end
end

Expand Down

0 comments on commit 2617908

Please sign in to comment.