From 41fb53cde32367fc744cfd11103b76c205b36d48 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Tue, 28 Aug 2018 12:08:52 -0400 Subject: [PATCH] Ensure options is always a hash https://github.com/ManageIQ/manageiq/pull/17802 added a line that called [] on options and if nil, it would raise NoMethodError where it should have returned nil --- app/models/custom_button.rb | 2 +- spec/lib/task_helpers/exports/custom_buttons_spec.rb | 4 ++-- spec/models/custom_button_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/custom_button.rb b/app/models/custom_button.rb index b0eb0e82523..b8255cbf48d 100644 --- a/app/models/custom_button.rb +++ b/app/models/custom_button.rb @@ -1,7 +1,7 @@ class CustomButton < ApplicationRecord has_one :resource_action, :as => :resource, :dependent => :destroy, :autosave => true - serialize :options + serialize :options, Hash serialize :visibility_expression serialize :enablement_expression serialize :visibility diff --git a/spec/lib/task_helpers/exports/custom_buttons_spec.rb b/spec/lib/task_helpers/exports/custom_buttons_spec.rb index 5fc8afb0b1f..dd3ced705bc 100644 --- a/spec/lib/task_helpers/exports/custom_buttons_spec.rb +++ b/spec/lib/task_helpers/exports/custom_buttons_spec.rb @@ -26,7 +26,7 @@ "description" => "Export Test", "applies_to_class" => "Vm", "visibility_expression" => nil, - "options" => nil, + "options" => {}, "userid" => nil, "wait_for_complete" => nil, "name" => "export_test_button", @@ -44,7 +44,7 @@ "description" => "Export Test", "applies_to_class" => "Service", "visibility_expression" => nil, - "options" => nil, + "options" => {}, "userid" => nil, "wait_for_complete" => nil, "name" => "export_test_button2", diff --git a/spec/models/custom_button_spec.rb b/spec/models/custom_button_spec.rb index ab415d812a3..c2a2f35cfb8 100644 --- a/spec/models/custom_button_spec.rb +++ b/spec/models/custom_button_spec.rb @@ -251,7 +251,7 @@ "disabled_text" => nil, "enablement_expression" => nil, "applies_to_class" => nil, - "options" => nil, + "options" => {}, "userid" => nil, "wait_for_complete" => nil, "created_on" => nil,