aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-12-12 10:46:58 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-12-12 10:46:58 +0000
commitbe4a30ee02704b591f45fe12e1546739bf35f1cb (patch)
tree286dfa333a37b0ad6e02a86b1bd06d3e8063447c
parentac2fb2330a564ba52761ed2b06036c61fc9f07d6 (diff)
Fixed up alert truncating only to work on strings. Added test case.
-rw-r--r--lib/mauve/alert.rb2
-rw-r--r--test/tc_mauve_alert.rb19
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb
index 9d04250..a2033a5 100644
--- a/lib/mauve/alert.rb
+++ b/lib/mauve/alert.rb
@@ -272,7 +272,7 @@ module Mauve
attributes.each do |key, val|
prop = self.class.properties[key]
next unless prop.is_a?(DataMapper::Property::String)
-
+ next unless val.is_a?(String)
#
# Truncate
#
diff --git a/test/tc_mauve_alert.rb b/test/tc_mauve_alert.rb
index 61bd117..5c6f2bd 100644
--- a/test/tc_mauve_alert.rb
+++ b/test/tc_mauve_alert.rb
@@ -475,4 +475,23 @@ EOF
assert(!alert.suppressed?,"Alert marked as suppressed when the suppression period was never set")
end
+ def test_long_fields_get_truncated
+ Configuration.current = ConfigurationBuilder.parse(@test_config)
+ Server.instance.setup
+
+ alert = Alert.new(
+ :alert_id => "x"*257,
+ :source => "test",
+ :subject => "test"
+ )
+
+ assert(alert.save, "Alert with overly long field failed to save")
+ # This should trigger a warning.
+ logger_pop
+
+ alert.reload
+ assert(256, alert.alert_id.length)
+
+ end
+
end