summaryrefslogtreecommitdiff
path: root/vendor/plugins/globalize2/test
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2010-01-14 22:21:43 +0100
committerhukl <contact@smyck.org>2010-01-14 22:21:43 +0100
commit57d1382013c85a7b11ac8ce5e683f6006b12b328 (patch)
tree19646c4fa5952fa1cf0a2c874952affa346373f1 /vendor/plugins/globalize2/test
parent1b86bf5f2e35d1820bfa32d979bcc2d9ff9a9a8e (diff)
Updated globalize2 to latest version. Modified existing code accoringly
Diffstat (limited to 'vendor/plugins/globalize2/test')
-rw-r--r--vendor/plugins/globalize2/test/active_record/fallbacks_test.rb102
-rw-r--r--vendor/plugins/globalize2/test/active_record/migration_test.rb (renamed from vendor/plugins/globalize2/test/model/active_record/migration_test.rb)71
-rw-r--r--vendor/plugins/globalize2/test/active_record/sti_translated_test.rb (renamed from vendor/plugins/globalize2/test/model/active_record/sti_translated_test.rb)34
-rw-r--r--vendor/plugins/globalize2/test/active_record/translates_test.rb87
-rw-r--r--vendor/plugins/globalize2/test/active_record/translation_class_test.rb30
-rw-r--r--vendor/plugins/globalize2/test/active_record/validation_tests.rb75
-rw-r--r--vendor/plugins/globalize2/test/active_record_test.rb442
-rw-r--r--vendor/plugins/globalize2/test/backends/chained_test.rb175
-rw-r--r--vendor/plugins/globalize2/test/backends/pluralizing_test.rb63
-rw-r--r--vendor/plugins/globalize2/test/backends/static_test.rb143
-rw-r--r--vendor/plugins/globalize2/test/data/locale/all.yml2
-rw-r--r--vendor/plugins/globalize2/test/data/locale/de-DE.yml2
-rw-r--r--vendor/plugins/globalize2/test/data/locale/en-US.yml2
-rw-r--r--vendor/plugins/globalize2/test/data/locale/en-US/module.yml2
-rw-r--r--vendor/plugins/globalize2/test/data/locale/fi-FI/module.yml2
-rw-r--r--vendor/plugins/globalize2/test/data/locale/root.yml0
-rw-r--r--vendor/plugins/globalize2/test/data/models.rb26
-rw-r--r--vendor/plugins/globalize2/test/i18n/missing_translations_test.rb12
-rw-r--r--vendor/plugins/globalize2/test/load_path_test.rb49
-rw-r--r--vendor/plugins/globalize2/test/locale/fallbacks_test.rb154
-rw-r--r--vendor/plugins/globalize2/test/locale/language_tag_test.rb130
-rw-r--r--vendor/plugins/globalize2/test/model/active_record/translated_test.rb478
-rw-r--r--vendor/plugins/globalize2/test/test_helper.rb70
-rw-r--r--vendor/plugins/globalize2/test/translation_test.rb54
24 files changed, 857 insertions, 1348 deletions
diff --git a/vendor/plugins/globalize2/test/active_record/fallbacks_test.rb b/vendor/plugins/globalize2/test/active_record/fallbacks_test.rb
new file mode 100644
index 0000000..449ec8b
--- /dev/null
+++ b/vendor/plugins/globalize2/test/active_record/fallbacks_test.rb
@@ -0,0 +1,102 @@
1require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2require File.expand_path(File.dirname(__FILE__) + '/../data/models')
3
4if I18n.respond_to?(:fallbacks)
5 class TranslatedTest < ActiveSupport::TestCase
6 def setup
7 I18n.locale = :'en-US'
8 I18n.fallbacks.clear
9 reset_db!
10 ActiveRecord::Base.locale = nil
11 end
12
13 def teardown
14 I18n.fallbacks.clear
15 end
16
17 test "keeping one field in new locale when other field is changed" do
18 I18n.fallbacks.map 'de-DE' => [ 'en-US' ]
19 post = Post.create :subject => 'foo'
20 I18n.locale = 'de-DE'
21 post.content = 'bar'
22 assert_equal 'foo', post.subject
23 end
24
25 test "modifying non-required field in a new locale" do
26 I18n.fallbacks.map 'de-DE' => [ 'en-US' ]
27 post = Post.create :subject => 'foo'
28 I18n.locale = 'de-DE'
29 post.content = 'bar'
30 assert post.save
31 end
32
33 test "resolves a simple fallback" do
34 I18n.locale = 'de-DE'
35 post = Post.create :subject => 'foo'
36 I18n.locale = 'de'
37 post.subject = 'baz'
38 post.content = 'bar'
39 post.save
40 I18n.locale = 'de-DE'
41 assert_equal 'foo', post.subject
42 assert_equal 'bar', post.content
43 end
44
45 test "resolves a simple fallback without reloading" do
46 I18n.locale = 'de-DE'
47 post = Post.new :subject => 'foo'
48 I18n.locale = 'de'
49 post.subject = 'baz'
50 post.content = 'bar'
51 I18n.locale = 'de-DE'
52 assert_equal 'foo', post.subject
53 assert_equal 'bar', post.content
54 end
55
56 test "resolves a complex fallback without reloading" do
57 I18n.fallbacks.map 'de' => %w(en he)
58 I18n.locale = 'de'
59 post = Post.new
60 I18n.locale = 'en'
61 post.subject = 'foo'
62 I18n.locale = 'he'
63 post.subject = 'baz'
64 post.content = 'bar'
65 I18n.locale = 'de'
66 assert_equal 'foo', post.subject
67 assert_equal 'bar', post.content
68 end
69
70 test 'fallbacks with lots of locale switching' do
71 I18n.fallbacks.map :'de-DE' => [ :'en-US' ]
72 post = Post.create :subject => 'foo'
73
74 I18n.locale = :'de-DE'
75 assert_equal 'foo', post.subject
76
77 I18n.locale = :'en-US'
78 post.update_attribute :subject, 'bar'
79
80 I18n.locale = :'de-DE'
81 assert_equal 'bar', post.subject
82 end
83
84 test 'fallbacks with lots of locale switching' do
85 I18n.fallbacks.map :'de-DE' => [ :'en-US' ]
86 child = Child.create :content => 'foo'
87
88 I18n.locale = :'de-DE'
89 assert_equal 'foo', child.content
90
91 I18n.locale = :'en-US'
92 child.update_attribute :content, 'bar'
93
94 I18n.locale = :'de-DE'
95 assert_equal 'bar', child.content
96 end
97 end
98end
99
100# TODO should validate_presence_of take fallbacks into account? maybe we need
101# an extra validation call, or more options for validate_presence_of.
102
diff --git a/vendor/plugins/globalize2/test/model/active_record/migration_test.rb b/vendor/plugins/globalize2/test/active_record/migration_test.rb
index eb6533d..359d811 100644
--- a/vendor/plugins/globalize2/test/model/active_record/migration_test.rb
+++ b/vendor/plugins/globalize2/test/active_record/migration_test.rb
@@ -1,36 +1,32 @@
1require File.join( File.dirname(__FILE__), '..', '..', 'test_helper' ) 1require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2require 'active_record' 2require File.expand_path(File.dirname(__FILE__) + '/../data/models')
3require 'globalize/model/active_record'
4
5# Hook up model translation
6ActiveRecord::Base.send(:include, Globalize::Model::ActiveRecord::Translated)
7
8# Load Post model
9require File.join( File.dirname(__FILE__), '..', '..', 'data', 'models' )
10 3
11class MigrationTest < ActiveSupport::TestCase 4class MigrationTest < ActiveSupport::TestCase
12 def setup 5 def setup
13 reset_db! File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data', 'no_globalize_schema.rb')) 6 reset_db!
7 Post.drop_translation_table!
14 end 8 end
15 9
16 test 'globalize table added' do 10 test 'globalize table added' do
17 assert !Post.connection.table_exists?( :post_translations ) 11 assert !Post.connection.table_exists?(:post_translations)
18 assert !Post.connection.index_exists?( :post_translations, :post_id ) 12 assert !Post.connection.index_exists?(:post_translations, :post_id)
19 Post.create_translation_table! :subject => :string, :content => :text 13
20 assert Post.connection.table_exists?( :post_translations ) 14 Post.create_translation_table!(:subject => :string, :content => :text)
21 assert Post.connection.index_exists?( :post_translations, :post_id ) 15 assert Post.connection.table_exists?(:post_translations)
22 columns = Post.connection.columns( :post_translations ) 16 assert Post.connection.index_exists?(:post_translations, :post_id)
23 assert locale = columns.detect {|c| c.name == 'locale' } 17
18 columns = Post.connection.columns(:post_translations)
19 assert locale = columns.detect { |c| c.name == 'locale' }
24 assert_equal :string, locale.type 20 assert_equal :string, locale.type
25 assert subject = columns.detect {|c| c.name == 'subject' } 21 assert subject = columns.detect { |c| c.name == 'subject' }
26 assert_equal :string, subject.type 22 assert_equal :string, subject.type
27 assert content = columns.detect {|c| c.name == 'content' } 23 assert content = columns.detect { |c| c.name == 'content' }
28 assert_equal :text, content.type 24 assert_equal :text, content.type
29 assert post_id = columns.detect {|c| c.name == 'post_id' } 25 assert post_id = columns.detect { |c| c.name == 'post_id' }
30 assert_equal :integer, post_id.type 26 assert_equal :integer, post_id.type
31 assert created_at = columns.detect {|c| c.name == 'created_at' } 27 assert created_at = columns.detect { |c| c.name == 'created_at' }
32 assert_equal :datetime, created_at.type 28 assert_equal :datetime, created_at.type
33 assert updated_at = columns.detect {|c| c.name == 'updated_at' } 29 assert updated_at = columns.detect { |c| c.name == 'updated_at' }
34 assert_equal :datetime, updated_at.type 30 assert_equal :datetime, updated_at.type
35 end 31 end
36 32
@@ -46,13 +42,13 @@ class MigrationTest < ActiveSupport::TestCase
46 end 42 end
47 43
48 test 'exception on missing field inputs' do 44 test 'exception on missing field inputs' do
49 assert_raise Globalize::Model::MigrationMissingTranslatedField do 45 assert_raise Globalize::MigrationMissingTranslatedField do
50 Post.create_translation_table! :content => :text 46 Post.create_translation_table! :content => :text
51 end 47 end
52 end 48 end
53 49
54 test 'exception on bad input type' do 50 test 'exception on bad input type' do
55 assert_raise Globalize::Model::BadMigrationFieldType do 51 assert_raise Globalize::BadMigrationFieldType do
56 Post.create_translation_table! :subject => :string, :content => :integer 52 Post.create_translation_table! :subject => :string, :content => :integer
57 end 53 end
58 end 54 end
@@ -74,31 +70,29 @@ class MigrationTest < ActiveSupport::TestCase
74 Blog.drop_translation_table! 70 Blog.drop_translation_table!
75 end 71 end
76 end 72 end
77 73
78 test "translation_index_name returns a readable index name when it's not longer than 50 characters" do 74 test "translation_index_name returns a readable index name when it's not longer than 50 characters" do
79 assert_equal 'index_post_translations_on_post_id', Post.send(:translation_index_name) 75 assert_equal 'index_post_translations_on_post_id', Post.send(:translation_index_name)
80 end 76 end
81 77
82 test "translation_index_name returns a hashed index name when it's longer than 50 characters" do 78 test "translation_index_name returns a hashed index name when it's longer than 50 characters" do
83 class UltraLongModelNameWithoutProper < ActiveRecord::Base 79 class UltraLongModelNameWithoutProper < ActiveRecord::Base
84 translates :foo 80 translates :foo
85 end 81 end
86 expected = 'index_44eba0f057e01a590ffccd0b8a3b5c78979539cd' 82 name = UltraLongModelNameWithoutProper.send(:translation_index_name)
87 actual = UltraLongModelNameWithoutProper.send(:translation_index_name) 83 assert_match /^index_[a-z0-9]{40}$/, name
88
89 assert_equal expected, actual
90 end 84 end
91 85
92 test 'globalize table added when table has long name' do 86 test 'globalize table added when table has long name' do
93 UltraLongModelNameWithoutProper.create_translation_table!( 87 UltraLongModelNameWithoutProper.create_translation_table!(
94 :subject => :string, :content => :text 88 :subject => :string, :content => :text
95 ) 89 )
96 90
97 assert UltraLongModelNameWithoutProper.connection.table_exists?( 91 assert UltraLongModelNameWithoutProper.connection.table_exists?(
98 :ultra_long_model_name_without_proper_translations 92 :ultra_long_model_name_without_proper_translations
99 ) 93 )
100 assert UltraLongModelNameWithoutProper.connection.index_exists?( 94 assert UltraLongModelNameWithoutProper.connection.index_exists?(
101 :ultra_long_model_name_without_proper_translations, 95 :ultra_long_model_name_without_proper_translations,
102 :name => UltraLongModelNameWithoutProper.send( 96 :name => UltraLongModelNameWithoutProper.send(
103 :translation_index_name 97 :translation_index_name
104 ) 98 )
@@ -106,20 +100,19 @@ class MigrationTest < ActiveSupport::TestCase
106 end 100 end
107 101
108 test 'globalize table dropped when table has long name' do 102 test 'globalize table dropped when table has long name' do
103 UltraLongModelNameWithoutProper.drop_translation_table!
109 UltraLongModelNameWithoutProper.create_translation_table!( 104 UltraLongModelNameWithoutProper.create_translation_table!(
110 :subject => :string, :content => :text 105 :subject => :string, :content => :text
111 ) 106 )
112
113 UltraLongModelNameWithoutProper.drop_translation_table! 107 UltraLongModelNameWithoutProper.drop_translation_table!
114 108
115 assert !UltraLongModelNameWithoutProper.connection.table_exists?( 109 assert !UltraLongModelNameWithoutProper.connection.table_exists?(
116 :ultra_long_model_name_without_proper_translations 110 :ultra_long_model_name_without_proper_translations
117 ) 111 )
118
119 assert !UltraLongModelNameWithoutProper.connection.index_exists?( 112 assert !UltraLongModelNameWithoutProper.connection.index_exists?(
120 :ultra_long_model_name_without_proper_translations, 113 :ultra_long_model_name_without_proper_translations,
121 :ultra_long_model_name_without_proper_id 114 :ultra_long_model_name_without_proper_id
122 ) 115 )
123 end 116 end
124 117
125end \ No newline at end of file 118end
diff --git a/vendor/plugins/globalize2/test/model/active_record/sti_translated_test.rb b/vendor/plugins/globalize2/test/active_record/sti_translated_test.rb
index 6980ba0..f529b8d 100644
--- a/vendor/plugins/globalize2/test/model/active_record/sti_translated_test.rb
+++ b/vendor/plugins/globalize2/test/active_record/sti_translated_test.rb
@@ -1,22 +1,10 @@
1require File.join( File.dirname(__FILE__), '..', '..', 'test_helper' ) 1require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2require 'active_record' 2require File.expand_path(File.dirname(__FILE__) + '/../data/models')
3require 'globalize/model/active_record'
4
5# Hook up model translation
6ActiveRecord::Base.send(:include, Globalize::Model::ActiveRecord::Translated)
7
8# Load Post model
9require File.join( File.dirname(__FILE__), '..', '..', 'data', 'models' )
10 3
11class StiTranslatedTest < ActiveSupport::TestCase 4class StiTranslatedTest < ActiveSupport::TestCase
12 def setup 5 def setup
13 I18n.locale = :'en-US' 6 I18n.locale = :'en-US'
14 I18n.fallbacks.clear 7 reset_db!
15 reset_db! File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data', 'schema.rb'))
16 end
17
18 def teardown
19 I18n.fallbacks.clear
20 end 8 end
21 9
22 test "works with simple dynamic finders" do 10 test "works with simple dynamic finders" do
@@ -43,20 +31,6 @@ class StiTranslatedTest < ActiveSupport::TestCase
43 assert_equal [ 'content' ], child.changed 31 assert_equal [ 'content' ], child.changed
44 end 32 end
45 33
46 test 'fallbacks with lots of locale switching' do
47 I18n.fallbacks.map :'de-DE' => [ :'en-US' ]
48 child = Child.create :content => 'foo'
49
50 I18n.locale = :'de-DE'
51 assert_equal 'foo', child.content
52
53 I18n.locale = :'en-US'
54 child.update_attribute :content, 'bar'
55
56 I18n.locale = :'de-DE'
57 assert_equal 'bar', child.content
58 end
59
60 test "saves all locales, even after locale switching" do 34 test "saves all locales, even after locale switching" do
61 child = Child.new :content => 'foo' 35 child = Child.new :content => 'foo'
62 I18n.locale = 'de-DE' 36 I18n.locale = 'de-DE'
@@ -72,4 +46,4 @@ class StiTranslatedTest < ActiveSupport::TestCase
72 I18n.locale = 'he-IL' 46 I18n.locale = 'he-IL'
73 assert_equal 'baz', child.content 47 assert_equal 'baz', child.content
74 end 48 end
75end \ No newline at end of file 49end
diff --git a/vendor/plugins/globalize2/test/active_record/translates_test.rb b/vendor/plugins/globalize2/test/active_record/translates_test.rb
new file mode 100644
index 0000000..4207bc4
--- /dev/null
+++ b/vendor/plugins/globalize2/test/active_record/translates_test.rb
@@ -0,0 +1,87 @@
1require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2require File.expand_path(File.dirname(__FILE__) + '/../data/models')
3
4class TranslatesTest < ActiveSupport::TestCase
5 def setup
6 I18n.locale = nil
7 ActiveRecord::Base.locale = nil
8 reset_db!
9 end
10
11 test 'defines a :locale accessors on ActiveRecord::Base' do
12 ActiveRecord::Base.locale = :de
13 assert_equal :de, ActiveRecord::Base.locale
14 end
15
16 test 'the :locale reader on ActiveRecord::Base does not default to I18n.locale (anymore)' do
17 I18n.locale = :en
18 assert_nil ActiveRecord::Base.locale
19 end
20
21 test 'ActiveRecord::Base.with_locale temporarily sets the given locale and yields the block' do
22 I18n.locale = :en
23 post = Post.with_locale(:de) do
24 Post.create!(:subject => 'Titel', :content => 'Inhalt')
25 end
26 assert_nil Post.locale
27 assert_equal :en, I18n.locale
28
29 I18n.locale = :de
30 assert_equal 'Titel', post.subject
31 end
32
33 test 'translation_class returns the Translation class' do
34 assert_equal Post::Translation, Post.translation_class
35 end
36
37 test 'defines a has_many association on the model class' do
38 assert_has_many Post, :translations
39 end
40
41 test 'defines a scope for retrieving locales that have complete translations' do
42 post = Post.create!(:subject => 'subject', :content => 'content')
43 assert_equal [:en], post.translated_locales
44 end
45
46 test 'sets the given attributes to translated_attribute_names' do
47 assert_equal [:subject, :content], Post.translated_attribute_names
48 end
49
50 test 'defines accessors for the translated attributes' do
51 post = Post.new
52 assert post.respond_to?(:subject)
53 assert post.respond_to?(:subject=)
54 end
55
56 test 'attribute reader without arguments will use the current locale on ActiveRecord::Base or I18n' do
57 post = Post.with_locale(:de) do
58 Post.create!(:subject => 'Titel', :content => 'Inhalt')
59 end
60 I18n.locale = :de
61 assert_equal 'Titel', post.subject
62
63 I18n.locale = :en
64 ActiveRecord::Base.locale = :de
65 assert_equal 'Titel', post.subject
66 end
67
68 test 'attribute reader when passed a locale will use the given locale' do
69 post = Post.with_locale(:de) do
70 Post.create!(:subject => 'Titel', :content => 'Inhalt')
71 end
72 assert_equal 'Titel', post.subject(:de)
73 end
74
75 test 'attribute reader will use the current locale on ActiveRecord::Base or I18n' do
76 post = Post.with_locale(:en) do
77 Post.create!(:subject => 'title', :content => 'content')
78 end
79 I18n.locale = :de
80 post.subject = 'Titel'
81 assert_equal 'Titel', post.subject
82
83 ActiveRecord::Base.locale = :en
84 post.subject = 'title'
85 assert_equal 'title', post.subject
86 end
87end
diff --git a/vendor/plugins/globalize2/test/active_record/translation_class_test.rb b/vendor/plugins/globalize2/test/active_record/translation_class_test.rb
new file mode 100644
index 0000000..1628416
--- /dev/null
+++ b/vendor/plugins/globalize2/test/active_record/translation_class_test.rb
@@ -0,0 +1,30 @@
1require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2require File.expand_path(File.dirname(__FILE__) + '/../data/models')
3
4class TranlationClassTest < ActiveSupport::TestCase
5 def setup
6 reset_db!
7 end
8
9 test 'defines a Translation class nested in the model class' do
10 assert Post.const_defined?(:Translation)
11 end
12
13 test 'defines a belongs_to association' do
14 assert_belongs_to Post::Translation, :post
15 end
16
17 test 'defines a reader for :locale that always returns a symbol' do
18 post = Post::Translation.new
19 post.write_attribute('locale', 'de')
20 assert_equal :de, post.locale
21 end
22
23 test 'defines a write for :locale that always writes a string' do
24 post = Post::Translation.new
25 post.locale = :de
26 assert_equal 'de', post.read_attribute('locale')
27 end
28end
29
30
diff --git a/vendor/plugins/globalize2/test/active_record/validation_tests.rb b/vendor/plugins/globalize2/test/active_record/validation_tests.rb
new file mode 100644
index 0000000..0148fa3
--- /dev/null
+++ b/vendor/plugins/globalize2/test/active_record/validation_tests.rb
@@ -0,0 +1,75 @@
1require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2require File.expand_path(File.dirname(__FILE__) + '/../data/models')
3
4class ValidationTest < ActiveSupport::TestCase
5 def setup
6 reset_db!
7 end
8
9 def teardown
10 Validatee.instance_variable_set(:@validate_callbacks, CallbackChain.new)
11 end
12
13 test "validates_presence_of" do
14 Validatee.class_eval { validates_presence_of :string }
15 assert !Validatee.new.valid?
16 assert Validatee.new(:string => 'foo').valid?
17 end
18
19 test "validates_confirmation_of" do
20 Validatee.class_eval { validates_confirmation_of :string }
21 assert !Validatee.new(:string => 'foo', :string_confirmation => 'bar').valid?
22 assert Validatee.new(:string => 'foo', :string_confirmation => 'foo').valid?
23 end
24
25 test "validates_acceptance_of" do
26 Validatee.class_eval { validates_acceptance_of :string, :accept => '1' }
27 assert !Validatee.new(:string => '0').valid?
28 assert Validatee.new(:string => '1').valid?
29 end
30
31 test "validates_length_of (:is)" do
32 Validatee.class_eval { validates_length_of :string, :is => 1 }
33 assert !Validatee.new(:string => 'aa').valid?
34 assert Validatee.new(:string => 'a').valid?
35 end
36
37 test "validates_format_of" do
38 Validatee.class_eval { validates_format_of :string, :with => /^\d+$/ }
39 assert !Validatee.new(:string => 'a').valid?
40 assert Validatee.new(:string => '1').valid?
41 end
42
43 test "validates_inclusion_of" do
44 Validatee.class_eval { validates_inclusion_of :string, :in => %(a) }
45 assert !Validatee.new(:string => 'b').valid?
46 assert Validatee.new(:string => 'a').valid?
47 end
48
49 test "validates_exclusion_of" do
50 Validatee.class_eval { validates_exclusion_of :string, :in => %(b) }
51 assert !Validatee.new(:string => 'b').valid?
52 assert Validatee.new(:string => 'a').valid?
53 end
54
55 test "validates_numericality_of" do
56 Validatee.class_eval { validates_numericality_of :string }
57 assert !Validatee.new(:string => 'a').valid?
58 assert Validatee.new(:string => '1').valid?
59 end
60
61 # This doesn't pass and Rails' validates_uniqueness_of implementation doesn't
62 # seem to be extensible easily. One can work around that by either defining
63 # a custom validation on the Validatee model itself, or by using validates_uniqueness_of
64 # on Validatee::Translation.
65 #
66 # test "validates_uniqueness_of" do
67 # Validatee.class_eval { validates_uniqueness_of :string }
68 # Validatee.create!(:string => 'a')
69 # assert !Validatee.new(:string => 'a').valid?
70 # assert Validatee.new(:string => 'b').valid?
71 # end
72
73 # test "validates_associated" do
74 # end
75end \ No newline at end of file
diff --git a/vendor/plugins/globalize2/test/active_record_test.rb b/vendor/plugins/globalize2/test/active_record_test.rb
new file mode 100644
index 0000000..e6b54f0
--- /dev/null
+++ b/vendor/plugins/globalize2/test/active_record_test.rb
@@ -0,0 +1,442 @@
1require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2require File.expand_path(File.dirname(__FILE__) + '/data/models')
3
4# Higher level tests.
5
6class ActiveRecordTest < ActiveSupport::TestCase
7 def setup
8 I18n.locale = :en
9 reset_db!
10 ActiveRecord::Base.locale = nil
11 end
12
13 def assert_translated(locale, record, names, expected)
14 I18n.locale = locale
15 assert_equal Array(expected), Array(names).map { |name| record.send(name) }
16 end
17
18 test "a translated record has translations" do
19 assert_equal [], Post.new.translations
20 end
21
22 test "saves a translated version of the record for each locale" do
23 post = Post.create(:subject => 'title')
24 I18n.locale = :de
25 post.update_attributes(:subject => 'Titel')
26
27 assert_equal 2, post.translations.size
28 assert_equal %w(de en), post.translations.map(&:locale).map(&:to_s).sort
29 assert_equal %w(Titel title), post.translations.map(&:subject).sort
30 end
31
32 test "a translated record has German translations" do
33 I18n.locale = :de
34 post = Post.create(:subject => 'foo')
35 assert_equal 1, post.translations.size
36 assert_equal [:de], post.translations.map { |t| t.locale }
37 end
38
39 test "modifiying translated fields while switching locales" do
40 post = Post.create(:subject => 'title', :content => 'content')
41 assert_equal %w(title content), [post.subject, post.content]
42
43 I18n.locale = :de
44 post.subject, post.content = 'Titel', 'Inhalt'
45
46 assert_translated(:de, post, [:subject, :content], %w(Titel Inhalt))
47 assert_translated(:en, post, [:subject, :content], %w(title content))
48 assert_translated(:de, post, [:subject, :content], %w(Titel Inhalt))
49
50 post.save
51 post.reload
52
53 assert_translated(:en, post, [:subject, :content], %w(title content))
54 assert_translated(:de, post, [:subject, :content], %w(Titel Inhalt))
55 end
56
57 test "attribute writers do return their argument" do
58 value = Post.new.subject = 'foo'
59 assert_equal 'foo', value
60 end
61
62 test "update_attribute succeeds with valid values" do
63 post = Post.create(:subject => 'foo', :content => 'bar')
64 post.update_attribute(:subject, 'baz')
65 assert_equal 'baz', Post.first.subject
66 end
67
68 test "update_attributes fails with invalid values" do
69 post = Post.create(:subject => 'foo', :content => 'bar')
70 assert !post.update_attributes(:subject => '')
71 assert_nil post.reload.attributes['subject']
72 assert_equal 'foo', post.subject
73 end
74
75 test "passing the locale to create uses the given locale" do
76 post = Post.create(:subject => 'Titel', :content => 'Inhalt', :locale => :de)
77 assert_equal :en, I18n.locale
78 assert_nil ActiveRecord::Base.locale
79
80 I18n.locale = :de
81 assert_equal 'Titel', post.subject
82 end
83
84 test "passing the locale to attributes= uses the given locale" do
85 post = Post.create(:subject => 'title', :content => 'content')
86 post.update_attributes(:subject => 'Titel', :content => 'Inhalt', :locale => :de)
87 post.reload
88
89 assert_equal :en, I18n.locale
90 assert_nil ActiveRecord::Base.locale
91
92 assert_equal 'title', post.subject
93 I18n.locale = :de
94 assert_equal 'Titel', post.subject
95 end
96
97 test 'reload works' do
98 post = Post.create(:subject => 'foo', :content => 'bar')
99 post.subject = 'baz'
100 post.reload
101 assert_equal 'foo', post.subject
102 end
103
104 test "returns nil if no translations are found (unsaved record)" do
105 post = Post.new(:subject => 'foo')
106 assert_equal 'foo', post.subject
107 assert_nil post.content
108 end
109
110 test "returns nil if no translations are found (saved record)" do
111 post = Post.create(:subject => 'foo')
112 post.reload
113 assert_equal 'foo', post.subject
114 assert_nil post.content
115 end
116
117 test "finds a German post" do
118 post = Post.create(:subject => 'foo (en)', :content => 'bar')
119 I18n.locale = :de
120 post = Post.first
121 post.subject = 'baz (de)'
122 post.save
123 assert_equal 'baz (de)', Post.first.subject
124 I18n.locale = :en
125 assert_equal 'foo (en)', Post.first.subject
126 end
127
128 test "saves an English post and loads correctly" do
129 post = Post.create(:subject => 'foo', :content => 'bar')
130 assert post.save
131 post = Post.first
132 assert_equal 'foo', post.subject
133 assert_equal 'bar', post.content
134 end
135
136 test "returns the value for the correct locale, after locale switching" do
137 post = Post.create(:subject => 'foo')
138 I18n.locale = :de
139 post.subject = 'bar'
140 post.save
141 I18n.locale = :en
142 post = Post.first
143 assert_equal 'foo', post.subject
144 I18n.locale = :de
145 assert_equal 'bar', post.subject
146 end
147
148 test "returns the value for the correct locale, after locale switching, without saving" do
149 post = Post.create :subject => 'foo'
150 I18n.locale = :de
151 post.subject = 'bar'
152 I18n.locale = :en
153 assert_equal 'foo', post.subject
154 I18n.locale = :de
155 assert_equal 'bar', post.subject
156 end
157
158 test "saves all locales, even after locale switching" do
159 post = Post.new :subject => 'foo'
160 I18n.locale = :de
161 post.subject = 'bar'
162 I18n.locale = :he
163 post.subject = 'baz'
164 post.save
165 I18n.locale = :en
166 post = Post.first
167 assert_equal 'foo', post.subject
168 I18n.locale = :de
169 assert_equal 'bar', post.subject
170 I18n.locale = :he
171 assert_equal 'baz', post.subject
172 end
173
174 test "works with associations" do
175 blog = Blog.create
176 post1 = blog.posts.create(:subject => 'foo')
177
178 I18n.locale = :de
179 post2 = blog.posts.create(:subject => 'bar')
180 assert_equal 2, blog.posts.size
181
182 I18n.locale = :en
183 assert_equal 'foo', blog.posts.first.subject
184 assert_nil blog.posts.last.subject
185
186 I18n.locale = :de
187 assert_equal 'bar', blog.posts.last.subject
188 end
189
190 test "works with simple dynamic finders" do
191 foo = Post.create(:subject => 'foo')
192 Post.create(:subject => 'bar')
193 post = Post.find_by_subject('foo')
194 assert_equal foo, post
195 end
196
197 test 'change attribute on globalized model' do
198 post = Post.create(:subject => 'foo', :content => 'bar')
199 assert_equal [], post.changed
200 post.subject = 'baz'
201 assert_equal ['subject'], post.changed
202 post.content = 'quux'
203 assert_member 'subject', post.changed
204 assert_member 'content', post.changed
205 end
206
207 test 'change attribute on globalized model after locale switching' do
208 post = Post.create(:subject => 'foo', :content => 'bar')
209 assert_equal [], post.changed
210 post.subject = 'baz'
211 I18n.locale = :de
212 assert_equal ['subject'], post.changed
213 end
214
215 test 'complex writing and stashing' do
216 post = Post.create(:subject => 'foo', :content => 'bar')
217 post.subject = nil
218 assert_nil post.subject
219 assert !post.valid?
220 post.subject = 'stashed_foo'
221 assert_equal 'stashed_foo', post.subject
222 end
223
224 test 'translated class locale setting' do
225 assert ActiveRecord::Base.respond_to?(:locale)
226 assert_equal :en, I18n.locale
227 assert_nil ActiveRecord::Base.locale
228
229 I18n.locale = :de
230 assert_equal :de, I18n.locale
231 assert_nil ActiveRecord::Base.locale
232
233 ActiveRecord::Base.locale = :es
234 assert_equal :de, I18n.locale
235 assert_equal :es, ActiveRecord::Base.locale
236
237 I18n.locale = :fr
238 assert_equal :fr, I18n.locale
239 assert_equal :es, ActiveRecord::Base.locale
240 end
241
242 test "untranslated class responds to locale" do
243 assert Blog.respond_to?(:locale)
244 end
245
246 test "to ensure locales in different classes are the same" do
247 ActiveRecord::Base.locale = :de
248 assert_equal :de, ActiveRecord::Base.locale
249 assert_equal :de, Parent.locale
250
251 Parent.locale = :es
252 assert_equal :es, ActiveRecord::Base.locale
253 assert_equal :es, Parent.locale
254 end
255
256 test "attribute saving goes by content locale and not global locale" do
257 ActiveRecord::Base.locale = :de
258 assert_equal :en, I18n.locale
259 Post.create :subject => 'foo'
260 assert_equal :de, Post.first.translations.first.locale
261 end
262
263 test "attribute loading goes by content locale and not global locale" do
264 post = Post.create(:subject => 'foo')
265 assert_nil ActiveRecord::Base.locale
266
267 ActiveRecord::Base.locale = :de
268 assert_equal :en, I18n.locale
269 post.update_attribute(:subject, 'foo [de]')
270 assert_equal 'foo [de]', Post.first.subject
271
272 ActiveRecord::Base.locale = :en
273 assert_equal 'foo', Post.first.subject
274 end
275
276 test "access content locale before setting" do
277 Globalize::ActiveRecord::ActMacro.class_eval "remove_class_variable(:@@locale)"
278 assert_nothing_raised { ActiveRecord::Base.locale }
279 end
280
281 test "available_locales" do
282 Post.locale = :de
283 post = Post.create(:subject => 'foo')
284 Post.locale = :es
285 post.update_attribute(:subject, 'bar')
286 Post.locale = :fr
287 post.update_attribute(:subject, 'baz')
288 assert_equal [:de, :es, :fr], post.available_locales
289 assert_equal [:de, :es, :fr], Post.first.available_locales
290 end
291
292 test "saving record correctly after post-save reload" do
293 reloader = Reloader.create(:content => 'foo')
294 assert_equal 'foo', reloader.content
295 end
296
297 test "including translations" do
298 I18n.locale = :de
299 Post.create(:subject => "Foo1", :content => "Bar1")
300 Post.create(:subject => "Foo2", :content => "Bar2")
301
302 class << Post
303 def translations_included
304 self.all(:include => :translations)
305 end
306 end
307
308 default = Post.all.map { |x| [x.subject, x.content] }
309 with_include = Post.translations_included.map { |x| [x.subject, x.content] }
310 assert_equal default, with_include
311 end
312
313 test "setting multiple translations at once with options hash" do
314 Post.locale = :de
315 post = Post.create(:subject => "foo1", :content => "foo1")
316 Post.locale = :en
317 post.update_attributes(:subject => "bar1", :content => "bar1")
318
319 options = { :de => {:subject => "foo2", :content => "foo2"},
320 :en => {:subject => "bar2", :content => "bar2"} }
321 post.set_translations options
322 post.reload
323
324 assert ["bar2", "bar2"], [post.subject, post.content]
325 Post.locale = :de
326 assert ["foo2", "foo2"], [post.subject, post.content]
327 end
328
329 test "setting only one translation with set_translations" do
330 Post.locale = :de
331 post = Post.create(:subject => "foo1", :content => "foo1")
332 Post.locale = :en
333 post.update_attributes(:subject => "bar1", :content => "bar1")
334
335 options = { :en => { :subject => "bar2", :content => "bar2" } }
336 post.set_translations options
337 post.reload
338
339 assert ["bar2", "bar2"], [post.subject, post.content]
340 Post.locale = :de
341 assert ["foo1", "foo1"], [post.subject, post.content]
342 end
343
344 test "setting only selected attributes with set_translations" do
345 Post.locale = :de
346 post = Post.create(:subject => "foo1", :content => "foo1")
347 Post.locale = :en
348 post.update_attributes(:subject => "bar1", :content => "bar1")
349
350 options = { :de => { :content => "foo2" }, :en => { :subject => "bar2" } }
351 post.set_translations options
352 post.reload
353
354 assert ["bar2", "bar1"], [post.subject, post.content]
355 Post.locale = :de
356 assert ["foo1", "foo2"], [post.subject, post.content]
357 end
358
359 test "setting invalid attributes raises ArgumentError" do
360 Post.locale = :de
361 post = Post.create(:subject => "foo1", :content => "foo1")
362 Post.locale = :en
363 post.update_attributes(:subject => "bar1", :content => "bar1")
364
365 options = { :de => {:fake => "foo2"} }
366 exception = assert_raise(ActiveRecord::UnknownAttributeError) do
367 post.set_translations options
368 end
369 assert_equal "unknown attribute: fake", exception.message
370 end
371
372 test "reload accepting find options" do
373 p = Post.create(:subject => "Foo", :content => "Bar")
374 assert p.reload(:readonly => true, :lock => true)
375 assert_raise(ArgumentError) { p.reload(:foo => :bar) }
376 end
377
378 test "dependent destroy of translation" do
379 p = Post.create(:subject => "Foo", :content => "Bar")
380 assert_equal 1, PostTranslation.count
381 p.destroy
382 assert_equal 0, PostTranslation.count
383 end
384
385 test "translating subclass of untranslated comment model" do
386 translated_comment = TranslatedComment.create(:post => @post)
387 assert_nothing_raised { translated_comment.translations }
388 end
389
390 test "modifiying translated comments works as expected" do
391 I18n.locale = :en
392 translated_comment = TranslatedComment.create(:post => @post, :content => 'foo')
393 assert_equal 'foo', translated_comment.content
394
395 I18n.locale = :de
396 translated_comment.content = 'bar'
397 assert translated_comment.save
398 assert_equal 'bar', translated_comment.content
399
400 I18n.locale = :en
401 assert_equal 'foo', translated_comment.content
402
403 assert_equal 2, translated_comment.translations.size
404 end
405
406 test "can create a proxy class for a namespaced model" do
407 assert_nothing_raised do
408 module Foo
409 module Bar
410 class Baz < ActiveRecord::Base
411 translates :bumm
412 end
413 end
414 end
415 end
416 end
417
418 test "attribute translated before type cast" do
419 Post.locale = :en
420 post = Post.create(:subject => 'foo', :content => 'bar')
421 Post.locale = :de
422 post.update_attribute(:subject, "German foo")
423 assert_equal 'German foo', post.subject_before_type_cast
424 Post.locale = :en
425 assert_equal 'foo', post.subject_before_type_cast
426 end
427
428 test "don't override existing translation class" do
429 assert PostTranslation.new.respond_to?(:existing_method)
430 end
431
432 test "has_many and named scopes work with globalize" do
433 blog = Blog.create
434 assert_nothing_raised { blog.posts.foobar }
435 end
436end
437
438# TODO error checking for fields that exist in main table, don't exist in
439# proxy table, aren't strings or text
440#
441# TODO allow finding by translated attributes in conditions?
442# TODO generate advanced dynamic finders?
diff --git a/vendor/plugins/globalize2/test/backends/chained_test.rb b/vendor/plugins/globalize2/test/backends/chained_test.rb
deleted file mode 100644
index bb0b3e0..0000000
--- a/vendor/plugins/globalize2/test/backends/chained_test.rb
+++ /dev/null
@@ -1,175 +0,0 @@
1require File.join( File.dirname(__FILE__), '..', 'test_helper' )
2require 'globalize/backend/chain'
3
4module Globalize
5 module Backend
6 class Dummy
7 def translate(locale, key, options = {})
8 end
9 end
10 end
11end
12
13class ChainedTest < ActiveSupport::TestCase
14
15 test "instantiates a chained backend and sets test as backend" do
16 assert_nothing_raised { I18n.chain_backends }
17 assert_instance_of Globalize::Backend::Chain, I18n.backend
18 end
19
20 test "passes all given arguments to the chained backends #initialize method" do
21 Globalize::Backend::Chain.expects(:new).with(:spec, :simple)
22 I18n.chain_backends :spec, :simple
23 end
24
25 test "passes all given arguments to #add assuming that they are backends" do
26 # no idea how to spec that
27 end
28end
29
30class AddChainedTest < ActiveSupport::TestCase
31 def setup
32 I18n.backend = Globalize::Backend::Chain.new
33 end
34
35 test "accepts an instance of a backend" do
36 assert_nothing_raised { I18n.backend.add Globalize::Backend::Dummy.new }
37 assert_instance_of Globalize::Backend::Dummy, I18n.backend.send(:backends).first
38 end
39
40 test "accepts a class and instantiates the backend" do
41 assert_nothing_raised { I18n.backend.add Globalize::Backend::Dummy }
42 assert_instance_of Globalize::Backend::Dummy, I18n.backend.send(:backends).first
43 end
44
45 test "accepts a symbol, constantizes test as a backend class and instantiates the backend" do
46 assert_nothing_raised { I18n.backend.add :dummy }
47 assert_instance_of Globalize::Backend::Dummy, I18n.backend.send(:backends).first
48 end
49
50 test "accepts any number of backend instances, classes or symbols" do
51 assert_nothing_raised { I18n.backend.add Globalize::Backend::Dummy.new, Globalize::Backend::Dummy, :dummy }
52 assert_instance_of Globalize::Backend::Dummy, I18n.backend.send(:backends).first
53 assert_equal [ Globalize::Backend::Dummy, Globalize::Backend::Dummy, Globalize::Backend::Dummy ],
54 I18n.backend.send(:backends).map{|backend| backend.class }
55 end
56
57end
58
59class TranslateChainedTest < ActiveSupport::TestCase
60 def setup
61 I18n.locale = :en
62 I18n.backend = Globalize::Backend::Chain.new
63 @first_backend = I18n::Backend::Simple.new
64 @last_backend = I18n::Backend::Simple.new
65 I18n.backend.add @first_backend
66 I18n.backend.add @last_backend
67 end
68
69 test "delegates #translate to all backends in the order they were added" do
70 @first_backend.expects(:translate).with(:en, :foo, {})
71 @last_backend.expects(:translate).with(:en, :foo, {})
72 I18n.translate :foo
73 end
74
75 test "returns the result from #translate from the first backend if test's not nil" do
76 @first_backend.store_translations :en, {:foo => 'foo from first backend'}
77 @last_backend.store_translations :en, {:foo => 'foo from last backend'}
78 result = I18n.translate :foo
79 assert_equal 'foo from first backend', result
80 end
81
82 test "returns the result from #translate from the second backend if the first one returned nil" do
83 @first_backend.store_translations :en, {}
84 @last_backend.store_translations :en, {:foo => 'foo from last backend'}
85 result = I18n.translate :foo
86 assert_equal 'foo from last backend', result
87 end
88
89 test "looks up a namespace from all backends and merges them (if a result is a hash and no count option is present)" do
90 @first_backend.store_translations :en, {:foo => {:bar => 'bar from first backend'}}
91 @last_backend.store_translations :en, {:foo => {:baz => 'baz from last backend'}}
92 result = I18n.translate :foo
93 assert_equal( {:bar => 'bar from first backend', :baz => 'baz from last backend'}, result )
94 end
95
96 test "raises a MissingTranslationData exception if no translation was found" do
97 assert_raise( I18n::MissingTranslationData ) { I18n.translate :not_here, :raise => true }
98 end
99
100 test "raises an InvalidLocale exception if the locale is nil" do
101 assert_raise( I18n::InvalidLocale ) { Globalize::Backend::Chain.new.translate nil, :foo }
102 end
103
104 test "bulk translates a number of keys from different backends" do
105 @first_backend.store_translations :en, {:foo => 'foo from first backend'}
106 @last_backend.store_translations :en, {:bar => 'bar from last backend'}
107 result = I18n.translate [:foo, :bar]
108 assert_equal( ['foo from first backend', 'bar from last backend'], result )
109 end
110
111 test "still calls #translate on all the backends" do
112 @last_backend.expects :translate
113 I18n.translate :not_here, :default => 'default'
114 end
115
116 test "returns a given default string when no backend returns a translation" do
117 result = I18n.translate :not_here, :default => 'default'
118 assert_equal 'default', result
119 end
120
121end
122
123class CustomLocalizeBackend < I18n::Backend::Simple
124 def localize(locale, object, format = :default)
125 "result from custom localize backend" if locale == 'custom'
126 end
127end
128
129class LocalizeChainedTest < ActiveSupport::TestCase
130 def setup
131 I18n.locale = :en
132 I18n.backend = Globalize::Backend::Chain.new
133 @first_backend = CustomLocalizeBackend.new
134 @last_backend = I18n::Backend::Simple.new
135 I18n.backend.add @first_backend
136 I18n.backend.add @last_backend
137 @time = Time.now
138 end
139
140 test "delegates #localize to all backends in the order they were added" do
141 @first_backend.expects(:localize).with(:en, @time, :default)
142 @last_backend.expects(:localize).with(:en, @time, :default)
143 I18n.localize @time
144 end
145
146 test "returns the result from #localize from the first backend if test's not nil" do
147 @last_backend.expects(:localize).never
148 result = I18n.localize @time, :locale => 'custom'
149 assert_equal 'result from custom localize backend', result
150 end
151
152 test "returns the result from #localize from the second backend if the first one returned nil" do
153 @last_backend.expects(:localize).returns "value from last backend"
154 result = I18n.localize @time
155 assert_equal 'value from last backend', result
156 end
157end
158
159class NamespaceChainedTest < ActiveSupport::TestCase
160 def setup
161 @backend = Globalize::Backend::Chain.new
162 end
163
164 test "returns false if the given result is not a Hash" do
165 assert !@backend.send(:namespace_lookup?, 'foo', {})
166 end
167
168 test "returns false if a count option is present" do
169 assert !@backend.send(:namespace_lookup?, {:foo => 'foo'}, {:count => 1})
170 end
171
172 test "returns true if the given result is a Hash AND no count option is present" do
173 assert @backend.send(:namespace_lookup?, {:foo => 'foo'}, {})
174 end
175end
diff --git a/vendor/plugins/globalize2/test/backends/pluralizing_test.rb b/vendor/plugins/globalize2/test/backends/pluralizing_test.rb
deleted file mode 100644
index 7445e3f..0000000
--- a/vendor/plugins/globalize2/test/backends/pluralizing_test.rb
+++ /dev/null
@@ -1,63 +0,0 @@
1require File.join( File.dirname(__FILE__), '..', 'test_helper' )
2require 'globalize/backend/pluralizing'
3
4class PluralizingTest < ActiveSupport::TestCase
5 def setup
6 @backend = Globalize::Backend::Pluralizing.new
7 @cz_pluralizer = lambda{|c| c == 1 ? :one : (2..4).include?(c) ? :few : :other }
8 end
9
10 test "#pluralizer returns the pluralizer for a given locale if defined" do
11 assert_instance_of Proc, @backend.pluralizer(:en)
12 end
13
14 test "#pluralizer returns the default pluralizer if no pluralizer is defined for the given locale" do
15 assert_equal @backend.pluralizer(:en), @backend.pluralizer(:de)
16 end
17
18 test "#add_pluralizer allows to store a pluralizer per locale" do
19 assert_nothing_raised { @backend.add_pluralizer(:cz, @cz_pluralizer) }
20 assert_equal @cz_pluralizer, @backend.pluralizer(:cz)
21 end
22
23end
24
25class PluralizePluralizingTest < ActiveSupport::TestCase
26 def setup
27 @backend = Globalize::Backend::Pluralizing.new
28 @cz_pluralizer = lambda{|c| c == 1 ? :one : (2..4).include?(c) ? :few : :other }
29 @backend.store_translations :en, :foo => {:one => 'one en foo', :other => 'many en foos'}
30 @backend.store_translations :cz, :foo => {:one => 'one cz foo', :few => 'few cz foos', :other => 'many cz foos'}
31 end
32
33 test "looks up the :one translation when count is 1" do
34 assert_equal 'one en foo', @backend.translate(:en, :foo, :count => 1)
35 end
36
37 test "looks up the :other translation when count is 2" do
38 assert_equal 'many en foos', @backend.translate(:en, :foo, :count => 2)
39 end
40end
41
42class CzPluralizingTest < ActiveSupport::TestCase
43 def setup
44 @backend = Globalize::Backend::Pluralizing.new
45 @cz_pluralizer = lambda{|c| c == 1 ? :one : (2..4).include?(c) ? :few : :other }
46 @backend.store_translations :en, :foo => {:one => 'one en foo', :other => 'many en foos'}
47 @backend.store_translations :cz, :foo => {:one => 'one cz foo', :few => 'few cz foos', :other => 'many cz foos'}
48 @backend.add_pluralizer(:cz, @cz_pluralizer)
49 end
50
51 test "looks up the :one translation when count is 1 (:cz)" do
52 assert_equal 'one cz foo', @backend.translate(:cz, :foo, :count => 1)
53 end
54
55 test "looks up the :few translation when count is 2 (:cz)" do
56 assert_equal 'few cz foos', @backend.translate(:cz, :foo, :count => 2)
57 end
58
59 test "looks up the :other translation when count is 5 (:cz)" do
60 assert_equal 'many cz foos', @backend.translate(:cz, :foo, :count => 5)
61 end
62
63end
diff --git a/vendor/plugins/globalize2/test/backends/static_test.rb b/vendor/plugins/globalize2/test/backends/static_test.rb
deleted file mode 100644
index 133e547..0000000
--- a/vendor/plugins/globalize2/test/backends/static_test.rb
+++ /dev/null
@@ -1,143 +0,0 @@
1require File.join( File.dirname(__FILE__), '..', 'test_helper' )
2require 'globalize/backend/static'
3require 'globalize/translation'
4require 'action_view'
5include ActionView::Helpers::NumberHelper
6
7I18n.locale = :'en-US' # Need to set this, since I18n defaults to 'en'
8
9class StaticTest < ActiveSupport::TestCase
10 def setup
11 I18n.backend = Globalize::Backend::Static.new
12 translations = {:"en-US" => {:foo => "foo in en-US", :boz => 'boz', :buz => {:bum => 'bum'}},
13 :"en" => {:bar => "bar in en"},
14 :"de-DE" => {:baz => "baz in de-DE"},
15 :"de" => {:boo => "boo in de", :number => { :currency => { :format => { :unit => '€', :format => '%n %u'}}}}}
16 translations.each do |locale, data|
17 I18n.backend.store_translations locale, data
18 end
19 I18n.fallbacks.map :"de-DE" => :"en-US", :he => :en
20 end
21
22 test "returns an instance of Translation:Static" do
23 translation = I18n.translate :foo
24 assert_instance_of Globalize::Translation::Static, translation
25 end
26
27 test "returns the translation in en-US if present" do
28 assert_equal "foo in en-US", I18n.translate(:foo, :locale => :"en-US")
29 end
30
31 test "returns the translation in en if en-US is not present" do
32 assert_equal "bar in en", I18n.translate(:bar, :locale => :"en-US")
33 end
34
35 test "returns the translation in de-DE if present" do
36 assert_equal "baz in de-DE", I18n.translate(:baz, :locale => :"de-DE")
37 end
38
39 test "returns the translation in de if de-DE is not present" do
40 assert_equal "boo in de", I18n.translate(:boo, :locale => :"de-DE")
41 end
42
43 test "returns the translation in en-US if none of de-DE and de are present" do
44 assert_equal "foo in en-US", I18n.translate(:foo, :locale => :"de-DE")
45 end
46
47 test "returns the translation in en if none of de-DE, de and en-US are present" do
48 assert_equal "bar in en", I18n.translate(:bar, :locale => :"de-DE")
49 end
50
51 test "returns the translation in en if none in he is present" do
52 assert_equal "bar in en", I18n.translate(:bar, :locale => :he)
53 end
54
55 test "returns the given default String when the key is not present for any locale" do
56 assert_equal "default", I18n.translate(:missing, :default => "default")
57 end
58
59 test "returns the fallback translation for the key if present for a fallback locale" do
60 I18n.backend.store_translations :de, :non_default => "non_default in de"
61 assert_equal "non_default in de", I18n.translate(:non_default, :default => "default", :locale => :"de-DE")
62 end
63
64 test "returns an array of translations" do
65 assert_instance_of Array, I18n.translate([:foo, :boz])
66 end
67
68 test "returns an array of instances of Translation::Static" do
69 assert_equal [Globalize::Translation::Static], I18n.translate([:foo, :boz]).map(&:class).uniq
70 end
71
72 test "returns a hash of translations" do
73 assert_instance_of Hash, I18n.translate(:"buz")
74 end
75
76 test "returns an array of translations 2" do
77 assert_equal [Globalize::Translation::Static], I18n.translate(:"buz").values.map(&:class)
78 end
79
80 test "returns currency properly formated" do
81 currency = number_to_currency(10)
82 assert_equal "$10.00", currency
83 end
84
85 test "returns currency properly formated for locale" do
86 currency = number_to_currency(10, :locale => :'de')
87 assert_equal "10.000 €", currency
88 end
89
90 test "returns currency properly formated from parameters" do
91 currency = number_to_currency(10, :format => "%n %u", :unit => '€')
92 assert_equal "10.00 €", currency
93 end
94
95 test "makes sure interpolation does not break even with False as string" do
96 assert_equal "translation missing: en, support, array, skip_last_comma", I18n.translate(:"support.array.skip_last_comma")
97 end
98end
99
100class TranslationStaticTest < ActiveSupport::TestCase
101 def setup
102 I18n.backend = Globalize::Backend::Static.new
103 translations = {
104 :greeting => "Hi {{name}}",
105 :messages => { :one => "You have one message.", :other => "You have {{count}} messages."}
106 }
107 I18n.backend.store_translations :"en", translations
108 end
109
110 def greeting
111 I18n.translate :greeting, :locale => :"en-US", :name => "Joshua"
112 end
113
114 test "stores the actual locale" do
115 assert_equal :en, greeting.locale
116 end
117
118 test "stores the requested locale" do
119 assert_equal :'en-US', greeting.requested_locale
120 end
121
122 test "stores the requested key" do
123 assert_equal :greeting, greeting.key
124 end
125
126 test "stores the options given to #translate" do
127 assert_equal( {:name => "Joshua"}, greeting.options )
128 end
129
130 test "stores the original translation before test was interpolated" do
131 assert_equal "Hi {{name}}", greeting.original
132 end
133
134 test "stores the plural_key :one if pluralized as such" do
135 message = I18n.translate :messages, :locale => :"en-US", :count => 1
136 assert_equal :one, message.plural_key
137 end
138
139 test "stores the plural_key :other if pluralized as such" do
140 messages = I18n.translate :messages, :locale => :"en-US", :count => 2
141 assert_equal :other, messages.plural_key
142 end
143end
diff --git a/vendor/plugins/globalize2/test/data/locale/all.yml b/vendor/plugins/globalize2/test/data/locale/all.yml
deleted file mode 100644
index ee4fb4a..0000000
--- a/vendor/plugins/globalize2/test/data/locale/all.yml
+++ /dev/null
@@ -1,2 +0,0 @@
1en-US:
2 from-all-file: From the "all" file.
diff --git a/vendor/plugins/globalize2/test/data/locale/de-DE.yml b/vendor/plugins/globalize2/test/data/locale/de-DE.yml
deleted file mode 100644
index d4c468e..0000000
--- a/vendor/plugins/globalize2/test/data/locale/de-DE.yml
+++ /dev/null
@@ -1,2 +0,0 @@
1de-DE:
2 from-locale-file: Aus der Locale Datei. \ No newline at end of file
diff --git a/vendor/plugins/globalize2/test/data/locale/en-US.yml b/vendor/plugins/globalize2/test/data/locale/en-US.yml
deleted file mode 100644
index 866b171..0000000
--- a/vendor/plugins/globalize2/test/data/locale/en-US.yml
+++ /dev/null
@@ -1,2 +0,0 @@
1en-US:
2 from-locale-file: From the locale file.
diff --git a/vendor/plugins/globalize2/test/data/locale/en-US/module.yml b/vendor/plugins/globalize2/test/data/locale/en-US/module.yml
deleted file mode 100644
index 6655e9b..0000000
--- a/vendor/plugins/globalize2/test/data/locale/en-US/module.yml
+++ /dev/null
@@ -1,2 +0,0 @@
1en-US:
2 from-locale-dir: From the locale directory.
diff --git a/vendor/plugins/globalize2/test/data/locale/fi-FI/module.yml b/vendor/plugins/globalize2/test/data/locale/fi-FI/module.yml
deleted file mode 100644
index 62d00b1..0000000
--- a/vendor/plugins/globalize2/test/data/locale/fi-FI/module.yml
+++ /dev/null
@@ -1,2 +0,0 @@
1fi-FI:
2 from-locale-dir: Locale hakemistosta. \ No newline at end of file
diff --git a/vendor/plugins/globalize2/test/data/locale/root.yml b/vendor/plugins/globalize2/test/data/locale/root.yml
deleted file mode 100644
index e69de29..0000000
--- a/vendor/plugins/globalize2/test/data/locale/root.yml
+++ /dev/null
diff --git a/vendor/plugins/globalize2/test/data/models.rb b/vendor/plugins/globalize2/test/data/models.rb
index f6dab90..553fca3 100644
--- a/vendor/plugins/globalize2/test/data/models.rb
+++ b/vendor/plugins/globalize2/test/data/models.rb
@@ -1,6 +1,16 @@
1#require 'ruby2ruby'
2#require 'parse_tree'
3#require 'parse_tree_extensions'
4#require 'pp'
5
6class PostTranslation < ActiveRecord::Base
7 def existing_method ; end
8end
9
1class Post < ActiveRecord::Base 10class Post < ActiveRecord::Base
2 translates :subject, :content 11 translates :subject, :content
3 validates_presence_of :subject 12 validates_presence_of :subject
13 named_scope :foobar, :conditions => { :title => "foobar" }
4end 14end
5 15
6class Blog < ActiveRecord::Base 16class Blog < ActiveRecord::Base
@@ -18,7 +28,7 @@ class Comment < ActiveRecord::Base
18 validates_presence_of :content 28 validates_presence_of :content
19 belongs_to :post 29 belongs_to :post
20end 30end
21 31
22class TranslatedComment < Comment 32class TranslatedComment < Comment
23 translates :content 33 translates :content
24end 34end
@@ -26,4 +36,16 @@ end
26class UltraLongModelNameWithoutProper < ActiveRecord::Base 36class UltraLongModelNameWithoutProper < ActiveRecord::Base
27 translates :subject, :content 37 translates :subject, :content
28 validates_presence_of :subject 38 validates_presence_of :subject
29end \ No newline at end of file 39end
40
41class Reloader < Parent
42 after_create :do_reload
43
44 def do_reload
45 reload
46 end
47end
48
49class Validatee < ActiveRecord::Base
50 translates :string
51end
diff --git a/vendor/plugins/globalize2/test/i18n/missing_translations_test.rb b/vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
index 8641d57..5d0ecd6 100644
--- a/vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
+++ b/vendor/plugins/globalize2/test/i18n/missing_translations_test.rb
@@ -1,5 +1,5 @@
1require File.join( File.dirname(__FILE__), '..', 'test_helper' ) 1require File.dirname(__FILE__) + '/../test_helper'
2require 'globalize/i18n/missing_translations_log_handler' 2require 'i18n/missing_translations_log_handler'
3 3
4class MissingTranslationsTest < ActiveSupport::TestCase 4class MissingTranslationsTest < ActiveSupport::TestCase
5 test "defines I18n.missing_translations_logger accessor" do 5 test "defines I18n.missing_translations_logger accessor" do
@@ -19,18 +19,18 @@ class LogMissingTranslationsTest < ActiveSupport::TestCase
19 def setup 19 def setup
20 @locale, @key, @options = :en, :foo, {} 20 @locale, @key, @options = :en, :foo, {}
21 @exception = I18n::MissingTranslationData.new(@locale, @key, @options) 21 @exception = I18n::MissingTranslationData.new(@locale, @key, @options)
22 22
23 @logger = TestLogger.new 23 @logger = TestLogger.new
24 I18n.missing_translations_logger = @logger 24 I18n.missing_translations_logger = @logger
25 end 25 end
26 26
27 test "still returns the exception message for MissingTranslationData exceptions" do 27 test "still returns the exception message for MissingTranslationData exceptions" do
28 result = I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options) 28 result = I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
29 assert_equal 'translation missing: en, foo', result 29 assert_equal 'translation missing: en, foo', result
30 end 30 end
31 31
32 test "logs the missing translation to I18n.missing_translations_logger" do 32 test "logs the missing translation to I18n.missing_translations_logger" do
33 I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options) 33 I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
34 assert_equal 'translation missing: en, foo', @logger 34 assert_equal 'translation missing: en, foo', @logger
35 end 35 end
36end 36end
diff --git a/vendor/plugins/globalize2/test/load_path_test.rb b/vendor/plugins/globalize2/test/load_path_test.rb
deleted file mode 100644
index ff009b3..0000000
--- a/vendor/plugins/globalize2/test/load_path_test.rb
+++ /dev/null
@@ -1,49 +0,0 @@
1require File.join( File.dirname(__FILE__), 'test_helper' )
2require 'globalize/load_path'
3
4class LoadPathTest < ActiveSupport::TestCase
5 def setup
6 @plugin_dir = "#{File.dirname(__FILE__)}/.."
7 @locale_dir = "#{File.dirname(__FILE__)}/data/locale"
8 @load_path = Globalize::LoadPath.new
9 end
10
11 test "returns glob patterns for all locales and ruby + yaml files by default" do
12 patterns = %w(locales/all.rb
13 locales/*.rb
14 locales/*/**/*.rb
15 locales/all.yml
16 locales/*.yml
17 locales/*/**/*.yml)
18 assert_equal patterns, @load_path.send(:patterns, 'locales')
19 end
20
21 test "returns the glob patterns for registered locales and extensions" do
22 @load_path.locales = [:en, :de]
23 @load_path.extensions = [:sql]
24 patterns = %w(locales/all.sql
25 locales/en.sql
26 locales/en/**/*.sql
27 locales/de.sql
28 locales/de/**/*.sql)
29 assert_equal patterns, @load_path.send(:patterns, 'locales')
30 end
31
32 test "expands paths using yml as a default file extension" do
33 @load_path << @locale_dir
34 expected = %w(all.yml de-DE.yml en-US.yml en-US/module.yml fi-FI/module.yml root.yml)
35 assert_equal expected, @load_path.map{|path| path.sub("#{@locale_dir}\/", '')}
36 end
37
38 test "appends new paths to the collection so earlier collected paths preceed later collected ones" do
39 @load_path.locales = [:root]
40 @load_path << "#{@plugin_dir}/lib/locale"
41 @load_path << @locale_dir
42
43 expected = %W(#{@plugin_dir}/lib/locale/root.yml
44 #{@locale_dir}/all.yml
45 #{@locale_dir}/root.yml)
46 assert_equal expected, @load_path
47 end
48
49end
diff --git a/vendor/plugins/globalize2/test/locale/fallbacks_test.rb b/vendor/plugins/globalize2/test/locale/fallbacks_test.rb
deleted file mode 100644
index 304d3da..0000000
--- a/vendor/plugins/globalize2/test/locale/fallbacks_test.rb
+++ /dev/null
@@ -1,154 +0,0 @@
1require File.join( File.dirname(__FILE__), '..', 'test_helper' )
2require 'globalize/locale/fallbacks'
3
4include Globalize::Locale
5I18n.default_locale = :'en-US' # This has to be set explicitly, no longer default for I18n
6
7class FallbacksTest < ActiveSupport::TestCase
8 def setup
9 I18n.fallbacks = Fallbacks.new
10 end
11
12 def teardown
13 I18n.default_locale = :'en-US'
14 end
15
16 test "#[] caches computed results" do
17 I18n.fallbacks['en']
18 assert_equal( { :en => [:en, :"en-US", :root] }, I18n.fallbacks )
19 end
20
21 test "#defaults always reflect the I18n.default_locale if no default has been set manually" do
22 I18n.default_locale = :'en-US'
23 assert_equal( [:'en-US', :en, :root], I18n.fallbacks.defaults )
24 end
25
26 test "#defaults always reflect a manually passed default locale if any" do
27 I18n.fallbacks = Fallbacks.new(:'fi-FI')
28 assert_equal( [:'fi-FI', :fi, :root], I18n.fallbacks.defaults )
29 I18n.default_locale = :'de-DE'
30 assert_equal( [:'fi-FI', :fi, :root], I18n.fallbacks.defaults )
31 end
32
33 test "#defaults allows to set multiple defaults" do
34 I18n.fallbacks = Fallbacks.new(:'fi-FI', :'se-FI')
35 assert_equal( [:'fi-FI', :fi, :'se-FI', :se, :root], I18n.fallbacks.defaults )
36 end
37end
38
39class NoMappingFallbacksTest < ActiveSupport::TestCase
40 def setup
41 @fallbacks = Fallbacks.new(:'en-US')
42 end
43
44 test "returns [:es, :en-US, :root] for :es" do
45 assert_equal [:es, :"en-US", :en, :root], @fallbacks[:es]
46 end
47
48 test "returns [:es-ES, :es, :en-US, :root] for :es-ES" do
49 assert_equal [:"es-ES", :es, :"en-US", :en, :root], @fallbacks[:"es-ES"]
50 end
51
52 test "returns [:es-MX, :es, :en-US, :root] for :es-MX" do
53 assert_equal [:"es-MX", :es, :"en-US", :en, :root], @fallbacks[:"es-MX"]
54 end
55
56 test "returns [:es-Latn-ES, :es-Latn, :es, :en-US, :root] for :es-Latn-ES" do
57 assert_equal [:"es-Latn-ES", :"es-Latn", :es, :"en-US", :en, :root], @fallbacks[:'es-Latn-ES']
58 end
59
60 test "returns [:en, :en-US, :root] for :en" do
61 assert_equal [:en, :"en-US", :root], @fallbacks[:en]
62 end
63
64 test "returns [:en-US, :en, :root] for :en-US (special case: locale == default)" do
65 assert_equal [:"en-US", :en, :root], @fallbacks[:"en-US"]
66 end
67end
68
69class CaMappingFallbacksTest < ActiveSupport::TestCase
70 # Most people who speak Catalan also live in Spain, so test is safe to assume
71 # that they also speak Spanish as spoken in Spain.
72 def setup
73 @fallbacks = Fallbacks.new(:'en-US')
74 @fallbacks.map :ca => :"es-ES"
75 end
76
77 test "returns [:ca, :es-ES, :es, :en-US, :root] for :ca" do
78 assert_equal [:ca, :"es-ES", :es, :"en-US", :en, :root], @fallbacks[:ca]
79 end
80
81 test "returns [:ca-ES, :ca, :es-ES, :es, :en-US, :root] for :ca-ES" do
82 assert_equal [:"ca-ES", :ca, :"es-ES", :es, :"en-US", :en, :root], @fallbacks[:"ca-ES"]
83 end
84end
85
86class ArMappingFallbacksTest < ActiveSupport::TestCase
87 # People who speak Arabic as spoken in Palestine often times also speak
88 # Hebrew as spoken in Israel. However test is in no way safe to assume that
89 # everybody who speaks Arabic also speaks Hebrew.
90 def setup
91 @fallbacks = Fallbacks.new(:'en-US')
92 @fallbacks.map :"ar-PS" => :"he-IL"
93 end
94
95 test "returns [:ar, :en-US, :root] for :ar" do
96 assert_equal [:ar, :"en-US", :en, :root], @fallbacks[:ar]
97 end
98
99 test "returns [:ar-EG, :ar, :en-US, :root] for :ar-EG" do
100 assert_equal [:"ar-EG", :ar, :"en-US", :en, :root], @fallbacks[:"ar-EG"]
101 end
102
103 test "returns [:ar-PS, :ar, :he-IL, :he, :en-US, :root] for :ar-PS" do
104 assert_equal [:"ar-PS", :ar, :"he-IL", :he, :"en-US", :en, :root], @fallbacks[:"ar-PS"]
105 end
106end
107
108class SmsMappingFallbacksTest < ActiveSupport::TestCase
109 # Sami people live in several scandinavian countries. In Finnland many people
110 # know Swedish and Finnish. Thus, test can be assumed that Sami living in
111 # Finnland also speak Swedish and Finnish.
112 def setup
113 @fallbacks = Fallbacks.new(:'en-US')
114 @fallbacks.map :sms => [:"se-FI", :"fi-FI"]
115 end
116
117 test "returns [:sms-FI, :sms, :se-FI, :se, :fi-FI, :fi, :en-US, :root] for :sms-FI" do
118 assert_equal [:"sms-FI", :sms, :"se-FI", :se, :"fi-FI", :fi, :"en-US", :en, :root], @fallbacks[:"sms-FI"]
119 end
120end
121
122class DeAtMappingFallbacksTest < ActiveSupport::TestCase
123 def setup
124 @fallbacks = Fallbacks.new(:'en-US')
125 @fallbacks.map :"de-AT" => :"de-DE"
126 end
127
128 test "returns [:de, :en-US, :root] for de" do
129 assert_equal [:de, :"en-US", :en, :root], @fallbacks[:"de"]
130 end
131
132 test "returns [:de-DE, :de, :en-US, :root] for de-DE" do
133 assert_equal [:"de-DE", :de, :"en-US", :en, :root], @fallbacks[:"de-DE"]
134 end
135
136 test "returns [:de-AT, :de, :de-DE, :en-US, :root] for de-AT" do
137 assert_equal [:"de-AT", :de, :"de-DE", :"en-US", :en, :root], @fallbacks[:"de-AT"]
138 end
139end
140
141class DeMappingFallbacksTest < ActiveSupport::TestCase
142 def setup
143 @fallbacks = Fallbacks.new(:'en-US')
144 @fallbacks.map :de => :en, :he => :en
145 end
146
147 test "returns [:de, :en, :root] for :de" do
148 assert_equal [:de, :en, :"en-US", :root], @fallbacks[:de]
149 end
150
151 test "returns [:he, :en, :root] for :de" do
152 assert_equal [:he, :en, :"en-US", :root], @fallbacks[:he]
153 end
154end
diff --git a/vendor/plugins/globalize2/test/locale/language_tag_test.rb b/vendor/plugins/globalize2/test/locale/language_tag_test.rb
deleted file mode 100644
index 2448af1..0000000
--- a/vendor/plugins/globalize2/test/locale/language_tag_test.rb
+++ /dev/null
@@ -1,130 +0,0 @@
1require File.join( File.dirname(__FILE__), '..', 'test_helper' )
2require 'globalize/locale/language_tag'
3
4include Globalize::Locale
5
6class LanguageTagTest < ActiveSupport::TestCase
7 test "given a valid tag 'de' returns an LanguageTag from #tag" do
8 assert_instance_of LanguageTag, LanguageTag.tag('de')
9 end
10
11 test "given a valid tag 'de' returns an array of subtags" do
12 assert_equal ['de', nil, nil, nil, nil, nil, nil], LanguageTag::SimpleParser.match('de')
13 end
14
15 test "given a valid tag 'de-DE' returns an array of subtags" do
16 assert_equal ['de', nil, 'DE', nil, nil, nil, nil], LanguageTag::SimpleParser.match('de-DE')
17 end
18
19 test "given a valid lowercase tag 'de-latn-de-variant-x-phonebk' returns an array of subtags" do
20 assert_equal ['de', 'latn', 'de', 'variant', nil, 'x-phonebk', nil],
21 LanguageTag::SimpleParser.match('de-latn-de-variant-x-phonebk')
22 end
23
24 test "given a valid uppercase tag 'DE-LATN-DE-VARIANT-X-PHONEBK' returns an array of subtags" do
25 assert_equal ['DE', 'LATN', 'DE', 'VARIANT', nil, 'X-PHONEBK', nil],
26 LanguageTag::SimpleParser.match('DE-LATN-DE-VARIANT-X-PHONEBK')
27 end
28
29 test "given an invalid tag 'a-DE' test returns false" do
30 assert !LanguageTag::SimpleParser.match('a-DE')
31 end
32
33 test "given an invalid tag 'de-419-DE' test returns false" do
34 assert !LanguageTag::SimpleParser.match('de-419-DE')
35 end
36end
37
38class DeLatnLanguageTagTest < ActiveSupport::TestCase
39 def setup
40 subtags = %w(de Latn DE variant a-ext x-phonebk i-klingon)
41 @tag = LanguageTag.new *subtags
42 end
43
44 test "returns 'de' as the language subtag in lowercase" do
45 assert_equal 'de', @tag.language
46 end
47
48 test "returns 'Latn' as the script subtag in titlecase" do
49 assert_equal 'Latn', @tag.script
50 end
51
52 test "returns 'DE' as the region subtag in uppercase" do
53 assert_equal 'DE', @tag.region
54 end
55
56 test "returns 'variant' as the variant subtag in lowercase" do
57 assert_equal 'variant', @tag.variant
58 end
59
60 test "returns 'a-ext' as the extension subtag" do
61 assert_equal 'a-ext', @tag.extension
62 end
63
64 test "returns 'x-phonebk' as the privateuse subtag" do
65 assert_equal 'x-phonebk', @tag.privateuse
66 end
67
68 test "returns 'i-klingon' as the grandfathered subtag" do
69 assert_equal 'i-klingon', @tag.grandfathered
70 end
71
72 test "returns a formatted tag string from #to_s" do
73 assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon', @tag.to_s
74 end
75
76 test "returns an array containing the formatted subtags from #to_a" do
77 assert_equal %w(de Latn DE variant a-ext x-phonebk i-klingon), @tag.to_a
78 end
79end
80
81class InheritanceLanguageTagTest < ActiveSupport::TestCase
82 test "returns 'de-Latn-DE-variant-a-ext-x-phonebk' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
83 tag = LanguageTag.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
84 assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk', tag.parent.to_s
85 end
86
87 test "returns 'de-Latn-DE-variant-a-ext' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk'" do
88 tag = LanguageTag.new *%w(de Latn DE variant a-ext x-phonebk)
89 assert_equal 'de-Latn-DE-variant-a-ext', tag.parent.to_s
90 end
91
92 test "returns 'de-Latn-DE-variant' as the parent of 'de-Latn-DE-variant-a-ext'" do
93 tag = LanguageTag.new *%w(de Latn DE variant a-ext)
94 assert_equal 'de-Latn-DE-variant', tag.parent.to_s
95 end
96
97 test "returns 'de-Latn-DE' as the parent of 'de-Latn-DE-variant'" do
98 tag = LanguageTag.new *%w(de Latn DE variant)
99 assert_equal 'de-Latn-DE', tag.parent.to_s
100 end
101
102 test "returns 'de-Latn' as the parent of 'de-Latn-DE'" do
103 tag = LanguageTag.new *%w(de Latn DE)
104 assert_equal 'de-Latn', tag.parent.to_s
105 end
106
107 test "returns 'de' as the parent of 'de-Latn'" do
108 tag = LanguageTag.new *%w(de Latn)
109 assert_equal 'de', tag.parent.to_s
110 end
111
112 # TODO RFC4647 says: "If no language tag matches the request, the "default" value is returned."
113 # where should we set the default language?
114 # test "returns '' as the parent of 'de'" do
115 # tag = LanguageTag.new *%w(de)
116 # assert_equal '', tag.parent.to_s
117 # end
118
119 test "returns an array of 5 parents for 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
120 parents = %w(de-Latn-DE-variant-a-ext-x-phonebk-i-klingon
121 de-Latn-DE-variant-a-ext-x-phonebk
122 de-Latn-DE-variant-a-ext
123 de-Latn-DE-variant
124 de-Latn-DE
125 de-Latn
126 de)
127 tag = LanguageTag.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
128 assert_equal parents, tag.parents.map{|tag| tag.to_s}
129 end
130end
diff --git a/vendor/plugins/globalize2/test/model/active_record/translated_test.rb b/vendor/plugins/globalize2/test/model/active_record/translated_test.rb
deleted file mode 100644
index f54894e..0000000
--- a/vendor/plugins/globalize2/test/model/active_record/translated_test.rb
+++ /dev/null
@@ -1,478 +0,0 @@
1require File.join( File.dirname(__FILE__), '..', '..', 'test_helper' )
2require 'active_record'
3require 'globalize/model/active_record'
4
5# Hook up model translation
6ActiveRecord::Base.send(:include, Globalize::Model::ActiveRecord::Translated)
7
8# Load Post model
9require File.join( File.dirname(__FILE__), '..', '..', 'data', 'models' )
10
11class TranslatedTest < ActiveSupport::TestCase
12 def setup
13 I18n.locale = :'en-US'
14 I18n.fallbacks.clear
15 reset_db! File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data', 'schema.rb'))
16 ActiveRecord::Base.locale = nil
17 end
18
19 def teardown
20 I18n.fallbacks.clear
21 end
22
23 test "modifiying translated fields" do
24 post = Post.create :subject => 'foo'
25 assert_equal 'foo', post.subject
26 post.subject = 'bar'
27 assert_equal 'bar', post.subject
28 end
29
30 test "modifiying translated fields while switching locales" do
31 post = Post.create :subject => 'foo'
32 assert_equal 'foo', post.subject
33 I18n.locale = :'de-DE'
34 post.subject = 'bar'
35 assert_equal 'bar', post.subject
36 I18n.locale = :'en-US'
37 assert_equal 'foo', post.subject
38 I18n.locale = :'de-DE'
39 post.subject = 'bar'
40 end
41
42 test "has post_translations" do
43 post = Post.create
44 assert_nothing_raised { post.globalize_translations }
45 end
46
47 test "has German post_translations" do
48 I18n.locale = :de
49 post = Post.create :subject => 'foo'
50 assert_equal 1, post.globalize_translations.size
51 I18n.locale = :en
52 assert_equal 1, post.globalize_translations.size
53 end
54
55 test "returns the value passed to :subject" do
56 post = Post.new
57 assert_equal 'foo', (post.subject = 'foo')
58 end
59
60 test "translates subject and content into en-US" do
61 post = Post.create :subject => 'foo', :content => 'bar'
62 assert_equal 'foo', post.subject
63 assert_equal 'bar', post.content
64 assert post.save
65 post.reload
66 assert_equal 'foo', post.subject
67 assert_equal 'bar', post.content
68 end
69
70 test "finds a German post" do
71 post = Post.create :subject => 'foo (en)', :content => 'bar'
72 I18n.locale = 'de-DE'
73 post = Post.first
74 post.subject = 'baz (de)'
75 post.save
76 assert_equal 'baz (de)', Post.first.subject
77 I18n.locale = :'en-US'
78 assert_equal 'foo (en)', Post.first.subject
79 end
80
81 test "saves an English post and loads test correctly" do
82 assert_nil Post.first
83 post = Post.create :subject => 'foo', :content => 'bar'
84 assert post.save
85 post = Post.first
86 assert_equal 'foo', post.subject
87 assert_equal 'bar', post.content
88 end
89
90 test "updates an attribute" do
91 post = Post.create :subject => 'foo', :content => 'bar'
92 post.update_attribute :subject, 'baz'
93 assert_equal 'baz', Post.first.subject
94 end
95
96 test "update_attributes failure" do
97 post = Post.create :subject => 'foo', :content => 'bar'
98 assert !post.update_attributes( { :subject => '' } )
99 assert_nil post.reload.attributes['subject']
100 assert_equal 'foo', post.subject
101 end
102
103 test "validates presence of :subject" do
104 post = Post.new
105 assert !post.save
106
107 post = Post.new :subject => 'foo'
108 assert post.save
109 end
110
111 test "returns the value for the correct locale, after locale switching" do
112 post = Post.create :subject => 'foo'
113 I18n.locale = 'de-DE'
114 post.subject = 'bar'
115 post.save
116 I18n.locale = 'en-US'
117 post = Post.first
118 assert_equal 'foo', post.subject
119 I18n.locale = 'de-DE'
120 assert_equal 'bar', post.subject
121 end
122
123 test "keeping one field in new locale when other field is changed" do
124 I18n.fallbacks.map 'de-DE' => [ 'en-US' ]
125 post = Post.create :subject => 'foo'
126 I18n.locale = 'de-DE'
127 post.content = 'bar'
128 assert_equal 'foo', post.subject
129 end
130
131 test "modifying non-required field in a new locale" do
132 I18n.fallbacks.map 'de-DE' => [ 'en-US' ]
133 post = Post.create :subject => 'foo'
134 I18n.locale = 'de-DE'
135 post.content = 'bar'
136 assert post.save
137 end
138
139 test "returns the value for the correct locale, after locale switching, without saving" do
140 post = Post.create :subject => 'foo'
141 I18n.locale = 'de-DE'
142 post.subject = 'bar'
143 I18n.locale = 'en-US'
144 assert_equal 'foo', post.subject
145 I18n.locale = 'de-DE'
146 assert_equal 'bar', post.subject
147 end
148
149 test "saves all locales, even after locale switching" do
150 post = Post.new :subject => 'foo'
151 I18n.locale = 'de-DE'
152 post.subject = 'bar'
153 I18n.locale = 'he-IL'
154 post.subject = 'baz'
155 post.save
156 I18n.locale = 'en-US'
157 post = Post.first
158 assert_equal 'foo', post.subject
159 I18n.locale = 'de-DE'
160 assert_equal 'bar', post.subject
161 I18n.locale = 'he-IL'
162 assert_equal 'baz', post.subject
163 end
164
165 test "resolves a simple fallback" do
166 I18n.locale = 'de-DE'
167 post = Post.create :subject => 'foo'
168 I18n.locale = 'de'
169 post.subject = 'baz'
170 post.content = 'bar'
171 post.save
172 I18n.locale = 'de-DE'
173 assert_equal 'foo', post.subject
174 assert_equal 'bar', post.content
175 end
176
177 test "resolves a simple fallback without reloading" do
178 I18n.locale = 'de-DE'
179 post = Post.new :subject => 'foo'
180 I18n.locale = 'de'
181 post.subject = 'baz'
182 post.content = 'bar'
183 I18n.locale = 'de-DE'
184 assert_equal 'foo', post.subject
185 assert_equal 'bar', post.content
186 end
187
188 test "resolves a complex fallback without reloading" do
189 I18n.fallbacks.map 'de' => %w(en he)
190 I18n.locale = 'de'
191 post = Post.new
192 I18n.locale = 'en'
193 post.subject = 'foo'
194 I18n.locale = 'he'
195 post.subject = 'baz'
196 post.content = 'bar'
197 I18n.locale = 'de'
198 assert_equal 'foo', post.subject
199 assert_equal 'bar', post.content
200 end
201
202 test "returns nil if no translations are found" do
203 post = Post.new :subject => 'foo'
204 assert_equal 'foo', post.subject
205 assert_nil post.content
206 end
207
208 test "returns nil if no translations are found; reloaded" do
209 post = Post.create :subject => 'foo'
210 post = Post.first
211 assert_equal 'foo', post.subject
212 assert_nil post.content
213 end
214
215 test "works with associations" do
216 blog = Blog.create
217 post1 = blog.posts.create :subject => 'foo'
218 I18n.locale = 'de-DE'
219 post2 = blog.posts.create :subject => 'bar'
220 assert_equal 2, blog.posts.size
221 I18n.locale = 'en-US'
222 assert_equal 'foo', blog.posts.first.subject
223 assert_nil blog.posts.last.subject
224 I18n.locale = 'de-DE'
225 assert_equal 'bar', blog.posts.last.subject
226 end
227
228 test "works with simple dynamic finders" do
229 foo = Post.create :subject => 'foo'
230 Post.create :subject => 'bar'
231 post = Post.find_by_subject('foo')
232 assert_equal foo, post
233 end
234
235 test 'change attribute on globalized model' do
236 post = Post.create :subject => 'foo', :content => 'bar'
237 assert_equal [], post.changed
238 post.subject = 'baz'
239 assert_equal [ 'subject' ], post.changed
240 post.content = 'quux'
241 assert_member 'subject', post.changed
242 assert_member 'content', post.changed
243 end
244
245 test 'change attribute on globalized model after locale switching' do
246 post = Post.create :subject => 'foo', :content => 'bar'
247 assert_equal [], post.changed
248 post.subject = 'baz'
249 I18n.locale = :de
250 assert_equal [ 'subject' ], post.changed
251 end
252
253 test 'fallbacks with lots of locale switching' do
254 I18n.fallbacks.map :'de-DE' => [ :'en-US' ]
255 post = Post.create :subject => 'foo'
256
257 I18n.locale = :'de-DE'
258 assert_equal 'foo', post.subject
259
260 I18n.locale = :'en-US'
261 post.update_attribute :subject, 'bar'
262
263 I18n.locale = :'de-DE'
264 assert_equal 'bar', post.subject
265 end
266
267 test 'reload' do
268 post = Post.create :subject => 'foo', :content => 'bar'
269 post.subject = 'baz'
270 assert_equal 'foo', post.reload.subject
271 end
272
273 test 'complex writing and stashing' do
274 post = Post.create :subject => 'foo', :content => 'bar'
275 post.subject = nil
276 assert_nil post.subject
277 assert !post.valid?
278 end
279
280 test 'translated class locale setting' do
281 assert ActiveRecord::Base.respond_to?(:locale)
282 assert_equal :'en-US', I18n.locale
283 assert_equal :'en-US', ActiveRecord::Base.locale
284 I18n.locale = :de
285 assert_equal :de, I18n.locale
286 assert_equal :de, ActiveRecord::Base.locale
287 ActiveRecord::Base.locale = :es
288 assert_equal :de, I18n.locale
289 assert_equal :es, ActiveRecord::Base.locale
290 I18n.locale = :fr
291 assert_equal :fr, I18n.locale
292 assert_equal :es, ActiveRecord::Base.locale
293 end
294
295 test "untranslated class responds to locale" do
296 assert Blog.respond_to?(:locale)
297 end
298
299 test "to ensure locales in different classes are the same" do
300 ActiveRecord::Base.locale = :de
301 assert_equal :de, ActiveRecord::Base.locale
302 assert_equal :de, Parent.locale
303 Parent.locale = :es
304 assert_equal :es, ActiveRecord::Base.locale
305 assert_equal :es, Parent.locale
306 end
307
308 test "attribute saving goes by content locale and not global locale" do
309 ActiveRecord::Base.locale = :de
310 assert_equal :'en-US', I18n.locale
311 Post.create :subject => 'foo'
312 assert_equal :de, Post.first.globalize_translations.first.locale
313 end
314
315 test "attribute loading goes by content locale and not global locale" do
316 post = Post.create :subject => 'foo'
317 assert_equal :'en-US', ActiveRecord::Base.locale
318 ActiveRecord::Base.locale = :de
319 assert_equal :'en-US', I18n.locale
320 post.update_attribute :subject, 'foo [de]'
321 assert_equal 'foo [de]', Post.first.subject
322 ActiveRecord::Base.locale = :'en-US'
323 assert_equal 'foo', Post.first.subject
324 end
325
326 test "access content locale before setting" do
327 Globalize::Model::ActiveRecord::Translated::ActMethods.class_eval "remove_class_variable(:@@locale)"
328 assert_nothing_raised { ActiveRecord::Base.locale }
329 end
330
331 test "translated_locales" do
332 Post.locale = :de
333 post = Post.create :subject => 'foo'
334 Post.locale = :es
335 post.update_attribute :subject, 'bar'
336 Post.locale = :fr
337 post.update_attribute :subject, 'baz'
338 assert_equal [ :de, :es, :fr ], post.translated_locales
339 assert_equal [ :de, :es, :fr ], Post.first.translated_locales
340 end
341
342 test "including globalize_translations" do
343 I18n.locale = :de
344 Post.create :subject => "Foo1", :content => "Bar1"
345 Post.create :subject => "Foo2", :content => "Bar2"
346
347 class << Post
348 def tranlsations_included
349 self.all(:include => :globalize_translations)
350 end
351 end
352
353 default = Post.all.map {|x| [x.subject, x.content]}
354 with_include = Post.tranlsations_included.map {|x| [x.subject, x.content]}
355 assert_equal default, with_include
356 end
357
358 test "setting multiple translations at once with options hash" do
359 Post.locale = :de
360 post = Post.create :subject => "foo1", :content => "foo1"
361 Post.locale = :en
362 post.update_attributes( :subject => "bar1", :content => "bar1" )
363
364 options = { :de => {:subject => "foo2", :content => "foo2"},
365 :en => {:subject => "bar2", :content => "bar2"} }
366 post.set_translations options
367 post.reload
368
369 assert ["bar2", "bar2"], [post.subject, post.content]
370 Post.locale = :de
371 assert ["foo2", "foo2"], [post.subject, post.content]
372 end
373
374 test "setting only one translation with set_translations" do
375 Post.locale = :de
376 post = Post.create :subject => "foo1", :content => "foo1"
377 Post.locale = :en
378 post.update_attributes( :subject => "bar1", :content => "bar1" )
379
380 options = { :en => {:subject => "bar2", :content => "bar2"} }
381 post.set_translations options
382 post.reload
383
384 assert ["bar2", "bar2"], [post.subject, post.content]
385 Post.locale = :de
386 assert ["foo1", "foo1"], [post.subject, post.content]
387 end
388
389 test "setting only selected attributes with set_translations" do
390 Post.locale = :de
391 post = Post.create :subject => "foo1", :content => "foo1"
392 Post.locale = :en
393 post.update_attributes( :subject => "bar1", :content => "bar1" )
394
395 options = { :de => {:content => "foo2"}, :en => {:subject => "bar2"} }
396 post.set_translations options
397 post.reload
398
399 assert ["bar2", "bar1"], [post.subject, post.content]
400 Post.locale = :de
401 assert ["foo1", "foo2"], [post.subject, post.content]
402 end
403
404 test "setting invalid attributes raises ArgumentError" do
405 Post.locale = :de
406 post = Post.create :subject => "foo1", :content => "foo1"
407 Post.locale = :en
408 post.update_attributes( :subject => "bar1", :content => "bar1" )
409
410 options = { :de => {:fake => "foo2"} }
411 exception = assert_raise(ActiveRecord::UnknownAttributeError) do
412 post.set_translations options
413 end
414 assert_equal "unknown attribute: fake", exception.message
415 end
416
417 test "reload accepting find options" do
418 p = Post.create :subject => "Foo", :content => "Bar"
419 assert p.reload(:readonly => true, :lock => true)
420 assert_raise(ArgumentError) { p.reload(:foo => :bar) }
421 end
422
423 test "dependent destroy of translation" do
424 p = Post.create :subject => "Foo", :content => "Bar"
425 assert_equal 1, PostTranslation.count
426 p.destroy
427 assert_equal 0, PostTranslation.count
428 end
429
430 test "translating subclass of untranslated comment model" do
431 translated_comment = TranslatedComment.create(:post => @post)
432 assert_nothing_raised { translated_comment.globalize_translations }
433 end
434
435 test "modifiying translated comments works as expected" do
436 I18n.locale = :en
437 translated_comment = TranslatedComment.create(:post => @post, :content => 'foo')
438 assert_equal 'foo', translated_comment.content
439
440 I18n.locale = :de
441 translated_comment.content = 'bar'
442 assert translated_comment.save
443 assert_equal 'bar', translated_comment.content
444
445 I18n.locale = :en
446 assert_equal 'foo', translated_comment.content
447
448 assert_equal 2, translated_comment.globalize_translations.size
449 end
450
451 test "can create a proxy class for a namespaced model" do
452 module Foo
453 module Bar
454 class Baz < ActiveRecord::Base
455 translates :bumm
456 end
457 end
458 end
459 end
460
461 test "attribute translated before type cast" do
462 Post.locale = :en
463 post = Post.create :subject => 'foo', :content => 'bar'
464 Post.locale = :de
465 post.update_attribute :subject, "German foo"
466 assert_equal 'German foo', post.subject_before_type_cast
467 Post.locale = :en
468 assert_equal 'foo', post.subject_before_type_cast
469 end
470end
471
472# TODO should validate_presence_of take fallbacks into account? maybe we need
473# an extra validation call, or more options for validate_presence_of.
474# TODO error checking for fields that exist in main table, don't exist in
475# proxy table, aren't strings or text
476#
477# TODO allow finding by translated attributes in conditions?
478# TODO generate advanced dynamic finders?
diff --git a/vendor/plugins/globalize2/test/test_helper.rb b/vendor/plugins/globalize2/test/test_helper.rb
index 3a1c8c4..195907d 100644
--- a/vendor/plugins/globalize2/test/test_helper.rb
+++ b/vendor/plugins/globalize2/test/test_helper.rb
@@ -1,28 +1,41 @@
1$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
2
1require 'rubygems' 3require 'rubygems'
2require 'test/unit' 4require 'test/unit'
5require 'active_record'
3require 'active_support' 6require 'active_support'
4require 'active_support/test_case' 7require 'active_support/test_case'
5require 'mocha' 8require 'mocha'
9require 'globalize'
10require 'validation_reflection'
6 11
7$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' ) 12config = { :adapter => 'sqlite3', :database => ':memory:' }
13ActiveRecord::Base.establish_connection(config)
8 14
9class ActiveSupport::TestCase 15class ActiveSupport::TestCase
10 def reset_db!( schema_path ) 16 def reset_db!(schema_path = nil)
11 ::ActiveRecord::Migration.verbose = false # Quiet down the migration engine 17 schema_path ||= File.expand_path(File.dirname(__FILE__) + '/data/schema.rb')
12 ::ActiveRecord::Base.establish_connection({ 18 ActiveRecord::Migration.verbose = false
13 :adapter => 'sqlite3', 19 ActiveRecord::Base.silence { load(schema_path) }
14 :database => ':memory:'
15 })
16 ::ActiveRecord::Base.silence do
17 load schema_path
18 end
19 end 20 end
20 21
21 def assert_member(item, arr) 22 def assert_member(item, array)
22 assert_block "Item #{item} is not in array #{arr}" do 23 assert_block "Item #{item} is not in array #{array}" do
23 arr.member? item 24 array.member?(item)
24 end 25 end
25 end 26 end
27
28 def assert_belongs_to(model, associated)
29 assert model.reflect_on_all_associations(:belongs_to).detect { |association|
30 association.name.to_s == associated.to_s
31 }
32 end
33
34 def assert_has_many(model, associated)
35 assert model.reflect_on_all_associations(:has_many).detect { |association|
36 association.name.to_s == associated.to_s
37 }
38 end
26end 39end
27 40
28module ActiveRecord 41module ActiveRecord
@@ -33,4 +46,31 @@ module ActiveRecord
33 end 46 end
34 end 47 end
35 end 48 end
36end \ No newline at end of file 49end
50
51# module ActiveRecord
52# class BaseWithoutTable < Base
53# self.abstract_class = true
54#
55# def create_or_update
56# errors.empty?
57# end
58#
59# class << self
60# def columns()
61# @columns ||= []
62# end
63#
64# def column(name, sql_type = nil, default = nil, null = true)
65# columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
66# reset_column_information
67# end
68#
69# # Do not reset @columns
70# def reset_column_information
71# read_methods.each { |name| undef_method(name) }
72# @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil
73# end
74# end
75# end
76# end \ No newline at end of file
diff --git a/vendor/plugins/globalize2/test/translation_test.rb b/vendor/plugins/globalize2/test/translation_test.rb
deleted file mode 100644
index 4b52bb1..0000000
--- a/vendor/plugins/globalize2/test/translation_test.rb
+++ /dev/null
@@ -1,54 +0,0 @@
1require File.join( File.dirname(__FILE__), 'test_helper' )
2require 'globalize/translation'
3
4class TranslationTest < ActiveSupport::TestCase
5 include Globalize
6
7 def setup
8 @translation = Translation::Static.new 'foo', :locale => :'en-US'
9 end
10
11 test "responds to fallback?" do
12 assert @translation.respond_to?( :fallback? )
13 end
14
15 test "returns true when :locale and :requested_locale are not equal" do
16 @translation.requested_locale = :'de-DE'
17 assert @translation.fallback?
18 end
19
20 test "returns false when :locale and :requested_locale are equal" do
21 @translation.requested_locale = :'en-US'
22 assert !@translation.fallback?
23 end
24
25 test "has the attribute :locale" do
26 assert @translation.respond_to?( :locale )
27 end
28
29 test "has the attribute :requested_locale" do
30 assert @translation.respond_to?( :requested_locale )
31 end
32
33 test "has the attribute :options" do
34 assert @translation.respond_to?( :options )
35 end
36
37 test "has the attribute :plural_key" do
38 assert @translation.respond_to?( :plural_key )
39 end
40
41 test "has the attribute :original" do
42 assert @translation.respond_to?( :original )
43 end
44
45 test "Translation::Attribute has the attribute :locale" do
46 translation = Translation::Attribute.new 'foo'
47 assert translation.respond_to?( :locale )
48 end
49
50 test "Translation::Attribute has the attribute :requested_locale" do
51 translation = Translation::Attribute.new 'foo'
52 assert translation.respond_to?( :requested_locale )
53 end
54end