diff --git a/test/backends/static_test.rb b/test/backends/static_test.rb index 65cb29d..f3fd90a 100644 --- a/test/backends/static_test.rb +++ b/test/backends/static_test.rb @@ -1,6 +1,8 @@ require File.join( File.dirname(__FILE__), '..', 'test_helper' ) require 'globalize/backend/static' require 'globalize/translation' +require 'action_view' +include ActionView::Helpers::NumberHelper I18n.locale = :'en-US' # Need to set this, since I18n defaults to 'en' @@ -10,7 +12,7 @@ class StaticTest < ActiveSupport::TestCase translations = {:"en-US" => {:foo => "foo in en-US", :boz => 'boz', :buz => {:bum => 'bum'}}, :"en" => {:bar => "bar in en"}, :"de-DE" => {:baz => "baz in de-DE"}, - :"de" => {:boo => "boo in de"}} + :"de" => {:boo => "boo in de", :number => { :currency => { :format => { :unit => '€', :format => '%n %u'}}}}} translations.each do |locale, data| I18n.backend.store_translations locale, data end @@ -74,6 +76,21 @@ class StaticTest < ActiveSupport::TestCase test "returns an array of translations 2" do assert_equal [Globalize::Translation::Static], I18n.translate(:"buz").values.map(&:class) end + + test "returns currency properly formated" do + currency = number_to_currency(10) + assert_equal "$10", currency + end + + test "returns currency properly formated for locale" do + currency = number_to_currency(10, :locale => :'de') + assert_equal "10 €", currency + end + + test "returns currency properly formated from parameters" do + currency = number_to_currency(10, :format => "%n %u", :unit => '€') + assert_equal "10 €", currency + end end class TranslationStaticTest < ActiveSupport::TestCase