Skip to content

Commit

Permalink
Only load string values in Tolk::Translation#value to accommodate has…
Browse files Browse the repository at this point in the history
…hes.
  • Loading branch information
Craig Davey committed Apr 22, 2010
1 parent cbf7003 commit b3263c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/tolk/translation.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/unit/translation_test.rb
Expand Up @@ -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.