gettext 1.8.0-mswin32 → 1.9.0-mswin32
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 +120 -0
- data/NEWS +16 -0
- data/README +27 -19
- data/data/locale/ca/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ca/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/eo/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/eo/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/et/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/zh_TW/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/zh_TW/LC_MESSAGES/rgettext.mo +0 -0
- data/ext/gettext/Makefile +22 -19
- data/ext/gettext/mkmf.log +3 -9
- data/lib/gettext.rb +13 -10
- data/lib/gettext/active_record.rb +130 -113
- data/lib/gettext/erb.rb +2 -2
- data/lib/gettext/locale.rb +11 -5
- data/lib/gettext/locale_cgi.rb +3 -3
- data/lib/gettext/locale_posix.rb +2 -2
- data/lib/gettext/locale_win32.rb +2 -1
- data/lib/gettext/parser/active_record.rb +24 -14
- data/lib/gettext/parser/ruby.rb +4 -63
- data/lib/gettext/rails.rb +23 -20
- data/lib/gettext/rgettext.rb +6 -6
- data/lib/gettext/utils.rb +12 -6
- data/lib/gettext/version.rb +2 -2
- data/po/ca/rails.po +121 -0
- data/po/ca/rgettext.po +130 -0
- data/po/cs/rails.po +30 -26
- data/po/cs/rgettext.po +44 -36
- data/po/de/rails.po +28 -24
- data/po/de/rgettext.po +43 -35
- data/po/el/rails.po +38 -34
- data/po/el/rgettext.po +54 -46
- data/po/eo/rails.po +121 -0
- data/po/eo/rgettext.po +127 -0
- data/po/es/rails.po +28 -24
- data/po/es/rgettext.po +45 -37
- data/po/et/rails.po +28 -24
- data/po/fr/rails.po +39 -33
- data/po/fr/rgettext.po +43 -35
- data/po/it/rails.po +28 -24
- data/po/it/rgettext.po +43 -35
- data/po/ja/rails.po +30 -26
- data/po/ja/rgettext.po +44 -36
- data/po/ko/rails.po +36 -32
- data/po/ko/rgettext.po +43 -35
- data/po/nl/rails.po +32 -28
- data/po/nl/rgettext.po +46 -38
- data/po/pt_BR/rails.po +36 -31
- data/po/pt_BR/rgettext.po +45 -37
- data/po/rails.pot +28 -24
- data/po/rgettext.pot +39 -31
- data/po/ru/rails.po +36 -30
- data/po/ru/rgettext.po +50 -41
- data/po/sv/rgettext.po +40 -32
- data/po/zh/rails.po +29 -24
- data/po/zh/rgettext.po +46 -36
- data/po/zh_TW/rails.po +29 -24
- data/po/zh_TW/rgettext.po +45 -36
- data/samples/cgi/locale/ca/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/po/ca/helloerb1.po +59 -0
- data/samples/cgi/po/ca/helloerb2.po +51 -0
- data/samples/cgi/po/ca/hellolib.po +23 -0
- data/samples/cgi/po/ca/main.po +83 -0
- data/samples/cgi/po/eo/helloerb1.po +60 -0
- data/samples/cgi/po/eo/helloerb2.po +52 -0
- data/samples/cgi/po/eo/hellolib.po +24 -0
- data/samples/cgi/po/eo/main.po +84 -0
- data/samples/locale/ca/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/po/ca/hello.po +23 -0
- data/samples/po/ca/hello2.po +31 -0
- data/samples/po/ca/hello_noop.po +27 -0
- data/samples/po/ca/hello_plural.po +25 -0
- data/samples/po/ca/helloglade2.po +31 -0
- data/samples/po/ca/hellogtk.po +23 -0
- data/samples/po/ca/hellotk.po +23 -0
- data/samples/po/eo/hello.po +23 -0
- data/samples/po/eo/hello2.po +31 -0
- data/samples/po/eo/hello_noop.po +27 -0
- data/samples/po/eo/hello_plural.po +26 -0
- data/samples/po/eo/helloglade2.po +32 -0
- data/samples/po/eo/hellogtk.po +23 -0
- data/samples/po/eo/hellotk.po +24 -0
- data/samples/rails/app/views/blog/list.rhtml +0 -1
- data/samples/rails/config/environment.rb +2 -0
- data/samples/rails/db/schema.rb +0 -79
- data/samples/rails/lib/tasks/gettext.rake +2 -1
- data/samples/rails/locale/ca/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/eo/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/it/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ru/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/zh/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/zh_TW/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/po/blog.pot +106 -106
- data/samples/rails/po/ca/blog.po +105 -0
- data/samples/rails/po/cs/blog.po +107 -110
- data/samples/rails/po/de/blog.po +107 -107
- data/samples/rails/po/el/blog.po +105 -105
- data/samples/rails/po/en/blog.po +107 -107
- data/samples/rails/po/eo/blog.po +106 -0
- data/samples/rails/po/es/blog.po +105 -105
- data/samples/rails/po/fr/blog.po +105 -105
- data/samples/rails/po/it/blog.po +105 -105
- data/samples/rails/po/ja/blog.po +105 -105
- data/samples/rails/po/ko/blog.po +105 -105
- data/samples/rails/po/nl/blog.po +105 -105
- data/samples/rails/po/pt_BR/blog.po +105 -105
- data/samples/rails/po/ru/blog.po +105 -105
- data/samples/rails/po/zh/blog.po +105 -105
- data/samples/rails/po/zh_TW/blog.po +107 -107
- data/samples/rails/vendor/plugins/gettext/locale/ca/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/vendor/plugins/gettext/po/ca/gettext_plugin.po +27 -0
- data/test/README +6 -0
- data/test/Rakefile +1 -1
- data/test/fixtures/book.rb +3 -0
- data/test/fixtures/user.rb +3 -0
- data/test/gettext_test_active_record.rb +347 -67
- data/test/gettext_test_cgi.rb +27 -2
- data/test/gettext_test_parser.rb +102 -4
- data/test/gettext_test_rails.rb +6 -1
- data/test/locale/ja/LC_MESSAGES/active_record.mo +0 -0
- data/test/po/ja/active_record.po +17 -17
- data/test/test.sh +1 -0
- data/test/test_rubyparser.rb +6 -4
- metadata +92 -3
@@ -0,0 +1,27 @@
|
|
1
|
+
# GetText Sample Blog on RoR.
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005 Masao Mutoh
|
4
|
+
#
|
5
|
+
# This file is distributed under the same license as the Ruby-GetText-Package.
|
6
|
+
#
|
7
|
+
# Ramon Salvadó <rsalvado at gnuine.com>, 2006.
|
8
|
+
#
|
9
|
+
msgid ""
|
10
|
+
msgstr ""
|
11
|
+
"Project-Id-Version: gettext_plugin 1.2.0\n"
|
12
|
+
"POT-Creation-Date: 2006-05-31 02:06+0900\n"
|
13
|
+
"PO-Revision-Date: 2005-12-20 10:33+0900\n"
|
14
|
+
"Last-Translator: Ramon Salvadó <rsalvado at gnuine.com>\n"
|
15
|
+
"Language-Team: Catalan\n"
|
16
|
+
"MIME-Version: 1.0\n"
|
17
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
18
|
+
"Content-Transfer-Encoding: 8bit\n"
|
19
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
20
|
+
|
21
|
+
#: lib/gettext_plugin.rb:18
|
22
|
+
msgid "Select locale"
|
23
|
+
msgstr "Selecciona locale"
|
24
|
+
|
25
|
+
#: lib/gettext_plugin.rb:30
|
26
|
+
msgid "Cookie "lang" is set: %s"
|
27
|
+
msgstr "La galeta "lang" existeix: %s"
|
data/test/README
CHANGED
data/test/Rakefile
CHANGED
@@ -4,6 +4,7 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'gettext'
|
6
6
|
require 'gettext/active_record'
|
7
|
+
require 'gettext/parser/active_record'
|
7
8
|
require 'test/unit'
|
8
9
|
require 'active_record'
|
9
10
|
require 'active_record/fixtures'
|
@@ -14,7 +15,25 @@ require 'fixtures/reply'
|
|
14
15
|
require 'fixtures/developer'
|
15
16
|
require 'logger'
|
16
17
|
|
17
|
-
|
18
|
+
version = /activerecord-([^\/]+)/.match($:.join)[1]
|
19
|
+
|
20
|
+
#if version > "1.15.0"
|
21
|
+
# ticket 6657 on dev.rubyonrails.org require this but it becames removed(?)
|
22
|
+
# AR_6657 = true
|
23
|
+
#else
|
24
|
+
AR_6657 = false
|
25
|
+
#end
|
26
|
+
puts "The activerecord svn version is #{$1}"
|
27
|
+
|
28
|
+
|
29
|
+
begin
|
30
|
+
`rake dropdb`
|
31
|
+
rescue
|
32
|
+
end
|
33
|
+
begin
|
34
|
+
`rake createdb`
|
35
|
+
rescue
|
36
|
+
end
|
18
37
|
|
19
38
|
ActiveRecord::Base.establish_connection(
|
20
39
|
:adapter => "mysql",
|
@@ -61,7 +80,7 @@ class ValidationsTest < Test::Unit::TestCase
|
|
61
80
|
r.save
|
62
81
|
assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid"
|
63
82
|
assert_equal "空です。", r.errors.on("content"), "A reply without content should contain an error"
|
64
|
-
assert_equal "内容 空です。", r.errors.full_messages[0], "A reply without content should contain an error"
|
83
|
+
assert_equal "Reply内容 空です。", r.errors.full_messages[0], "A reply without content should contain an error"
|
65
84
|
assert_equal 1, r.errors.count
|
66
85
|
|
67
86
|
GetText.set_locale_all "en"
|
@@ -77,11 +96,11 @@ class ValidationsTest < Test::Unit::TestCase
|
|
77
96
|
assert !r.save
|
78
97
|
|
79
98
|
assert r.errors.invalid?("title"), "A reply without title should mark that attribute as invalid"
|
80
|
-
assert_equal "タイトル 空です。", r.errors.full_messages[0]
|
99
|
+
assert_equal "Replyタイトル 空です。", r.errors.full_messages[0]
|
81
100
|
assert_equal "空です。", r.errors.on("title")
|
82
101
|
|
83
102
|
assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid"
|
84
|
-
assert_equal "内容 空です。", r.errors.full_messages[1]
|
103
|
+
assert_equal "Reply内容 空です。", r.errors.full_messages[1]
|
85
104
|
assert_equal "空です。", r.errors.on("content")
|
86
105
|
|
87
106
|
assert_equal 2, r.errors.count
|
@@ -107,7 +126,7 @@ class ValidationsTest < Test::Unit::TestCase
|
|
107
126
|
r.title = "Wrong Create"
|
108
127
|
assert !r.save
|
109
128
|
assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid"
|
110
|
-
assert_equal "タイトル が不正に生成されました。", r.errors.full_messages[0]
|
129
|
+
assert_equal "Replyタイトル が不正に生成されました。", r.errors.full_messages[0]
|
111
130
|
assert_equal "が不正に生成されました。", r.errors.on("title")
|
112
131
|
|
113
132
|
GetText.set_locale_all "en"
|
@@ -129,7 +148,7 @@ class ValidationsTest < Test::Unit::TestCase
|
|
129
148
|
r.title = "Wrong Update"
|
130
149
|
assert !r.save, "Second save should fail"
|
131
150
|
assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid"
|
132
|
-
assert_equal "タイトル が不正に更新されました。", r.errors.full_messages[0]
|
151
|
+
assert_equal "Replyタイトル が不正に更新されました。", r.errors.full_messages[0]
|
133
152
|
assert_equal "が不正に更新されました。", r.errors.on("title")
|
134
153
|
|
135
154
|
GetText.set_locale_all "en"
|
@@ -146,6 +165,56 @@ class ValidationsTest < Test::Unit::TestCase
|
|
146
165
|
assert_equal "is Wrong Update", r.errors.on("title")
|
147
166
|
end
|
148
167
|
|
168
|
+
def test_invalid_record_exception
|
169
|
+
assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
|
170
|
+
assert_raises(ActiveRecord::RecordInvalid) { Reply.new.save! }
|
171
|
+
|
172
|
+
GetText.set_locale_all "ja_JP.UTF-8"
|
173
|
+
begin
|
174
|
+
r = Reply.new
|
175
|
+
r.save!
|
176
|
+
flunk
|
177
|
+
rescue ActiveRecord::RecordInvalid => invalid
|
178
|
+
assert_equal r, invalid.record
|
179
|
+
assert_equal "入力値が正しくありません。: Replyタイトル 空です。, Reply内容 空です。", invalid.message
|
180
|
+
end
|
181
|
+
|
182
|
+
GetText.set_locale_all "en"
|
183
|
+
begin
|
184
|
+
r = Reply.new
|
185
|
+
r.save!
|
186
|
+
flunk
|
187
|
+
rescue ActiveRecord::RecordInvalid => invalid
|
188
|
+
assert_equal r, invalid.record
|
189
|
+
assert_equal "Validation failed: Title Empty, Content Empty", invalid.message
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_scoped_create_without_attributes
|
194
|
+
Reply.with_scope(:create => {}) do
|
195
|
+
assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
|
196
|
+
end
|
197
|
+
|
198
|
+
GetText.set_locale_all "ja_JP.UTF-8"
|
199
|
+
Reply.with_scope(:create => {}) do
|
200
|
+
begin
|
201
|
+
Reply.create!
|
202
|
+
rescue ActiveRecord::RecordInvalid => invalid
|
203
|
+
assert_equal "入力値が正しくありません。: Replyタイトル 空です。, Reply内容 空です。", invalid.message
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
GetText.set_locale_all "en"
|
208
|
+
Reply.with_scope(:create => {}) do
|
209
|
+
begin
|
210
|
+
Reply.create!
|
211
|
+
rescue ActiveRecord::RecordInvalid => invalid
|
212
|
+
assert_equal "Validation failed: Title Empty, Content Empty", invalid.message
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
|
149
218
|
def test_single_error_per_attr_iteration
|
150
219
|
GetText.set_locale_all "ja_JP.UTF-8"
|
151
220
|
r = Reply.new
|
@@ -177,8 +246,8 @@ class ValidationsTest < Test::Unit::TestCase
|
|
177
246
|
|
178
247
|
errors = []
|
179
248
|
r.errors.each_full { |error| errors << error }
|
180
|
-
assert_equal "タイトル が不正に生成されました。", errors[0]
|
181
|
-
assert_equal "タイトル は内容がミスマッチです。", errors[1]
|
249
|
+
assert_equal "Replyタイトル が不正に生成されました。", errors[0]
|
250
|
+
assert_equal "Replyタイトル は内容がミスマッチです。", errors[1]
|
182
251
|
assert_equal 2, r.errors.count
|
183
252
|
|
184
253
|
GetText.set_locale_all "en"
|
@@ -207,7 +276,7 @@ class ValidationsTest < Test::Unit::TestCase
|
|
207
276
|
|
208
277
|
assert_equal "リプライはdignifyされてません。", r.errors.on_base
|
209
278
|
|
210
|
-
assert errors.include?("タイトル 空です。")
|
279
|
+
assert errors.include?("Replyタイトル 空です。")
|
211
280
|
assert errors.include?("リプライはdignifyされてません。")
|
212
281
|
assert_equal 2, r.errors.count
|
213
282
|
|
@@ -498,6 +567,58 @@ class ValidationsTest < Test::Unit::TestCase
|
|
498
567
|
|
499
568
|
assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) }
|
500
569
|
end
|
570
|
+
|
571
|
+
def test_validate_format_numeric
|
572
|
+
Topic.validates_format_of(:title, :content, :with => /^[1-9][0-9]*$/, :message => N_("is bad data"))
|
573
|
+
|
574
|
+
GetText.set_locale_all "ja_JP.UTF-8"
|
575
|
+
t = Topic.create("title" => "72x", "content" => "6789")
|
576
|
+
assert !t.valid?, "Shouldn't be valid"
|
577
|
+
assert !t.save, "Shouldn't save because it's invalid"
|
578
|
+
assert_equal "は悪いデータです。", t.errors.on(:title)
|
579
|
+
assert_nil t.errors.on(:content)
|
580
|
+
|
581
|
+
t.title = "-11"
|
582
|
+
assert !t.valid?, "Shouldn't be valid"
|
583
|
+
|
584
|
+
t.title = "03"
|
585
|
+
assert !t.valid?, "Shouldn't be valid"
|
586
|
+
|
587
|
+
t.title = "z44"
|
588
|
+
assert !t.valid?, "Shouldn't be valid"
|
589
|
+
|
590
|
+
t.title = "5v7"
|
591
|
+
assert !t.valid?, "Shouldn't be valid"
|
592
|
+
|
593
|
+
t.title = "1"
|
594
|
+
|
595
|
+
assert t.save
|
596
|
+
assert_nil t.errors.on(:title)
|
597
|
+
|
598
|
+
GetText.set_locale_all "en"
|
599
|
+
t = Topic.create("title" => "72x", "content" => "6789")
|
600
|
+
assert !t.valid?, "Shouldn't be valid"
|
601
|
+
assert !t.save, "Shouldn't save because it's invalid"
|
602
|
+
assert_equal "is bad data", t.errors.on(:title)
|
603
|
+
assert_nil t.errors.on(:content)
|
604
|
+
|
605
|
+
t.title = "-11"
|
606
|
+
assert !t.valid?, "Shouldn't be valid"
|
607
|
+
|
608
|
+
t.title = "03"
|
609
|
+
assert !t.valid?, "Shouldn't be valid"
|
610
|
+
|
611
|
+
t.title = "z44"
|
612
|
+
assert !t.valid?, "Shouldn't be valid"
|
613
|
+
|
614
|
+
t.title = "5v7"
|
615
|
+
assert !t.valid?, "Shouldn't be valid"
|
616
|
+
|
617
|
+
t.title = "1"
|
618
|
+
|
619
|
+
assert t.save
|
620
|
+
assert_nil t.errors.on(:title)
|
621
|
+
end
|
501
622
|
|
502
623
|
def test_validates_inclusion_of
|
503
624
|
Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ) )
|
@@ -1001,13 +1122,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1001
1122
|
d = Developer.new
|
1002
1123
|
d.salary = "0"
|
1003
1124
|
assert !d.valid?
|
1004
|
-
|
1005
|
-
|
1125
|
+
if AR_6657
|
1126
|
+
assert_equal "給料は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).last
|
1127
|
+
else
|
1128
|
+
assert_equal "給料は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).first
|
1129
|
+
end
|
1006
1130
|
GetText.set_locale_all "en"
|
1007
1131
|
d = Developer.new
|
1008
1132
|
d.salary = "0"
|
1009
1133
|
assert !d.valid?
|
1010
|
-
|
1134
|
+
if AR_6657
|
1135
|
+
assert_equal "Salary contains 'single' and \"double\" quotes", d.errors.on(:salary).last
|
1136
|
+
else
|
1137
|
+
assert_equal "Salary contains 'single' and \"double\" quotes", d.errors.on(:salary).first
|
1138
|
+
end
|
1011
1139
|
end
|
1012
1140
|
|
1013
1141
|
def test_validates_acceptance_of_with_custom_error_using_quotes
|
@@ -1017,13 +1145,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1017
1145
|
d = Developer.new
|
1018
1146
|
d.salary = "0"
|
1019
1147
|
assert !d.valid?
|
1020
|
-
|
1021
|
-
|
1148
|
+
if AR_6657
|
1149
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).last
|
1150
|
+
else
|
1151
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).first
|
1152
|
+
end
|
1022
1153
|
GetText.set_locale_all "en"
|
1023
1154
|
d = Developer.new
|
1024
1155
|
d.salary = "0"
|
1025
1156
|
assert !d.valid?
|
1026
|
-
|
1157
|
+
if AR_6657
|
1158
|
+
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).last
|
1159
|
+
else
|
1160
|
+
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).first
|
1161
|
+
end
|
1027
1162
|
end
|
1028
1163
|
|
1029
1164
|
def test_validates_confirmation_of_with_custom_error_using_quotes_fn
|
@@ -1034,14 +1169,21 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1034
1169
|
d.name = "John"
|
1035
1170
|
d.name_confirmation = "Johnny"
|
1036
1171
|
assert !d.valid?
|
1037
|
-
|
1038
|
-
|
1172
|
+
if AR_6657
|
1173
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
|
1174
|
+
else
|
1175
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
|
1176
|
+
end
|
1039
1177
|
GetText.set_locale_all "en"
|
1040
1178
|
d = Developer.new
|
1041
1179
|
d.name = "John"
|
1042
1180
|
d.name_confirmation = "Johnny"
|
1043
1181
|
assert !d.valid?
|
1044
|
-
|
1182
|
+
if AR_6657
|
1183
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
|
1184
|
+
else
|
1185
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
|
1186
|
+
end
|
1045
1187
|
end
|
1046
1188
|
|
1047
1189
|
def test_validates_confirmation_of_with_custom_error_using_quotes
|
@@ -1069,13 +1211,21 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1069
1211
|
d = Developer.new
|
1070
1212
|
d.name = "John 32"
|
1071
1213
|
assert !d.valid?
|
1072
|
-
|
1214
|
+
if AR_6657
|
1215
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
|
1216
|
+
else
|
1217
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
|
1218
|
+
end
|
1073
1219
|
|
1074
1220
|
GetText.set_locale_all "en"
|
1075
1221
|
d = Developer.new
|
1076
1222
|
d.name = "John 32"
|
1077
1223
|
assert !d.valid?
|
1078
|
-
|
1224
|
+
if AR_6657
|
1225
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
|
1226
|
+
else
|
1227
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
|
1228
|
+
end
|
1079
1229
|
end
|
1080
1230
|
|
1081
1231
|
def test_validates_format_of_with_custom_error_using_quotes
|
@@ -1101,12 +1251,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1101
1251
|
d = Developer.new
|
1102
1252
|
d.salary = "90,000"
|
1103
1253
|
assert !d.valid?
|
1104
|
-
|
1254
|
+
if AR_6657
|
1255
|
+
assert_equal "給料は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).last
|
1256
|
+
else
|
1257
|
+
assert_equal "給料は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).first
|
1258
|
+
end
|
1105
1259
|
GetText.set_locale_all "en"
|
1106
1260
|
d = Developer.new
|
1107
1261
|
d.salary = "90,000"
|
1108
1262
|
assert !d.valid?
|
1109
|
-
|
1263
|
+
if AR_6657
|
1264
|
+
assert_equal "Salary contains 'single' and \"double\" quotes", d.errors.on(:salary).last
|
1265
|
+
else
|
1266
|
+
assert_equal "Salary contains 'single' and \"double\" quotes", d.errors.on(:salary).first
|
1267
|
+
end
|
1110
1268
|
end
|
1111
1269
|
|
1112
1270
|
def test_validates_inclusion_of_with_custom_error_using_quotes
|
@@ -1116,14 +1274,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1116
1274
|
d = Developer.new
|
1117
1275
|
d.salary = "90,000"
|
1118
1276
|
assert !d.valid?
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1277
|
+
if AR_6657
|
1278
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).last
|
1279
|
+
else
|
1280
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).first
|
1281
|
+
end
|
1122
1282
|
GetText.set_locale_all "en"
|
1123
1283
|
d = Developer.new
|
1124
1284
|
d.salary = "90,000"
|
1125
1285
|
assert !d.valid?
|
1126
|
-
|
1286
|
+
if AR_6657
|
1287
|
+
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).last
|
1288
|
+
else
|
1289
|
+
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).first
|
1290
|
+
end
|
1127
1291
|
end
|
1128
1292
|
|
1129
1293
|
def test_validates_length_of_with_custom_too_long_using_quotes_fn
|
@@ -1133,13 +1297,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1133
1297
|
d = Developer.new
|
1134
1298
|
d.name = "Jeffrey"
|
1135
1299
|
assert !d.valid?
|
1136
|
-
|
1137
|
-
|
1300
|
+
if AR_6657
|
1301
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
|
1302
|
+
else
|
1303
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
|
1304
|
+
end
|
1138
1305
|
GetText.set_locale_all "en"
|
1139
1306
|
d = Developer.new
|
1140
1307
|
d.name = "Jeffrey"
|
1141
1308
|
assert !d.valid?
|
1142
|
-
|
1309
|
+
if AR_6657
|
1310
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
|
1311
|
+
else
|
1312
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
|
1313
|
+
end
|
1143
1314
|
end
|
1144
1315
|
|
1145
1316
|
def test_validates_length_of_with_custom_too_long_using_quotes
|
@@ -1149,13 +1320,13 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1149
1320
|
d = Developer.new
|
1150
1321
|
d.name = "Jeffrey"
|
1151
1322
|
assert !d.valid?
|
1152
|
-
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).
|
1323
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
|
1153
1324
|
|
1154
1325
|
GetText.set_locale_all "en"
|
1155
1326
|
d = Developer.new
|
1156
1327
|
d.name = "Jeffrey"
|
1157
1328
|
assert !d.valid?
|
1158
|
-
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).
|
1329
|
+
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).last
|
1159
1330
|
end
|
1160
1331
|
|
1161
1332
|
def test_validates_length_of_with_custom_too_short_using_quotes_fn
|
@@ -1164,13 +1335,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1164
1335
|
d = Developer.new
|
1165
1336
|
d.name = "Joe"
|
1166
1337
|
assert !d.valid?
|
1167
|
-
|
1168
|
-
|
1338
|
+
if AR_6657
|
1339
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
|
1340
|
+
else
|
1341
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
|
1342
|
+
end
|
1169
1343
|
GetText.set_locale_all "en"
|
1170
1344
|
d = Developer.new
|
1171
1345
|
d.name = "Joe"
|
1172
1346
|
assert !d.valid?
|
1173
|
-
|
1347
|
+
if AR_6657
|
1348
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
|
1349
|
+
else
|
1350
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
|
1351
|
+
end
|
1174
1352
|
end
|
1175
1353
|
|
1176
1354
|
def test_validates_length_of_with_custom_too_short_using_quotes
|
@@ -1179,13 +1357,13 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1179
1357
|
d = Developer.new
|
1180
1358
|
d.name = "Joe"
|
1181
1359
|
assert !d.valid?
|
1182
|
-
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).
|
1360
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
|
1183
1361
|
|
1184
1362
|
GetText.set_locale_all "en"
|
1185
1363
|
d = Developer.new
|
1186
1364
|
d.name = "Joe"
|
1187
1365
|
assert !d.valid?
|
1188
|
-
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).
|
1366
|
+
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).last
|
1189
1367
|
end
|
1190
1368
|
|
1191
1369
|
def test_validates_length_of_with_custom_message_using_quotes_fn
|
@@ -1194,13 +1372,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1194
1372
|
d = Developer.new
|
1195
1373
|
d.name = "Joe"
|
1196
1374
|
assert !d.valid?
|
1197
|
-
|
1198
|
-
|
1375
|
+
if AR_6657
|
1376
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
|
1377
|
+
else
|
1378
|
+
assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
|
1379
|
+
end
|
1199
1380
|
GetText.set_locale_all "en"
|
1200
1381
|
d = Developer.new
|
1201
1382
|
d.name = "Joe"
|
1202
1383
|
assert !d.valid?
|
1203
|
-
|
1384
|
+
if AR_6657
|
1385
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
|
1386
|
+
else
|
1387
|
+
assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
|
1388
|
+
end
|
1204
1389
|
end
|
1205
1390
|
|
1206
1391
|
def test_validates_length_of_with_custom_message_using_quotes
|
@@ -1209,13 +1394,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1209
1394
|
d = Developer.new
|
1210
1395
|
d.name = "Joe"
|
1211
1396
|
assert !d.valid?
|
1212
|
-
|
1213
|
-
|
1397
|
+
if AR_6657
|
1398
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
|
1399
|
+
else
|
1400
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
|
1401
|
+
end
|
1214
1402
|
GetText.set_locale_all "en"
|
1215
1403
|
d = Developer.new
|
1216
1404
|
d.name = "Joe"
|
1217
1405
|
assert !d.valid?
|
1218
|
-
|
1406
|
+
if AR_6657
|
1407
|
+
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).last
|
1408
|
+
else
|
1409
|
+
assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).first
|
1410
|
+
end
|
1219
1411
|
end
|
1220
1412
|
|
1221
1413
|
def test_validates_presence_of_with_custom_message_using_quotes_fn
|
@@ -1226,13 +1418,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1226
1418
|
d.name = "Joe"
|
1227
1419
|
assert !d.valid?
|
1228
1420
|
|
1229
|
-
|
1230
|
-
|
1421
|
+
if AR_6657
|
1422
|
+
assert_equal "存在しないは'シングル' \"ダブル\"クオートを含む。", d.errors.on(:non_existent).last
|
1423
|
+
else
|
1424
|
+
assert_equal "存在しないは'シングル' \"ダブル\"クオートを含む。", d.errors.on(:non_existent).first
|
1425
|
+
end
|
1231
1426
|
GetText.set_locale_all "en"
|
1232
1427
|
d = Developer.new
|
1233
1428
|
d.name = "Joe"
|
1234
1429
|
assert !d.valid?
|
1235
|
-
|
1430
|
+
if AR_6657
|
1431
|
+
assert_equal "Non existent contains 'single' and \"double\" quotes", d.errors.on(:non_existent).last
|
1432
|
+
else
|
1433
|
+
assert_equal "Non existent contains 'single' and \"double\" quotes", d.errors.on(:non_existent).first
|
1434
|
+
end
|
1236
1435
|
end
|
1237
1436
|
|
1238
1437
|
def test_validates_presence_of_with_custom_message_using_quotes
|
@@ -1242,7 +1441,6 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1242
1441
|
d.name = "Joe"
|
1243
1442
|
assert !d.valid?
|
1244
1443
|
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:non_existent)
|
1245
|
-
|
1246
1444
|
GetText.set_locale_all "en"
|
1247
1445
|
d = Developer.new
|
1248
1446
|
d.name = "Joe"
|
@@ -1257,13 +1455,21 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1257
1455
|
d = Developer.new
|
1258
1456
|
d.name = "David"
|
1259
1457
|
assert !d.valid?
|
1260
|
-
|
1458
|
+
if AR_6657
|
1459
|
+
assert_equal d.errors.on(:name).last, "開発者名は'シングル' \"ダブル\"クオートを含む。"
|
1460
|
+
else
|
1461
|
+
assert_equal d.errors.on(:name).first, "開発者名は'シングル' \"ダブル\"クオートを含む。"
|
1462
|
+
end
|
1261
1463
|
|
1262
1464
|
GetText.set_locale_all "en"
|
1263
1465
|
d = Developer.new
|
1264
1466
|
d.name = "David"
|
1265
1467
|
assert !d.valid?
|
1266
|
-
|
1468
|
+
if AR_6657
|
1469
|
+
assert_equal d.errors.on(:name).last, "Name contains 'single' and \"double\" quotes"
|
1470
|
+
else
|
1471
|
+
assert_equal d.errors.on(:name).first, "Name contains 'single' and \"double\" quotes"
|
1472
|
+
end
|
1267
1473
|
end
|
1268
1474
|
|
1269
1475
|
def test_validates_uniqueness_of_with_custom_message_using_quotes
|
@@ -1273,18 +1479,18 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1273
1479
|
d = Developer.new
|
1274
1480
|
d.name = "David"
|
1275
1481
|
assert !d.valid?
|
1276
|
-
assert_equal d.errors.on(:name).
|
1482
|
+
assert_equal d.errors.on(:name).last, "この文字列は'シングル' \"ダブル\"クオートを含む。"
|
1277
1483
|
|
1278
1484
|
GetText.set_locale_all "en"
|
1279
1485
|
d = Developer.new
|
1280
1486
|
d.name = "David"
|
1281
1487
|
assert !d.valid?
|
1282
|
-
assert_equal d.errors.on(:name).
|
1488
|
+
assert_equal d.errors.on(:name).last, "This string contains 'single' and \"double\" quotes"
|
1283
1489
|
end
|
1284
1490
|
|
1285
1491
|
def test_validates_associated_with_custom_message_using_quotes_fn
|
1286
|
-
Reply.validates_associated
|
1287
|
-
Topic.validates_presence_of
|
1492
|
+
Reply.validates_associated :topic, :message => N_("%{fn} contains 'single' and \"double\" quotes")
|
1493
|
+
Topic.validates_presence_of :content
|
1288
1494
|
r = Reply.create("title" => "A reply", "content" => "with content!")
|
1289
1495
|
r.topic = Topic.create("title" => "uhohuhoh")
|
1290
1496
|
assert !r.valid?
|
@@ -1293,25 +1499,29 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1293
1499
|
assert r.valid?
|
1294
1500
|
|
1295
1501
|
GetText.set_locale_all "ja_JP.UTF-8"
|
1296
|
-
Reply.validates_associated :topic, :message => N_("%{fn} contains 'single' and \"double\" quotes")
|
1297
|
-
Topic.validates_presence_of :content
|
1298
1502
|
r = Reply.create("title" => "A reply", "content" => "with content!")
|
1299
1503
|
r.topic = Topic.create("title" => "uhohuhoh")
|
1300
1504
|
assert !r.valid?
|
1301
|
-
|
1302
|
-
|
1505
|
+
if AR_6657
|
1506
|
+
assert_equal "Replyトピックは'シングル' \"ダブル\"クオートを含む。", r.errors.on(:topic).last
|
1507
|
+
else
|
1508
|
+
assert_equal "Replyトピックは'シングル' \"ダブル\"クオートを含む。", r.errors.on(:topic).first
|
1509
|
+
end
|
1303
1510
|
|
1304
1511
|
GetText.set_locale_all "en"
|
1305
1512
|
r = Reply.create("title" => "A reply", "content" => "with content!")
|
1306
1513
|
r.topic = Topic.create("title" => "uhohuhoh")
|
1307
1514
|
assert !r.valid?
|
1308
|
-
|
1309
|
-
|
1515
|
+
if AR_6657
|
1516
|
+
assert_equal "Topic contains 'single' and \"double\" quotes", r.errors.on(:topic).last
|
1517
|
+
else
|
1518
|
+
assert_equal "Topic contains 'single' and \"double\" quotes", r.errors.on(:topic).first
|
1519
|
+
end
|
1310
1520
|
end
|
1311
1521
|
|
1312
1522
|
def test_validates_associated_with_custom_message_using_quotes
|
1313
|
-
Reply.validates_associated
|
1314
|
-
Topic.validates_presence_of
|
1523
|
+
Reply.validates_associated :topic, :message => N_("This string contains 'single' and \"double\" quotes")
|
1524
|
+
Topic.validates_presence_of :content
|
1315
1525
|
r = Reply.create("title" => "A reply", "content" => "with content!")
|
1316
1526
|
r.topic = Topic.create("title" => "uhohuhoh")
|
1317
1527
|
assert !r.valid?
|
@@ -1320,20 +1530,16 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1320
1530
|
assert r.valid?
|
1321
1531
|
|
1322
1532
|
GetText.set_locale_all "ja_JP.UTF-8"
|
1323
|
-
Reply.validates_associated :topic, :message => N_("This string contains 'single' and \"double\" quotes")
|
1324
|
-
Topic.validates_presence_of :content
|
1325
1533
|
r = Reply.create("title" => "A reply", "content" => "with content!")
|
1326
1534
|
r.topic = Topic.create("title" => "uhohuhoh")
|
1327
1535
|
assert !r.valid?
|
1328
|
-
assert_equal "
|
1329
|
-
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", r.errors.on(:topic).first
|
1536
|
+
assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", r.errors.on(:topic)
|
1330
1537
|
|
1331
1538
|
GetText.set_locale_all "en"
|
1332
1539
|
r = Reply.create("title" => "A reply", "content" => "with content!")
|
1333
1540
|
r.topic = Topic.create("title" => "uhohuhoh")
|
1334
1541
|
assert !r.valid?
|
1335
|
-
assert_equal "
|
1336
|
-
assert_equal "This string contains 'single' and \"double\" quotes", r.errors.on(:topic).first
|
1542
|
+
assert_equal "This string contains 'single' and \"double\" quotes", r.errors.on(:topic)
|
1337
1543
|
end
|
1338
1544
|
|
1339
1545
|
def test_conditional_validation_using_method_true_fn
|
@@ -1456,7 +1662,7 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1456
1662
|
r = Reply.create("title" => "A reply", "content" => "with content!")
|
1457
1663
|
# In this case, rgettext doesn't pick up the names of relations as msgid,
|
1458
1664
|
# so you need to define N_() in the model class
|
1459
|
-
assert_equal "トピックを入力してください。", r.errors.on(:topic)
|
1665
|
+
assert_equal "Replyトピックを入力してください。", r.errors.on(:topic)
|
1460
1666
|
|
1461
1667
|
GetText.set_locale_all "en"
|
1462
1668
|
r = Reply.create("title" => "A reply", "content" => "with content!")
|
@@ -1464,6 +1670,41 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1464
1670
|
assert_equal "Topic can't be blank", r.errors.full_messages[0]
|
1465
1671
|
end
|
1466
1672
|
|
1673
|
+
def test_errors_to_xml
|
1674
|
+
GetText.set_locale_all "ja_JP.UTF-8"
|
1675
|
+
r = Reply.new :title => "Wrong Create"
|
1676
|
+
assert !r.valid?
|
1677
|
+
xml = r.errors.to_xml(:skip_instruct => true)
|
1678
|
+
assert_equal "<errors>", xml.first(8)
|
1679
|
+
assert xml.include?("<error>Replyタイトル が不正に生成されました。</error>")
|
1680
|
+
assert xml.include?("<error>Reply内容 空です。</error>")
|
1681
|
+
|
1682
|
+
GetText.set_locale_all "en"
|
1683
|
+
r = Reply.new :title => "Wrong Create"
|
1684
|
+
assert !r.valid?
|
1685
|
+
xml = r.errors.to_xml(:skip_instruct => true)
|
1686
|
+
assert_equal "<errors>", xml.first(8)
|
1687
|
+
assert xml.include?("<error>Title is Wrong Create</error>")
|
1688
|
+
assert xml.include?("<error>Content Empty</error>")
|
1689
|
+
end
|
1690
|
+
|
1691
|
+
def test_validation_order
|
1692
|
+
if AR_6657
|
1693
|
+
Topic.validates_presence_of :title
|
1694
|
+
Topic.validates_length_of :title, :minimum => 2
|
1695
|
+
|
1696
|
+
GetText.set_locale_all "ja_JP.UTF-8"
|
1697
|
+
t = Topic.new("title" => "")
|
1698
|
+
assert !t.valid?
|
1699
|
+
assert_equal "タイトルを入力してください。", t.errors.on("title").first
|
1700
|
+
|
1701
|
+
GetText.set_locale_all "en"
|
1702
|
+
t = Topic.new("title" => "")
|
1703
|
+
assert !t.valid?
|
1704
|
+
assert_equal "Title can't be blank", t.errors.on("title").first
|
1705
|
+
end
|
1706
|
+
end
|
1707
|
+
|
1467
1708
|
def test_default_validates_numericality_of
|
1468
1709
|
GetText.set_locale_all "ja_JP.UTF-8"
|
1469
1710
|
Topic.validates_numericality_of :approved
|
@@ -1475,5 +1716,44 @@ class ValidationsTest < Test::Unit::TestCase
|
|
1475
1716
|
assert_equal "Approved is not a number", topic.errors.on(:approved)
|
1476
1717
|
assert_equal "Approved is not a number", topic.errors.full_messages[0]
|
1477
1718
|
end
|
1719
|
+
|
1720
|
+
def test_inherited_messages
|
1721
|
+
GetText.set_locale_all "ja_JP.UTF-8"
|
1722
|
+
Topic.validates_presence_of(:title, :content)
|
1723
|
+
|
1724
|
+
GetText.set_locale_all "ja_JP.UTF-8"
|
1725
|
+
t = Topic.create
|
1726
|
+
assert !t.save
|
1727
|
+
assert_equal "タイトルを入力してください。", t.errors.full_messages[0]
|
1728
|
+
assert_equal "内容を入力してください。", t.errors.full_messages[1]
|
1729
|
+
assert_equal "タイトルを入力してください。", t.errors.on(:title)
|
1730
|
+
assert_equal "内容を入力してください。", t.errors.on(:content)
|
1731
|
+
|
1732
|
+
t = Reply.create
|
1733
|
+
assert !t.save
|
1734
|
+
assert_equal "Replyタイトル 空です。", t.errors.full_messages[0]
|
1735
|
+
assert_equal "Reply内容 空です。", t.errors.full_messages[1]
|
1736
|
+
assert_equal "空です。", t.errors.on(:title)
|
1737
|
+
assert_equal "空です。", t.errors.on(:content)
|
1738
|
+
|
1739
|
+
t = Reply.create
|
1740
|
+
t.title = "Wrong Create"
|
1741
|
+
assert !t.save
|
1742
|
+
assert_equal "Replyタイトル が不正に生成されました。", t.errors.full_messages[0]
|
1743
|
+
assert_equal "Reply内容 空です。", t.errors.full_messages[1]
|
1744
|
+
|
1745
|
+
t = SillyReply.create
|
1746
|
+
assert !t.save
|
1747
|
+
assert_equal "Sillyタイトル 空です。", t.errors.full_messages[0]
|
1748
|
+
assert_equal "Silly内容 空です。", t.errors.full_messages[1]
|
1749
|
+
assert_equal "空です。", t.errors.on(:title)
|
1750
|
+
assert_equal "空です。", t.errors.on(:content)
|
1751
|
+
|
1752
|
+
t = SillyReply.create
|
1753
|
+
t.title = "Wrong Create"
|
1754
|
+
assert !t.save
|
1755
|
+
assert_equal "Sillyタイトル が不正に生成されました。", t.errors.full_messages[0]
|
1756
|
+
assert_equal "Silly内容 空です。", t.errors.full_messages[1]
|
1757
|
+
end
|
1478
1758
|
end
|
1479
1759
|
|