Skip to content

Commit

Permalink
Breadcrumbs/Validator: Allow nil as an acceptable meta_data type
Browse files Browse the repository at this point in the history
  • Loading branch information
Cawllec committed Jan 4, 2019
1 parent b4274cd commit 55dcd0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/bugsnag/breadcrumbs/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def validate(breadcrumb)
##
# Tests whether the meta_data types are non-complex objects.
#
# Acceptable types are String, Numeric, TrueClass, and FalseClass.
# Acceptable types are String, Numeric, TrueClass, FalseClass, and nil.
#
# @param value [Object] the object to be type checked
def valid_meta_data_type?(value)
value.is_a?(String) || value.is_a?(Numeric) || value.is_a?(FalseClass) || value.is_a?(TrueClass)
value.nil? || value.is_a?(String) || value.is_a?(Numeric) || value.is_a?(FalseClass) || value.is_a?(TrueClass)
end
end
end
5 changes: 3 additions & 2 deletions spec/breadcrumbs/validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
end

describe "tests meta_data types" do
it "accepts Strings, Numerics, & Booleans" do
it "accepts Strings, Numerics, Booleans, & nil" do
config = instance_double(Bugsnag::Configuration)
allow(config).to receive(:enabled_automatic_breadcrumb_types).and_return(enabled_automatic_breadcrumb_types)
validator = Bugsnag::Breadcrumbs::Validator.new(config)
Expand All @@ -67,7 +67,8 @@
:integer => 12345,
:float => 12345.6789,
:false => false,
:true => true
:true => true,
:nil => nil
}

breadcrumb = instance_double(Bugsnag::Breadcrumbs::Breadcrumb, {
Expand Down

0 comments on commit 55dcd0e

Please sign in to comment.