From 261790854b5900b90c00dd5cc0a4c0ed5ce9f468 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 8 Feb 2024 11:39:00 -0500 Subject: [PATCH] Fix rails 7 deprecation warnings 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
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
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
at /Users/joerafaniello/Code/manageiq/spec/models/vm_reconfigure_task_spec.rb:59) --- app/models/vm_reconfigure_task.rb | 2 +- lib/acts_as_ar_model.rb | 2 +- spec/models/vm_reconfigure_task_spec.rb | 6 +++--- spec/support/chargeback_helper.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/vm_reconfigure_task.rb b/app/models/vm_reconfigure_task.rb index de22865c6ef..8c4b07f6401 100644 --- a/app/models/vm_reconfigure_task.rb +++ b/app/models/vm_reconfigure_task.rb @@ -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 diff --git a/lib/acts_as_ar_model.rb b/lib/acts_as_ar_model.rb index 63eab08d8e7..bee378212ad 100644 --- a/lib/acts_as_ar_model.rb +++ b/lib/acts_as_ar_model.rb @@ -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 diff --git a/spec/models/vm_reconfigure_task_spec.rb b/spec/models/vm_reconfigure_task_spec.rb index e80c639534c..5d0a81b1f07 100644 --- a/spec/models/vm_reconfigure_task_spec.rb +++ b/spec/models/vm_reconfigure_task_spec.rb @@ -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 @@ -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 diff --git a/spec/support/chargeback_helper.rb b/spec/support/chargeback_helper.rb index fa07d76ca3f..94beca462a0 100644 --- a/spec/support/chargeback_helper.rb +++ b/spec/support/chargeback_helper.rb @@ -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