diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb index 5ae14d506..984f7131e 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb @@ -559,7 +559,7 @@ def self.convert_value_based_on_datatype(value, datatype) return false if datatype == 'FalseClass' return Time.parse(value) if datatype == 'time' || datatype == 'Time' return value.to_sym if datatype == 'symbol' || datatype == 'Symbol' - return value.to_i if datatype == 'integer' || datatype == 'Fixnum' + return value.to_i if %w(integer Integer Fixnum).include?(datatype) return value.to_f if datatype == 'float' || datatype == 'Float' return value.gsub(/[\[\]]/, '').strip.split(/\s*,\s*/) if datatype == 'array' && value.class == String return decrypt_password(value) if datatype == 'password' diff --git a/spec/miq_ae_object_spec.rb b/spec/miq_ae_object_spec.rb index cb7dbc48c..2fa32ae96 100644 --- a/spec/miq_ae_object_spec.rb +++ b/spec/miq_ae_object_spec.rb @@ -316,4 +316,23 @@ def value_match(value, xml_value) end.to raise_exception(MiqPassword::MiqPasswordError) end end + + context "integer" do + let(:value) { "45" } + let(:datatype) { "Integer" } + let(:datatype1) { "integer" } + let(:datatype2) { "Fixnum" } + + it "returns value to_i" do + expect(described_class.convert_value_based_on_datatype(value, datatype)).to eq(45) + end + + it "returns value to_i" do + expect(described_class.convert_value_based_on_datatype(value, datatype1)).to eq(45) + end + + it "returns value to_i" do + expect(described_class.convert_value_based_on_datatype(value, datatype2)).to eq(45) + end + end end