Skip to content

Commit

Permalink
Should take integer regardless of case...
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Oct 25, 2018
1 parent 772119d commit 79acbfc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
19 changes: 19 additions & 0 deletions spec/miq_ae_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 79acbfc

Please sign in to comment.