locale_rails 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4 -0
- data/Rakefile +4 -4
- data/lib/locale_rails/action_view.rb +15 -4
- data/lib/locale_rails/version.rb +1 -1
- data/test/README +243 -0
- data/test/Rakefile +10 -0
- data/test/app/controllers/application_controller.rb +10 -0
- data/test/app/controllers/articles_controller.rb +8 -0
- data/test/app/helpers/application_helper.rb +3 -0
- data/test/app/views/articles/index.html.erb +1 -0
- data/test/app/views/articles/index_de.html.erb +1 -0
- data/test/app/views/articles/index_fr_FR.html.erb +1 -0
- data/test/app/views/articles/index_ja.html.erb +1 -0
- data/test/app/views/articles/list.html.erb +1 -0
- data/test/config/boot.rb +110 -0
- data/test/config/database.yml +22 -0
- data/test/config/environment.rb +42 -0
- data/test/config/environments/development.rb +17 -0
- data/test/config/environments/production.rb +28 -0
- data/test/config/environments/test.rb +35 -0
- data/test/config/initializers/backtrace_silencers.rb +7 -0
- data/test/config/initializers/inflections.rb +10 -0
- data/test/config/initializers/mime_types.rb +5 -0
- data/test/config/initializers/new_rails_defaults.rb +19 -0
- data/test/config/initializers/session_store.rb +15 -0
- data/test/config/locales/en.yml +5 -0
- data/test/config/routes.rb +45 -0
- data/test/db/schema.rb +0 -0
- data/test/doc/README_FOR_APP +2 -0
- data/test/public/404.html +30 -0
- data/test/public/422.html +30 -0
- data/test/public/500.html +30 -0
- data/test/public/favicon.ico +0 -0
- data/test/public/images/rails.png +0 -0
- data/test/public/index.html +275 -0
- data/test/public/javascripts/application.js +2 -0
- data/test/public/javascripts/controls.js +963 -0
- data/test/public/javascripts/dragdrop.js +973 -0
- data/test/public/javascripts/effects.js +1128 -0
- data/test/public/javascripts/prototype.js +4320 -0
- data/test/public/robots.txt +5 -0
- data/test/script/about +4 -0
- data/test/script/console +3 -0
- data/test/script/dbconsole +3 -0
- data/test/script/destroy +3 -0
- data/test/script/generate +3 -0
- data/test/script/performance/benchmarker +3 -0
- data/test/script/performance/profiler +3 -0
- data/test/script/plugin +3 -0
- data/test/script/runner +3 -0
- data/test/script/server +3 -0
- data/test/test/functional/articles_controller_test.rb +135 -0
- data/test/test/performance/browsing_test.rb +9 -0
- data/test/test/test_helper.rb +38 -0
- metadata +73 -3
data/test/script/about
ADDED
data/test/script/console
ADDED
data/test/script/destroy
ADDED
data/test/script/plugin
ADDED
data/test/script/runner
ADDED
data/test/script/server
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class ArticlesControllerTest < ActionController::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR;ja;q=0.7,de;q=0.3"
|
8
|
+
Locale.clear
|
9
|
+
end
|
10
|
+
|
11
|
+
test "localized template with accept_language" do
|
12
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "en-US"
|
13
|
+
get :index
|
14
|
+
assert_equal "index.html.erb", @response.body.chop
|
15
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "ja-jp"
|
16
|
+
get :index, :lang => "ja"
|
17
|
+
assert_equal "index_ja.html.erb", @response.body.chop
|
18
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR"
|
19
|
+
get :index
|
20
|
+
assert_equal "index_fr_FR.html.erb", @response.body.chop
|
21
|
+
|
22
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "fr"
|
23
|
+
get :index
|
24
|
+
assert_equal "index.html.erb", @response.body.chop
|
25
|
+
end
|
26
|
+
|
27
|
+
test "localized template with accept_languages" do
|
28
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
|
29
|
+
get :index
|
30
|
+
assert_equal "index.html.erb", @response.body.chop
|
31
|
+
|
32
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR,ja;q=0.7,de;q=0.3"
|
33
|
+
get :index
|
34
|
+
assert_equal "index_fr_FR.html.erb", @response.body.chop
|
35
|
+
|
36
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "ja;q=0.7,de;q=0.3"
|
37
|
+
get :index
|
38
|
+
assert_equal "index_ja.html.erb", @response.body.chop
|
39
|
+
end
|
40
|
+
|
41
|
+
test "localized template with query string" do
|
42
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
|
43
|
+
get :index, :lang => "ja"
|
44
|
+
assert_equal "index_ja.html.erb", @response.body.chop
|
45
|
+
|
46
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR,ja;q=0.7,de;q=0.3"
|
47
|
+
get :index, :lang => "ja"
|
48
|
+
assert_equal "index_ja.html.erb", @response.body.chop
|
49
|
+
|
50
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "ja;q=0.7,de;q=0.3"
|
51
|
+
get :index, :lang => "en"
|
52
|
+
assert_equal "index.html.erb", @response.body.chop
|
53
|
+
end
|
54
|
+
|
55
|
+
test "localized template with accept_languages and default is de" do
|
56
|
+
# index_de.html.erb is existed.
|
57
|
+
Locale.default = "de"
|
58
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
|
59
|
+
get :index
|
60
|
+
assert_equal "index_ja.html.erb", @response.body.chop
|
61
|
+
|
62
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR,ja;q=0.7,de;q=0.3"
|
63
|
+
get :index
|
64
|
+
assert_equal "index_fr_FR.html.erb", @response.body.chop
|
65
|
+
|
66
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "ja;q=0.7,de;q=0.3"
|
67
|
+
get :index
|
68
|
+
assert_equal "index_ja.html.erb", @response.body.chop
|
69
|
+
|
70
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "de;q=0.7,en;q=0.3"
|
71
|
+
get :index
|
72
|
+
assert_equal "index_de.html.erb", @response.body.chop
|
73
|
+
|
74
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "zh"
|
75
|
+
get :index
|
76
|
+
assert_equal "index_de.html.erb", @response.body.chop
|
77
|
+
Locale.default = nil
|
78
|
+
end
|
79
|
+
|
80
|
+
test "localized template with accept_languages and default is zh" do
|
81
|
+
# index_zh.html.erb is not existed.
|
82
|
+
Locale.default = "zh"
|
83
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
|
84
|
+
get :index
|
85
|
+
assert_equal "index_ja.html.erb", @response.body.chop
|
86
|
+
|
87
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "fr-FR,ja;q=0.7,de;q=0.3"
|
88
|
+
get :index
|
89
|
+
assert_equal "index_fr_FR.html.erb", @response.body.chop
|
90
|
+
|
91
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "ja;q=0.7,de;q=0.3"
|
92
|
+
get :index
|
93
|
+
assert_equal "index_ja.html.erb", @response.body.chop
|
94
|
+
|
95
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "en;q=0.7;nl;q=0.3"
|
96
|
+
get :index
|
97
|
+
assert_equal "index.html.erb", @response.body.chop
|
98
|
+
|
99
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "zh"
|
100
|
+
get :index
|
101
|
+
assert_equal "index.html.erb", @response.body.chop
|
102
|
+
Locale.default = nil
|
103
|
+
end
|
104
|
+
|
105
|
+
test "list.html.erb should be cached" do
|
106
|
+
cache_path = RAILS_ROOT + "/tmp/cache/views"
|
107
|
+
FileUtils.rm_rf cache_path
|
108
|
+
@request.env["HTTP_ACCEPT_LANGUAGE"] = "en,ja;q=0.7,de;q=0.3"
|
109
|
+
get :list
|
110
|
+
assert_equal "list:en", @response.body.chop
|
111
|
+
|
112
|
+
path = Dir.glob(cache_path + "/**/list_en.cache")[0]
|
113
|
+
st = File.stat(path)
|
114
|
+
last_modified_en = [st.ctime, st.mtime]
|
115
|
+
|
116
|
+
get :list, :lang => "ja"
|
117
|
+
assert_equal "list:ja", @response.body.chop
|
118
|
+
|
119
|
+
path = Dir.glob(cache_path + "/**/list_ja.cache")[0]
|
120
|
+
st = File.stat(path)
|
121
|
+
last_modified_ja = [st.ctime, st.mtime]
|
122
|
+
|
123
|
+
get :list
|
124
|
+
st = File.stat(path)
|
125
|
+
assert_equal last_modified_en, [st.ctime, st.mtime]
|
126
|
+
assert_equal "list:en", @response.body.chop
|
127
|
+
|
128
|
+
get :list, :lang => "ja"
|
129
|
+
st = File.stat(path)
|
130
|
+
assert_equal last_modified_ja, [st.ctime, st.mtime]
|
131
|
+
assert_equal "list:ja", @response.body.chop
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
3
|
+
require 'test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Transactional fixtures accelerate your tests by wrapping each test method
|
7
|
+
# in a transaction that's rolled back on completion. This ensures that the
|
8
|
+
# test database remains unchanged so your fixtures don't have to be reloaded
|
9
|
+
# between every test method. Fewer database queries means faster tests.
|
10
|
+
#
|
11
|
+
# Read Mike Clark's excellent walkthrough at
|
12
|
+
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
13
|
+
#
|
14
|
+
# Every Active Record database supports transactions except MyISAM tables
|
15
|
+
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
16
|
+
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
17
|
+
# is recommended.
|
18
|
+
#
|
19
|
+
# The only drawback to using transactional fixtures is when you actually
|
20
|
+
# need to test transactions. Since your test is bracketed by a transaction,
|
21
|
+
# any transactions started in your code will be automatically rolled back.
|
22
|
+
self.use_transactional_fixtures = true
|
23
|
+
|
24
|
+
# Instantiated fixtures are slow, but give you @david where otherwise you
|
25
|
+
# would need people(:david). If you don't want to migrate your existing
|
26
|
+
# test cases which use the @david style and don't mind the speed hit (each
|
27
|
+
# instantiated fixtures translates to a database query per test method),
|
28
|
+
# then set this back to true.
|
29
|
+
self.use_instantiated_fixtures = false
|
30
|
+
|
31
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
32
|
+
#
|
33
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
34
|
+
# -- they do not yet inherit this setting
|
35
|
+
fixtures :all
|
36
|
+
|
37
|
+
# Add more helper methods to be used by all tests here...
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locale_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masao Mutoh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-23 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.0.
|
23
|
+
version: 2.0.4
|
24
24
|
version:
|
25
25
|
description: Ruby-Locale for Ruby on Rails is the pure ruby library which provides basic functions for localization.
|
26
26
|
email: mutomasa at gmail.com
|
@@ -44,6 +44,76 @@ files:
|
|
44
44
|
- lib/locale_rails/action_view.rb
|
45
45
|
- lib/locale_rails/i18n.rb
|
46
46
|
- README.rdoc
|
47
|
+
- test
|
48
|
+
- test/script
|
49
|
+
- test/script/plugin
|
50
|
+
- test/script/about
|
51
|
+
- test/script/generate
|
52
|
+
- test/script/performance
|
53
|
+
- test/script/performance/profiler
|
54
|
+
- test/script/performance/benchmarker
|
55
|
+
- test/script/server
|
56
|
+
- test/script/console
|
57
|
+
- test/script/runner
|
58
|
+
- test/script/destroy
|
59
|
+
- test/script/dbconsole
|
60
|
+
- test/doc
|
61
|
+
- test/doc/README_FOR_APP
|
62
|
+
- test/public
|
63
|
+
- test/public/index.html
|
64
|
+
- test/public/images
|
65
|
+
- test/public/images/rails.png
|
66
|
+
- test/public/robots.txt
|
67
|
+
- test/public/favicon.ico
|
68
|
+
- test/public/500.html
|
69
|
+
- test/public/404.html
|
70
|
+
- test/public/422.html
|
71
|
+
- test/public/javascripts
|
72
|
+
- test/public/javascripts/effects.js
|
73
|
+
- test/public/javascripts/application.js
|
74
|
+
- test/public/javascripts/prototype.js
|
75
|
+
- test/public/javascripts/controls.js
|
76
|
+
- test/public/javascripts/dragdrop.js
|
77
|
+
- test/db
|
78
|
+
- test/db/schema.rb
|
79
|
+
- test/README
|
80
|
+
- test/test
|
81
|
+
- test/test/functional
|
82
|
+
- test/test/functional/articles_controller_test.rb
|
83
|
+
- test/test/test_helper.rb
|
84
|
+
- test/test/performance
|
85
|
+
- test/test/performance/browsing_test.rb
|
86
|
+
- test/config
|
87
|
+
- test/config/locales
|
88
|
+
- test/config/locales/en.yml
|
89
|
+
- test/config/initializers
|
90
|
+
- test/config/initializers/session_store.rb
|
91
|
+
- test/config/initializers/backtrace_silencers.rb
|
92
|
+
- test/config/initializers/mime_types.rb
|
93
|
+
- test/config/initializers/inflections.rb
|
94
|
+
- test/config/initializers/new_rails_defaults.rb
|
95
|
+
- test/config/boot.rb
|
96
|
+
- test/config/routes.rb
|
97
|
+
- test/config/environment.rb
|
98
|
+
- test/config/database.yml
|
99
|
+
- test/config/environments
|
100
|
+
- test/config/environments/test.rb
|
101
|
+
- test/config/environments/development.rb
|
102
|
+
- test/config/environments/production.rb
|
103
|
+
- test/app
|
104
|
+
- test/app/helpers
|
105
|
+
- test/app/helpers/application_helper.rb
|
106
|
+
- test/app/views
|
107
|
+
- test/app/views/articles
|
108
|
+
- test/app/views/articles/index_fr_FR.html.erb
|
109
|
+
- test/app/views/articles/index_de.html.erb
|
110
|
+
- test/app/views/articles/list.html.erb
|
111
|
+
- test/app/views/articles/index_ja.html.erb
|
112
|
+
- test/app/views/articles/index.html.erb
|
113
|
+
- test/app/controllers
|
114
|
+
- test/app/controllers/application_controller.rb
|
115
|
+
- test/app/controllers/articles_controller.rb
|
116
|
+
- test/Rakefile
|
47
117
|
- sample
|
48
118
|
- sample/script
|
49
119
|
- sample/script/plugin
|