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 1aaf5fc
Show file tree
Hide file tree
Showing 2 changed files with 7 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
6 changes: 6 additions & 0 deletions spec/miq_ae_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,10 @@ def value_match(value, xml_value)
end.to raise_exception(MiqPassword::MiqPasswordError)
end
end

context "integer" do
it "returns value to_i" do
%w(Integer integer Fixnum).each { |type| expect(described_class.convert_value_based_on_datatype("45", type)).to eq(45) }
end
end
end

0 comments on commit 1aaf5fc

Please sign in to comment.