activesupport 2.3.6.pre → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- data/CHANGELOG +9 -5
- data/lib/active_support/buffered_logger.rb +1 -1
- data/lib/active_support/cache/memory_store.rb +7 -1
- data/lib/active_support/cache/strategy/local_cache.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +1 -1
- data/lib/active_support/core_ext/array/random_access.rb +11 -1
- data/lib/active_support/core_ext/class/attribute_accessors.rb +35 -28
- data/lib/active_support/core_ext/date/calculations.rb +14 -4
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
- data/lib/active_support/core_ext/module/aliasing.rb +1 -1
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attribute_accessors.rb +33 -26
- data/lib/active_support/core_ext/module/synchronization.rb +1 -1
- data/lib/active_support/core_ext/object/blank.rb +20 -2
- data/lib/active_support/core_ext/string/output_safety.rb +10 -2
- data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -4
- data/lib/active_support/core_ext/time.rb +8 -4
- data/lib/active_support/core_ext/time/calculations.rb +11 -2
- data/lib/active_support/deprecation.rb +3 -2
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector.rb +4 -1
- data/lib/active_support/json/backends/yaml.rb +10 -7
- data/lib/active_support/json/decoding.rb +1 -1
- data/lib/active_support/memoizable.rb +1 -1
- data/lib/active_support/multibyte/unicode_database.rb +2 -2
- data/lib/active_support/multibyte/utils.rb +6 -7
- data/lib/active_support/ordered_hash.rb +24 -30
- data/lib/active_support/testing/assertions.rb +14 -0
- data/lib/active_support/values/time_zone.rb +84 -76
- data/lib/active_support/vendor.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n.rb +92 -34
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend.rb +2 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record.rb +9 -13
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/missing.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/store_procs.rb +6 -6
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/translation.rb +14 -9
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/base.rb +23 -16
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/cache.rb +1 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/cascade.rb +22 -8
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/chain.rb +2 -1
- data/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb +100 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/fallbacks.rb +20 -3
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/fast.rb +14 -13
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/gettext.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/helpers.rb +4 -16
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/interpolation_compiler.rb +2 -2
- data/lib/active_support/vendor/i18n-0.3.7/i18n/backend/links.rb +34 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/metadata.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/pluralization.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/simple.rb +0 -0
- data/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/except.rb +8 -0
- data/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/slice.rb +8 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/core_ext/object/meta_class.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/core_ext/string/interpolate.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/exceptions.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/gettext.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/vendor → i18n-0.3.7/i18n/gettext}/po_parser.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/helpers.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/helpers/gettext.rb +3 -2
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/fallbacks.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/parents.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/rfc4646.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/simple.rb +0 -0
- data/lib/active_support/vendor/i18n-0.3.7/i18n/version.rb +3 -0
- metadata +42 -96
- data/lib/active_support/vendor/i18n-0.3.3/CHANGELOG.textile +0 -76
- data/lib/active_support/vendor/i18n-0.3.3/MIT-LICENSE +0 -20
- data/lib/active_support/vendor/i18n-0.3.3/README.textile +0 -81
- data/lib/active_support/vendor/i18n-0.3.3/Rakefile +0 -24
- data/lib/active_support/vendor/i18n-0.3.3/benchmark/example.yml +0 -144
- data/lib/active_support/vendor/i18n-0.3.3/benchmark/run.rb +0 -71
- data/lib/active_support/vendor/i18n-0.3.3/contributors.txt +0 -17
- data/lib/active_support/vendor/i18n-0.3.3/i18n.gemspec +0 -165
- data/lib/active_support/vendor/i18n-0.3.3/init.rb +0 -1
- data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/version.rb +0 -3
- data/lib/active_support/vendor/i18n-0.3.3/test/all.rb +0 -8
- data/lib/active_support/vendor/i18n-0.3.3/test/api/basics.rb +0 -15
- data/lib/active_support/vendor/i18n-0.3.3/test/api/defaults.rb +0 -40
- data/lib/active_support/vendor/i18n-0.3.3/test/api/interpolation.rb +0 -92
- data/lib/active_support/vendor/i18n-0.3.3/test/api/link.rb +0 -55
- data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/date.rb +0 -91
- data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/date_time.rb +0 -90
- data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/procs.rb +0 -54
- data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/time.rb +0 -84
- data/lib/active_support/vendor/i18n-0.3.3/test/api/lookup.rb +0 -45
- data/lib/active_support/vendor/i18n-0.3.3/test/api/pluralization.rb +0 -35
- data/lib/active_support/vendor/i18n-0.3.3/test/api/procs.rb +0 -40
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/active_record_test.rb +0 -29
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/all_features_test.rb +0 -40
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/cascade_test.rb +0 -31
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/chain_test.rb +0 -26
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/fallbacks_test.rb +0 -33
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/fast_test.rb +0 -31
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/pluralization_test.rb +0 -33
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/simple_test.rb +0 -21
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record/missing_test.rb +0 -60
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record_test.rb +0 -52
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/cache_test.rb +0 -72
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/cascade_test.rb +0 -66
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/chain_test.rb +0 -64
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/fallbacks_test.rb +0 -57
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/fast_test.rb +0 -50
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/helpers_test.rb +0 -26
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/interpolation_compiler_test.rb +0 -107
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/metadata_test.rb +0 -67
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/pluralization_test.rb +0 -43
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/simple_test.rb +0 -77
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/core_ext/string/interpolate_test.rb +0 -94
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/gettext/api_test.rb +0 -201
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/gettext/backend_test.rb +0 -91
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_exceptions_test.rb +0 -97
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_load_path_test.rb +0 -23
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_test.rb +0 -172
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/fallbacks_test.rb +0 -126
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/tag/rfc4646_test.rb +0 -143
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/tag/simple_test.rb +0 -33
- data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/de.po +0 -72
- data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/en.rb +0 -3
- data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/en.yml +0 -3
- data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/plurals.rb +0 -113
- data/lib/active_support/vendor/i18n-0.3.3/test/test_helper.rb +0 -100
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
3
|
-
|
4
|
-
setup_active_record
|
5
|
-
|
6
|
-
|
7
|
-
class I18nActiveRecordApiTest < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
I18n.backend = I18n::Backend::ActiveRecord.new
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
|
-
include Tests::Api::Basics
|
14
|
-
include Tests::Api::Defaults
|
15
|
-
include Tests::Api::Interpolation
|
16
|
-
include Tests::Api::Link
|
17
|
-
include Tests::Api::Lookup
|
18
|
-
include Tests::Api::Pluralization
|
19
|
-
include Tests::Api::Procs unless RUBY_VERSION >= '1.9.1'
|
20
|
-
|
21
|
-
include Tests::Api::Localization::Date
|
22
|
-
include Tests::Api::Localization::DateTime
|
23
|
-
include Tests::Api::Localization::Time
|
24
|
-
include Tests::Api::Localization::Procs unless RUBY_VERSION >= '1.9.1'
|
25
|
-
|
26
|
-
define_method "test: make sure we use an ActiveRecord backend" do
|
27
|
-
assert_equal I18n::Backend::ActiveRecord, I18n.backend.class
|
28
|
-
end
|
29
|
-
end if defined?(ActiveRecord)
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
-
|
5
|
-
class I18nAllFeaturesApiTest < Test::Unit::TestCase
|
6
|
-
class Backend
|
7
|
-
include I18n::Backend::Base
|
8
|
-
include I18n::Backend::Cache
|
9
|
-
include I18n::Backend::Metadata
|
10
|
-
include I18n::Backend::Cascade
|
11
|
-
include I18n::Backend::Fallbacks
|
12
|
-
include I18n::Backend::Pluralization
|
13
|
-
include I18n::Backend::Fast
|
14
|
-
include I18n::Backend::InterpolationCompiler
|
15
|
-
end
|
16
|
-
|
17
|
-
def setup
|
18
|
-
I18n.backend = I18n::Backend::Chain.new(Backend.new, I18n::Backend::Simple.new)
|
19
|
-
super
|
20
|
-
end
|
21
|
-
|
22
|
-
include Tests::Api::Basics
|
23
|
-
include Tests::Api::Defaults
|
24
|
-
include Tests::Api::Interpolation
|
25
|
-
include Tests::Api::Link
|
26
|
-
include Tests::Api::Lookup
|
27
|
-
include Tests::Api::Pluralization
|
28
|
-
include Tests::Api::Procs
|
29
|
-
include Tests::Api::Localization::Date
|
30
|
-
include Tests::Api::Localization::DateTime
|
31
|
-
include Tests::Api::Localization::Time
|
32
|
-
include Tests::Api::Localization::Procs
|
33
|
-
|
34
|
-
define_method "test: make sure we use a Chain backend with an all features backend" do
|
35
|
-
assert_equal I18n::Backend::Chain, I18n.backend.class
|
36
|
-
assert_equal Backend, I18n.backend.backends.first.class
|
37
|
-
end
|
38
|
-
|
39
|
-
# links: test that keys stored on one backend can link to keys stored on another backend
|
40
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
-
|
5
|
-
class I18nCascadeApiTest < Test::Unit::TestCase
|
6
|
-
class Backend
|
7
|
-
include I18n::Backend::Base
|
8
|
-
include I18n::Backend::Cascade
|
9
|
-
end
|
10
|
-
|
11
|
-
def setup
|
12
|
-
I18n.backend = Backend.new
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
include Tests::Api::Basics
|
17
|
-
include Tests::Api::Defaults
|
18
|
-
include Tests::Api::Interpolation
|
19
|
-
include Tests::Api::Link
|
20
|
-
include Tests::Api::Lookup
|
21
|
-
include Tests::Api::Pluralization
|
22
|
-
include Tests::Api::Procs
|
23
|
-
include Tests::Api::Localization::Date
|
24
|
-
include Tests::Api::Localization::DateTime
|
25
|
-
include Tests::Api::Localization::Time
|
26
|
-
include Tests::Api::Localization::Procs
|
27
|
-
|
28
|
-
define_method "test: make sure we use a backend with Cascade included" do
|
29
|
-
assert_equal Backend, I18n.backend.class
|
30
|
-
end
|
31
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
-
|
5
|
-
class I18nApiChainTest < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
super
|
8
|
-
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
|
9
|
-
end
|
10
|
-
|
11
|
-
include Tests::Api::Basics
|
12
|
-
include Tests::Api::Defaults
|
13
|
-
include Tests::Api::Interpolation
|
14
|
-
include Tests::Api::Link
|
15
|
-
include Tests::Api::Lookup
|
16
|
-
include Tests::Api::Pluralization
|
17
|
-
include Tests::Api::Procs
|
18
|
-
include Tests::Api::Localization::Date
|
19
|
-
include Tests::Api::Localization::DateTime
|
20
|
-
include Tests::Api::Localization::Time
|
21
|
-
include Tests::Api::Localization::Procs
|
22
|
-
|
23
|
-
define_method "test: make sure we use the Chain backend" do
|
24
|
-
assert_equal I18n::Backend::Chain, I18n.backend.class
|
25
|
-
end
|
26
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
-
|
5
|
-
class I18nFallbacksApiTest < Test::Unit::TestCase
|
6
|
-
class Backend
|
7
|
-
include I18n::Backend::Base
|
8
|
-
include I18n::Backend::Fallbacks
|
9
|
-
end
|
10
|
-
|
11
|
-
def setup
|
12
|
-
I18n.backend = Backend.new
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
include Tests::Api::Basics
|
17
|
-
include Tests::Api::Defaults
|
18
|
-
include Tests::Api::Interpolation
|
19
|
-
include Tests::Api::Link
|
20
|
-
include Tests::Api::Lookup
|
21
|
-
include Tests::Api::Pluralization
|
22
|
-
include Tests::Api::Procs
|
23
|
-
include Tests::Api::Localization::Date
|
24
|
-
include Tests::Api::Localization::DateTime
|
25
|
-
include Tests::Api::Localization::Time
|
26
|
-
include Tests::Api::Localization::Procs
|
27
|
-
|
28
|
-
define_method "test: make sure we use a backend with Fallbacks included" do
|
29
|
-
assert_equal Backend, I18n.backend.class
|
30
|
-
end
|
31
|
-
|
32
|
-
# links: test that keys stored on one backend can link to keys stored on another backend
|
33
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
-
|
5
|
-
class I18nFastBackendApiTest < Test::Unit::TestCase
|
6
|
-
include Tests::Api::Basics
|
7
|
-
include Tests::Api::Defaults
|
8
|
-
include Tests::Api::Interpolation
|
9
|
-
include Tests::Api::Link
|
10
|
-
include Tests::Api::Lookup
|
11
|
-
include Tests::Api::Pluralization
|
12
|
-
include Tests::Api::Procs
|
13
|
-
include Tests::Api::Localization::Date
|
14
|
-
include Tests::Api::Localization::DateTime
|
15
|
-
include Tests::Api::Localization::Time
|
16
|
-
include Tests::Api::Localization::Procs
|
17
|
-
|
18
|
-
class FastBackend
|
19
|
-
include I18n::Backend::Base
|
20
|
-
include I18n::Backend::Fast
|
21
|
-
end
|
22
|
-
|
23
|
-
def setup
|
24
|
-
I18n.backend = FastBackend.new
|
25
|
-
super
|
26
|
-
end
|
27
|
-
|
28
|
-
define_method "test: make sure we use the FastBackend backend" do
|
29
|
-
assert_equal FastBackend, I18n.backend.class
|
30
|
-
end
|
31
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
-
|
5
|
-
class I18nPluralizationApiTest < Test::Unit::TestCase
|
6
|
-
class Backend
|
7
|
-
include I18n::Backend::Base
|
8
|
-
include I18n::Backend::Pluralization
|
9
|
-
end
|
10
|
-
|
11
|
-
def setup
|
12
|
-
I18n.backend = Backend.new
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
include Tests::Api::Basics
|
17
|
-
include Tests::Api::Defaults
|
18
|
-
include Tests::Api::Interpolation
|
19
|
-
include Tests::Api::Link
|
20
|
-
include Tests::Api::Lookup
|
21
|
-
include Tests::Api::Pluralization
|
22
|
-
include Tests::Api::Procs
|
23
|
-
include Tests::Api::Localization::Date
|
24
|
-
include Tests::Api::Localization::DateTime
|
25
|
-
include Tests::Api::Localization::Time
|
26
|
-
include Tests::Api::Localization::Procs
|
27
|
-
|
28
|
-
define_method "test: make sure we use a backend with Pluralization included" do
|
29
|
-
assert_equal Backend, I18n.backend.class
|
30
|
-
end
|
31
|
-
|
32
|
-
# links: test that keys stored on one backend can link to keys stored on another backend
|
33
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
-
|
5
|
-
class I18nSimpleBackendApiTest < Test::Unit::TestCase
|
6
|
-
include Tests::Api::Basics
|
7
|
-
include Tests::Api::Defaults
|
8
|
-
include Tests::Api::Interpolation
|
9
|
-
include Tests::Api::Link
|
10
|
-
include Tests::Api::Lookup
|
11
|
-
include Tests::Api::Pluralization
|
12
|
-
include Tests::Api::Procs
|
13
|
-
include Tests::Api::Localization::Date
|
14
|
-
include Tests::Api::Localization::DateTime
|
15
|
-
include Tests::Api::Localization::Time
|
16
|
-
include Tests::Api::Localization::Procs
|
17
|
-
|
18
|
-
define_method "test: make sure we use the Simple backend" do
|
19
|
-
assert_equal I18n::Backend::Simple, I18n.backend.class
|
20
|
-
end
|
21
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
3
|
-
|
4
|
-
setup_active_record
|
5
|
-
|
6
|
-
class I18nActiveRecordMissingTest < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
store_translations(:en, :i18n => { :plural => { :keys => [:zero, :one, :other] } })
|
9
|
-
|
10
|
-
I18n.backend = I18n::Backend::Chain.new(I18n.backend)
|
11
|
-
I18n.backend.meta_class.send(:include, I18n::Backend::ActiveRecord::Missing)
|
12
|
-
|
13
|
-
I18n::Backend::ActiveRecord::Translation.delete_all
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_can_persist_interpolations
|
17
|
-
translation = I18n::Backend::ActiveRecord::Translation.new \
|
18
|
-
:key => 'foo',
|
19
|
-
:value => 'bar',
|
20
|
-
:locale => :en
|
21
|
-
|
22
|
-
translation.interpolations = %w{ count name }
|
23
|
-
translation.save
|
24
|
-
|
25
|
-
assert translation.valid?
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_lookup_persists_key
|
29
|
-
I18n.t('foo.bar.baz')
|
30
|
-
|
31
|
-
assert_equal 1, I18n::Backend::ActiveRecord::Translation.count
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_lookup_does_not_persist_key_twice
|
35
|
-
2.times { I18n.t('foo.bar.baz') }
|
36
|
-
|
37
|
-
assert_equal 1, I18n::Backend::ActiveRecord::Translation.count
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_persists_interpolation_keys_when_looked_up_directly
|
41
|
-
I18n.t('foo.bar.baz', :cow => "lucy" ) # creates stub translation.
|
42
|
-
|
43
|
-
translation_stub = I18n::Backend::ActiveRecord::Translation.locale(:en).lookup('foo.bar.baz').first
|
44
|
-
assert translation_stub.interpolates?(:cow)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_creates_one_stub_per_pluralization
|
48
|
-
I18n.t('foo', :count => 999)
|
49
|
-
|
50
|
-
translations = I18n::Backend::ActiveRecord::Translation.locale(:en).find_all_by_key %w{ foo.zero foo.one foo.other }
|
51
|
-
assert_equal 3, translations.length
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_creates_no_stub_for_base_key_in_pluralization
|
55
|
-
I18n.t('foo', :count => 999)
|
56
|
-
|
57
|
-
translations = I18n::Backend::ActiveRecord::Translation.locale(:en).find_by_key %w{ foo.zero foo.one foo.other }
|
58
|
-
assert !I18n::Backend::ActiveRecord::Translation.locale(:en).find_by_key("foo")
|
59
|
-
end
|
60
|
-
end if defined?(ActiveRecord)
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
3
|
-
|
4
|
-
setup_active_record
|
5
|
-
|
6
|
-
|
7
|
-
class I18nBackendActiveRecordTest < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
I18n.backend = I18n::Backend::ActiveRecord.new
|
10
|
-
store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' })
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
I18n::Backend::ActiveRecord::Translation.destroy_all
|
15
|
-
super
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_store_translations_does_not_allow_ambigous_keys_1
|
19
|
-
I18n::Backend::ActiveRecord::Translation.delete_all
|
20
|
-
I18n.backend.store_translations(:en, :foo => 'foo')
|
21
|
-
I18n.backend.store_translations(:en, :foo => { :bar => 'bar' })
|
22
|
-
I18n.backend.store_translations(:en, :foo => { :baz => 'baz' })
|
23
|
-
|
24
|
-
translations = I18n::Backend::ActiveRecord::Translation.locale(:en).lookup('foo', '.').all
|
25
|
-
assert_equal %w(bar baz), translations.map(&:value)
|
26
|
-
|
27
|
-
assert_equal({ :bar => 'bar', :baz => 'baz' }, I18n.t(:foo))
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_store_translations_does_not_allow_ambigous_keys_2
|
31
|
-
I18n::Backend::ActiveRecord::Translation.delete_all
|
32
|
-
I18n.backend.store_translations(:en, :foo => { :bar => 'bar' })
|
33
|
-
I18n.backend.store_translations(:en, :foo => { :baz => 'baz' })
|
34
|
-
I18n.backend.store_translations(:en, :foo => 'foo')
|
35
|
-
|
36
|
-
translations = I18n::Backend::ActiveRecord::Translation.locale(:en).lookup('foo', '.').all
|
37
|
-
assert_equal %w(foo), translations.map(&:value)
|
38
|
-
|
39
|
-
assert_equal 'foo', I18n.t(:foo)
|
40
|
-
end
|
41
|
-
|
42
|
-
with_mocha do
|
43
|
-
def test_missing_translations_table_does_not_cause_available_locales_to_error
|
44
|
-
I18n::Backend::ActiveRecord::Translation.expects(:available_locales).raises(::ActiveRecord::StatementInvalid)
|
45
|
-
assert_equal [], I18n.backend.available_locales
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_expand_keys
|
50
|
-
assert_equal %w(foo foo.bar foo.bar.baz), I18n.backend.send(:expand_keys, :'foo.bar.baz')
|
51
|
-
end
|
52
|
-
end if defined?(ActiveRecord)
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
4
|
-
require 'i18n/backend/cache'
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'active_support'
|
8
|
-
rescue LoadError
|
9
|
-
$stderr.puts "Skipping cache tests using ActiveSupport"
|
10
|
-
else
|
11
|
-
|
12
|
-
class I18nBackendCacheTest < Test::Unit::TestCase
|
13
|
-
class Backend
|
14
|
-
include I18n::Backend::Base
|
15
|
-
include I18n::Backend::Cache
|
16
|
-
end
|
17
|
-
|
18
|
-
def setup
|
19
|
-
I18n.backend = Backend.new
|
20
|
-
super
|
21
|
-
I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store)
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
I18n.cache_store = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_uses_cache
|
29
|
-
assert I18n.cache_store.is_a?(ActiveSupport::Cache::MemoryStore)
|
30
|
-
end
|
31
|
-
|
32
|
-
with_mocha do
|
33
|
-
define_method "test translate hits the backend and caches the response" do
|
34
|
-
I18n.backend.expects(:lookup).returns('Foo')
|
35
|
-
assert_equal 'Foo', I18n.t(:foo)
|
36
|
-
|
37
|
-
I18n.backend.expects(:lookup).never
|
38
|
-
assert_equal 'Foo', I18n.t(:foo)
|
39
|
-
|
40
|
-
I18n.backend.expects(:lookup).returns('Bar')
|
41
|
-
assert_equal 'Bar', I18n.t(:bar)
|
42
|
-
end
|
43
|
-
|
44
|
-
define_method "test still raises MissingTranslationData but also caches it" do
|
45
|
-
I18n.backend.expects(:lookup).returns(nil)
|
46
|
-
assert_raises(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
|
47
|
-
|
48
|
-
I18n.backend.expects(:lookup).never
|
49
|
-
assert_raises(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
define_method "test uses 'i18n' as a cache key namespace by default" do
|
54
|
-
assert_equal 0, I18n.backend.send(:cache_key, :foo).index('i18n')
|
55
|
-
end
|
56
|
-
|
57
|
-
define_method "test adds a custom cache key namespace" do
|
58
|
-
with_cache_namespace('bar') do
|
59
|
-
assert_equal 0, I18n.backend.send(:cache_key, :foo).index('i18n-bar')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
protected
|
64
|
-
|
65
|
-
def with_cache_namespace(namespace)
|
66
|
-
I18n.cache_namespace = namespace
|
67
|
-
yield
|
68
|
-
I18n.cache_namespace = nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end # AS cache check
|