diff options
| author | hukl <hukl@eight.local> | 2009-02-07 15:50:40 +0100 |
|---|---|---|
| committer | hukl <hukl@eight.local> | 2009-02-07 15:50:40 +0100 |
| commit | 36a2f1f3c085dd81171cf7d8220770d4ff921ab3 (patch) | |
| tree | 5ded15331b192bf428af4c94d46d1abb28ef0690 /vendor/plugins/globalize2/test/load_path_test.rb | |
| parent | ce9645d0092d42c7bf8781378181ffbd4ff3d088 (diff) | |
added globalize2 plugin as well as some modifications
which use the new translation facilities.
backend mostly.
Diffstat (limited to 'vendor/plugins/globalize2/test/load_path_test.rb')
| -rw-r--r-- | vendor/plugins/globalize2/test/load_path_test.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/plugins/globalize2/test/load_path_test.rb b/vendor/plugins/globalize2/test/load_path_test.rb new file mode 100644 index 0000000..ff009b3 --- /dev/null +++ b/vendor/plugins/globalize2/test/load_path_test.rb | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | require File.join( File.dirname(__FILE__), 'test_helper' ) | ||
| 2 | require 'globalize/load_path' | ||
| 3 | |||
| 4 | class 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 | |||
| 49 | end | ||
