Skip to content

Commit

Permalink
Fix undefined method issue for DialogFieldTagControl
Browse files Browse the repository at this point in the history
https://bugzilla.redhat.com/show_bug.cgi?id=1382765

Also will fix the issue for either drop downs or radio buttons that
somehow end up with nil values instead of multidimentional arrays
  • Loading branch information
eclarizio committed Oct 7, 2016
1 parent 5758548 commit a72ab1b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/dialog_field_sorted_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def sort_data(data_to_sort)
def raw_values
@raw_values ||= dynamic ? values_from_automate : self[:values].to_miq_a
unless @raw_values.collect { |value_pair| value_pair[0] }.include?(default_value)
self.default_value = sort_data(@raw_values).first.first
self.default_value = sort_data(@raw_values).first.try(:first)
end
self.value ||= default_value

Expand Down
20 changes: 18 additions & 2 deletions spec/models/dialog_field_drop_down_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,27 @@

context "when the raw values are not already set" do
before do
dialog_field.values = %w(original values)
dialog_field.values = [%w(original values)]
end

it "returns the values" do
expect(dialog_field.trigger_automate_value_updates).to eq(%w(original values))
expect(dialog_field.trigger_automate_value_updates).to eq([%w(original values)])
end

it "sets up the default value" do
dialog_field.trigger_automate_value_updates
expect(dialog_field.default_value).to eq("original")
end
end

context "when the raw values are nil" do
before do
dialog_field.values = nil
end

it "sets the default value to nil without blowing up" do
dialog_field.trigger_automate_value_updates
expect(dialog_field.default_value).to eq(nil)
end
end
end
Expand Down

0 comments on commit a72ab1b

Please sign in to comment.