Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (36 sloc) 1.416 kb
require 'test_helper'
require 'fileutils'
class TranslationTest < ActiveSupport::TestCase
fixtures :tolk_translations
def setup
Tolk::Locale.primary_locale(true)
end
test "translation is inavlid when a duplicate exists" do
translation = Tolk::Translation.new :phrase => tolk_translations(:hello_world_da).phrase, :locale => tolk_translations(:hello_world_da).locale
translation.text = "Revised Hello World"
assert translation.invalid?
assert translation.errors[:phrase_id]
end
test "translation is not changed when text is assigned an equal value in numberic form" do
translation = tolk_translations(:human_format_precision_en)
assert_equal "1", translation.text
translation.text = "1"
assert_equal false, translation.changed?
translation.text = 1
assert_equal false, translation.changed?
end
test "translation with string value" do
assert_equal "Hello World", tolk_translations(:hello_world_en).value
end
test "translation with string value with variables" do
text = "{{attribute}} {{message}}"
assert_equal text, Tolk::Translation.new(:text => text).value
end
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
Jump to Line
Something went wrong with that request. Please try again.