-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert_value_based_on_datatype won't take "Integer" #258
convert_value_based_on_datatype won't take "Integer" #258
Conversation
@miq-bot add_reviewer @tinaafitz |
@miq-bot add_label hammer/yes |
@@ -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 datatype == 'integer' || datatype == 'Fixnum' || datatype == 'Integer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe: datatype.casecmp?('integer')
1f0fb97
to
6f970b0
Compare
return value.gsub(/[\[\]]/, '').strip.split(/\s*,\s*/) if datatype == 'array' && value.class == String | ||
return Time.parse(value) if datatype.casecmp?('time') | ||
return value.to_sym if datatype.casecmp?('symbol') | ||
return value.to_i if datatype.casecmp?('integer') || datatype == 'Fixnum' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lower-case 'integer' type comes from the Automate class schema which is why we initially had that value and Fixnum
. Ruby 2.4 replaced Fixnum
with Integer
which causes the issue.
Since we still support Ruby 2.3 we will need to retain the Fixnum
check here for a bit longer.
1f1d4a7
to
d6ad1a1
Compare
@gmcculloug can you please take another look? |
fd16f2b
to
2f1338c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we set for tests on this method? Should be an easy one to test.
0b919fc
to
79acbfc
Compare
spec/miq_ae_object_spec.rb
Outdated
let(:datatype2) { "Fixnum" } | ||
|
||
it "returns value to_i" do | ||
expect(described_class.convert_value_based_on_datatype(value, datatype)).to eq(45) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just loop over the different datatypes in one test? There's not a big difference between the first test returns value to_i
and the other two returns value to_i
so maybe we just combine them.
79acbfc
to
1aaf5fc
Compare
Checked commit d-m-u@1aaf5fc with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
…rt_value_based_on_datatype convert_value_based_on_datatype won't take "Integer" (cherry picked from commit 67488e4) https://bugzilla.redhat.com/show_bug.cgi?id=1628224
Hammer backport details:
|
This is the last PR I need to fix https://bugzilla.redhat.com/show_bug.cgi?id=1628224. Custom Buttons on multiple objects aren't being run because the engine won't take "Integer" ... which I think it should. This hackiness seems to be the convention for Time and Symbol.
related
already merged
ManageIQ/manageiq#18056