Skip to content
Browse files

Only load string values in Tolk::Translation#value to accommodate has…

…hes.
  • Loading branch information...
1 parent cbf7003 commit b3263c8b162139352909d01433d73cf289aa870b Craig Davey committed Apr 22, 2010
Showing with 10 additions and 1 deletion.
  1. +5 −1 app/models/tolk/translation.rb
  2. +5 −0 test/unit/translation_test.rb
View
6 app/models/tolk/translation.rb
@@ -31,7 +31,11 @@ def text=(value)
end
def value
- YAML.load text if text
+ if text.is_a?(String)
+ YAML.load text
+ else
+ text
+ end
end
private
View
5 test/unit/translation_test.rb
@@ -30,4 +30,9 @@ def setup
test "translation with numeric value" do
assert_equal 1, tolk_translations(:human_format_precision_en).value
end
+
+ test "translation with hash value" do
+ hash = {:foo => "bar"}
+ assert_equal hash, Tolk::Translation.new(:text => hash).value
+ end
end

0 comments on commit b3263c8

Please sign in to comment.
Something went wrong with that request. Please try again.