Permalink
Browse files

Ensure #to_hash is called on objects supporting it when cleaning unse…

…rializable data.
  • Loading branch information...
1 parent 4bee32a commit 0e68e717b02e504ee5f2424998f56dd087c2de9a @tristandunn tristandunn committed Dec 23, 2009
Showing with 8 additions and 2 deletions.
  1. +1 −1 lib/hoptoad_notifier.rb
  2. +1 −1 lib/hoptoad_notifier/notice.rb
  3. +6 −0 test/notice_test.rb
@@ -11,7 +11,7 @@
# Plugin for applications to automatically post errors to the Hoptoad of their choice.
module HoptoadNotifier
- VERSION = "2.0.17"
+ VERSION = "2.0.18"
API_VERSION = "2.0"
LOG_PREFIX = "** [Hoptoad] "
@@ -221,7 +221,7 @@ def clean_unserializable_data_from(attribute)
# TODO: move this onto Hash
def clean_unserializable_data(data)
if data.respond_to?(:to_hash)
- data.inject({}) do |result, (key, value)|
+ data.to_hash.inject({}) do |result, (key, value)|
result.merge(key => clean_unserializable_data(value))
end
elsif data.respond_to?(:to_ary)
View
@@ -297,6 +297,12 @@ def stub_request(attrs = {})
assert_equal params, notice[:request][:params]
end
+ should "ensure #to_hash is called on objects that support it" do
+ assert_nothing_raised do
+ build_notice(:session => { :object => stub(:to_hash => {}) })
+ end
+ end
+
def assert_accepts_exception_attribute(attribute, args = {}, &block)
exception = build_exception
block ||= lambda { exception.send(attribute) }

0 comments on commit 0e68e71

Please sign in to comment.