diff --git a/app/models/custom_actions/actions/base.rb b/app/models/custom_actions/actions/base.rb index c499282473d..a600586f581 100644 --- a/app/models/custom_actions/actions/base.rb +++ b/app/models/custom_actions/actions/base.rb @@ -46,7 +46,7 @@ class CustomActions::Actions::Base end def value_objects - values.map do |value| + values.filter_map do |value| allowed_values.find { |v| v[:value] == value } end end diff --git a/spec/models/custom_actions/shared_expectations.rb b/spec/models/custom_actions/shared_expectations.rb index 36797bbe06d..59b35e15859 100644 --- a/spec/models/custom_actions/shared_expectations.rb +++ b/spec/models/custom_actions/shared_expectations.rb @@ -140,6 +140,15 @@ RSpec.shared_examples_for "associated custom action" do end end + describe "#value_objects" do + it "does not include nil for values not present in allowed_values" do + instance.values = [""] + + expect(instance.value_objects) + .not_to include(nil) + end + end + it_behaves_like "associated custom action validations" end end