gettext 1.93.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (881) hide show
  1. data/ChangeLog +16 -1941
  2. data/ChangeLog-1 +2016 -0
  3. data/{NEWS → NEWS-1} +2 -0
  4. data/README.rdoc +251 -0
  5. data/Rakefile +46 -57
  6. data/bin/rgettext +1 -1
  7. data/bin/rmsgfmt +2 -2
  8. data/bin/rmsgmerge +3 -3
  9. data/data/locale/bg/LC_MESSAGES/rgettext.mo +0 -0
  10. data/data/locale/bs/LC_MESSAGES/rgettext.mo +0 -0
  11. data/data/locale/ca/LC_MESSAGES/rgettext.mo +0 -0
  12. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  13. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  15. data/data/locale/eo/LC_MESSAGES/rgettext.mo +0 -0
  16. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  17. data/data/locale/et/LC_MESSAGES/rgettext.mo +0 -0
  18. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/hr/LC_MESSAGES/rgettext.mo +0 -0
  20. data/data/locale/hu/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  22. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  24. data/data/locale/lv/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/nb/LC_MESSAGES/rgettext.mo +0 -0
  26. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  27. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  28. data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
  29. data/data/locale/sr/LC_MESSAGES/rgettext.mo +0 -0
  30. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  31. data/data/locale/ua/LC_MESSAGES/rgettext.mo +0 -0
  32. data/data/locale/vi/LC_MESSAGES/rgettext.mo +0 -0
  33. data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
  34. data/data/locale/zh_TW/LC_MESSAGES/rgettext.mo +0 -0
  35. data/gettext.gemspec +40 -0
  36. data/lib/gettext.rb +101 -431
  37. data/lib/gettext/cgi.rb +4 -4
  38. data/lib/gettext/class_info.rb +54 -0
  39. data/lib/gettext/{iconv.rb → core_ext/iconv.rb} +1 -0
  40. data/lib/gettext/{string.rb → core_ext/string.rb} +12 -8
  41. data/lib/gettext/locale_path.rb +107 -0
  42. data/lib/gettext/mofile.rb +314 -0
  43. data/lib/gettext/parser/erb.rb +2 -1
  44. data/lib/gettext/parser/glade.rb +2 -1
  45. data/lib/gettext/parser/ruby.rb +66 -63
  46. data/lib/gettext/poparser.rb +3 -3
  47. data/lib/gettext/textdomain.rb +97 -171
  48. data/lib/gettext/textdomain_manager.rb +224 -0
  49. data/lib/gettext/tools.rb +195 -0
  50. data/lib/gettext/{rgettext.rb → tools/rgettext.rb} +74 -77
  51. data/lib/gettext/{rmsgfmt.rb → tools/rmsgfmt.rb} +12 -26
  52. data/lib/gettext/{rmsgmerge.rb → tools/rmsgmerge.rb} +3 -6
  53. data/lib/gettext/utils.rb +18 -135
  54. data/lib/gettext/version.rb +2 -2
  55. data/po/bg/rgettext.po +84 -88
  56. data/po/bs/rgettext.po +86 -90
  57. data/po/ca/rgettext.po +85 -88
  58. data/po/cs/rgettext.po +86 -90
  59. data/po/de/{rails.po → #rails.po#} +17 -16
  60. data/po/de/rgettext.po +84 -88
  61. data/po/el/rgettext.po +85 -89
  62. data/po/eo/rgettext.po +85 -89
  63. data/po/es/rgettext.po +84 -88
  64. data/po/et/rgettext.po +84 -88
  65. data/po/fr/rgettext.po +84 -88
  66. data/po/hr/rgettext.po +86 -90
  67. data/po/hu/rgettext.po +84 -88
  68. data/po/it/rgettext.po +82 -86
  69. data/po/ja/rails.po.old +150 -0
  70. data/po/ja/rgettext.po +84 -88
  71. data/po/ko/rgettext.po +86 -90
  72. data/po/lv/rgettext.po +84 -88
  73. data/po/nb/rgettext.po +84 -88
  74. data/po/nl/rgettext.po +86 -90
  75. data/po/pt_BR/rgettext.po +84 -88
  76. data/po/rgettext.pot +54 -70
  77. data/po/ru/rgettext.po +84 -88
  78. data/po/sr/rgettext.po +84 -88
  79. data/po/sv/rgettext.po +57 -73
  80. data/po/ua/rgettext.po +85 -89
  81. data/po/vi/rgettext.po +84 -88
  82. data/po/zh/rgettext.po +83 -87
  83. data/po/zh_TW/rgettext.po +83 -87
  84. data/samples/README +4 -8
  85. data/samples/cgi/Rakefile +2 -2
  86. data/samples/cgi/cookie.cgi +1 -0
  87. data/samples/cgi/helloerb1.cgi +8 -4
  88. data/samples/cgi/helloerb2.cgi +6 -4
  89. data/samples/cgi/hellolib.rb +1 -2
  90. data/samples/cgi/index.cgi +1 -0
  91. data/samples/cgi/locale/bg/LC_MESSAGES/hellolib.mo +0 -0
  92. data/samples/cgi/locale/bs/LC_MESSAGES/hellolib.mo +0 -0
  93. data/samples/cgi/locale/ca/LC_MESSAGES/hellolib.mo +0 -0
  94. data/samples/cgi/locale/cs/LC_MESSAGES/hellolib.mo +0 -0
  95. data/samples/cgi/locale/de/LC_MESSAGES/hellolib.mo +0 -0
  96. data/samples/cgi/locale/el/LC_MESSAGES/hellolib.mo +0 -0
  97. data/samples/cgi/locale/eo/LC_MESSAGES/hellolib.mo +0 -0
  98. data/samples/cgi/locale/es/LC_MESSAGES/hellolib.mo +0 -0
  99. data/samples/cgi/locale/fr/LC_MESSAGES/hellolib.mo +0 -0
  100. data/samples/cgi/locale/hr/LC_MESSAGES/hellolib.mo +0 -0
  101. data/samples/cgi/locale/hu/LC_MESSAGES/hellolib.mo +0 -0
  102. data/samples/cgi/locale/it/LC_MESSAGES/hellolib.mo +0 -0
  103. data/samples/cgi/locale/ja/LC_MESSAGES/helloerb1.mo +0 -0
  104. data/samples/cgi/locale/ja/LC_MESSAGES/helloerb2.mo +0 -0
  105. data/samples/cgi/locale/ja/LC_MESSAGES/hellolib.mo +0 -0
  106. data/samples/cgi/locale/ja/LC_MESSAGES/main.mo +0 -0
  107. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
  108. data/samples/cgi/locale/ko/LC_MESSAGES/hellolib.mo +0 -0
  109. data/samples/cgi/locale/lv/LC_MESSAGES/hellolib.mo +0 -0
  110. data/samples/cgi/locale/nb/LC_MESSAGES/hellolib.mo +0 -0
  111. data/samples/cgi/locale/nl/LC_MESSAGES/hellolib.mo +0 -0
  112. data/samples/cgi/locale/pt_BR/LC_MESSAGES/hellolib.mo +0 -0
  113. data/samples/cgi/locale/ru/LC_MESSAGES/hellolib.mo +0 -0
  114. data/samples/cgi/locale/sr/LC_MESSAGES/hellolib.mo +0 -0
  115. data/samples/cgi/locale/ua/LC_MESSAGES/hellolib.mo +0 -0
  116. data/samples/cgi/locale/vi/LC_MESSAGES/hellolib.mo +0 -0
  117. data/samples/cgi/locale/zh/LC_MESSAGES/hellolib.mo +0 -0
  118. data/samples/cgi/locale/zh_TW/LC_MESSAGES/hellolib.mo +0 -0
  119. data/samples/cgi/po/ja/helloerb1.po +2 -2
  120. data/samples/cgi/po/ja/helloerb2.po +2 -2
  121. data/samples/cgi/po/ja/hellolib.po +2 -2
  122. data/samples/cgi/po/ja/main.po +2 -2
  123. data/samples/hello.rb +4 -3
  124. data/samples/hello2.rb +2 -1
  125. data/samples/{helloglade2.glade → hello_glade2.glade} +0 -0
  126. data/samples/{helloglade2.rb → hello_glade2.rb} +5 -4
  127. data/samples/{hellogtk2.rb → hello_gtk2.rb} +3 -3
  128. data/samples/hello_noop.rb +2 -1
  129. data/samples/hello_plural.rb +2 -1
  130. data/samples/{hellotk.rb → hello_tk.rb} +3 -2
  131. data/samples/locale/bg/LC_MESSAGES/hello.mo +0 -0
  132. data/samples/locale/bg/LC_MESSAGES/hello2.mo +0 -0
  133. data/samples/locale/bg/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  134. data/samples/locale/bg/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  135. data/samples/locale/bg/LC_MESSAGES/hello_plural.mo +0 -0
  136. data/samples/locale/bg/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  137. data/samples/locale/bs/LC_MESSAGES/hello.mo +0 -0
  138. data/samples/locale/bs/LC_MESSAGES/hello2.mo +0 -0
  139. data/samples/locale/bs/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  140. data/samples/locale/bs/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  141. data/samples/locale/bs/LC_MESSAGES/hello_plural.mo +0 -0
  142. data/samples/locale/bs/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  143. data/samples/locale/ca/LC_MESSAGES/hello.mo +0 -0
  144. data/samples/locale/ca/LC_MESSAGES/hello2.mo +0 -0
  145. data/samples/locale/ca/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  146. data/samples/locale/ca/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  147. data/samples/locale/ca/LC_MESSAGES/hello_plural.mo +0 -0
  148. data/samples/locale/ca/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  149. data/samples/locale/cs/LC_MESSAGES/hello.mo +0 -0
  150. data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
  151. data/samples/locale/cs/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  152. data/samples/locale/cs/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  153. data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
  154. data/samples/locale/cs/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  155. data/samples/locale/de/LC_MESSAGES/hello.mo +0 -0
  156. data/samples/locale/de/LC_MESSAGES/hello2.mo +0 -0
  157. data/samples/locale/de/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  158. data/samples/locale/de/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  159. data/samples/locale/de/LC_MESSAGES/hello_plural.mo +0 -0
  160. data/samples/locale/de/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  161. data/samples/locale/el/LC_MESSAGES/hello.mo +0 -0
  162. data/samples/locale/el/LC_MESSAGES/hello2.mo +0 -0
  163. data/samples/locale/el/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  164. data/samples/locale/el/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  165. data/samples/locale/el/LC_MESSAGES/hello_plural.mo +0 -0
  166. data/samples/locale/el/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  167. data/samples/locale/eo/LC_MESSAGES/hello.mo +0 -0
  168. data/samples/locale/eo/LC_MESSAGES/hello2.mo +0 -0
  169. data/samples/locale/eo/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  170. data/samples/locale/eo/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  171. data/samples/locale/eo/LC_MESSAGES/hello_plural.mo +0 -0
  172. data/samples/locale/eo/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  173. data/samples/locale/es/LC_MESSAGES/hello.mo +0 -0
  174. data/samples/locale/es/LC_MESSAGES/hello2.mo +0 -0
  175. data/samples/locale/es/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  176. data/samples/locale/es/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  177. data/samples/locale/es/LC_MESSAGES/hello_plural.mo +0 -0
  178. data/samples/locale/es/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  179. data/samples/locale/fr/LC_MESSAGES/hello.mo +0 -0
  180. data/samples/locale/fr/LC_MESSAGES/hello2.mo +0 -0
  181. data/samples/locale/fr/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  182. data/samples/locale/fr/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  183. data/samples/locale/fr/LC_MESSAGES/hello_plural.mo +0 -0
  184. data/samples/locale/fr/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  185. data/samples/locale/hr/LC_MESSAGES/hello.mo +0 -0
  186. data/samples/locale/hr/LC_MESSAGES/hello2.mo +0 -0
  187. data/samples/locale/hr/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  188. data/samples/locale/hr/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  189. data/samples/locale/hr/LC_MESSAGES/hello_plural.mo +0 -0
  190. data/samples/locale/hr/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  191. data/samples/locale/hu/LC_MESSAGES/hello.mo +0 -0
  192. data/samples/locale/hu/LC_MESSAGES/hello2.mo +0 -0
  193. data/samples/locale/hu/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  194. data/samples/locale/hu/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  195. data/samples/locale/hu/LC_MESSAGES/hello_plural.mo +0 -0
  196. data/samples/locale/hu/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  197. data/samples/locale/it/LC_MESSAGES/hello.mo +0 -0
  198. data/samples/locale/it/LC_MESSAGES/hello2.mo +0 -0
  199. data/samples/locale/it/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  200. data/samples/locale/it/LC_MESSAGES/{hellotk.mo → hello_gtk.mo} +0 -0
  201. data/samples/locale/it/LC_MESSAGES/hello_plural.mo +0 -0
  202. data/samples/locale/it/LC_MESSAGES/{hellogtk.mo → hello_tk.mo} +0 -0
  203. data/samples/locale/ja/LC_MESSAGES/hello.mo +0 -0
  204. data/samples/locale/ja/LC_MESSAGES/hello2.mo +0 -0
  205. data/samples/locale/ja/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  206. data/samples/locale/ja/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  207. data/samples/locale/ja/LC_MESSAGES/hello_plural.mo +0 -0
  208. data/samples/locale/ja/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  209. data/samples/locale/ko/LC_MESSAGES/hello.mo +0 -0
  210. data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
  211. data/samples/locale/ko/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  212. data/samples/locale/ko/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  213. data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
  214. data/samples/locale/ko/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  215. data/samples/locale/lv/LC_MESSAGES/hello.mo +0 -0
  216. data/samples/locale/lv/LC_MESSAGES/hello2.mo +0 -0
  217. data/samples/locale/lv/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  218. data/samples/locale/lv/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  219. data/samples/locale/lv/LC_MESSAGES/hello_plural.mo +0 -0
  220. data/samples/locale/lv/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  221. data/samples/locale/nb/LC_MESSAGES/hello.mo +0 -0
  222. data/samples/locale/nb/LC_MESSAGES/hello2.mo +0 -0
  223. data/samples/locale/nb/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  224. data/samples/locale/nb/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  225. data/samples/locale/nb/LC_MESSAGES/hello_plural.mo +0 -0
  226. data/samples/locale/nb/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  227. data/samples/locale/nl/LC_MESSAGES/hello.mo +0 -0
  228. data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
  229. data/samples/locale/nl/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  230. data/samples/locale/nl/LC_MESSAGES/{hellotk.mo → hello_gtk.mo} +0 -0
  231. data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
  232. data/samples/locale/nl/LC_MESSAGES/{hellogtk.mo → hello_tk.mo} +0 -0
  233. data/samples/locale/pt_BR/LC_MESSAGES/hello.mo +0 -0
  234. data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
  235. data/samples/locale/pt_BR/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  236. data/samples/locale/pt_BR/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  237. data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
  238. data/samples/locale/pt_BR/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  239. data/samples/locale/ru/LC_MESSAGES/hello.mo +0 -0
  240. data/samples/locale/ru/LC_MESSAGES/hello2.mo +0 -0
  241. data/samples/locale/ru/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  242. data/samples/locale/ru/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  243. data/samples/locale/ru/LC_MESSAGES/hello_plural.mo +0 -0
  244. data/samples/locale/ru/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  245. data/samples/locale/sr/LC_MESSAGES/hello.mo +0 -0
  246. data/samples/locale/sr/LC_MESSAGES/hello2.mo +0 -0
  247. data/samples/locale/sr/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  248. data/samples/locale/sr/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  249. data/samples/locale/sr/LC_MESSAGES/hello_plural.mo +0 -0
  250. data/samples/locale/sr/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  251. data/samples/locale/sv/LC_MESSAGES/hello.mo +0 -0
  252. data/samples/locale/sv/LC_MESSAGES/hello2.mo +0 -0
  253. data/samples/locale/sv/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  254. data/samples/locale/sv/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  255. data/samples/locale/sv/LC_MESSAGES/hello_plural.mo +0 -0
  256. data/samples/locale/sv/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  257. data/samples/locale/ua/LC_MESSAGES/hello.mo +0 -0
  258. data/samples/locale/ua/LC_MESSAGES/hello2.mo +0 -0
  259. data/samples/locale/ua/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  260. data/samples/locale/ua/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  261. data/samples/locale/ua/LC_MESSAGES/hello_plural.mo +0 -0
  262. data/samples/locale/ua/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  263. data/samples/locale/vi/LC_MESSAGES/hello.mo +0 -0
  264. data/samples/locale/vi/LC_MESSAGES/hello2.mo +0 -0
  265. data/samples/locale/vi/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  266. data/samples/locale/vi/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  267. data/samples/locale/vi/LC_MESSAGES/hello_plural.mo +0 -0
  268. data/samples/locale/vi/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  269. data/samples/locale/zh/LC_MESSAGES/hello.mo +0 -0
  270. data/samples/locale/zh/LC_MESSAGES/hello2.mo +0 -0
  271. data/samples/locale/zh/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  272. data/samples/locale/zh/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  273. data/samples/locale/zh/LC_MESSAGES/hello_plural.mo +0 -0
  274. data/samples/locale/zh/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  275. data/samples/locale/zh_TW/LC_MESSAGES/hello.mo +0 -0
  276. data/samples/locale/zh_TW/LC_MESSAGES/hello2.mo +0 -0
  277. data/samples/locale/zh_TW/LC_MESSAGES/{helloglade2.mo → hello_glade2.mo} +0 -0
  278. data/samples/locale/zh_TW/LC_MESSAGES/{hellogtk.mo → hello_gtk.mo} +0 -0
  279. data/samples/locale/zh_TW/LC_MESSAGES/hello_plural.mo +0 -0
  280. data/samples/locale/zh_TW/LC_MESSAGES/{hellotk.mo → hello_tk.mo} +0 -0
  281. data/samples/makemo.rb +3 -2
  282. data/samples/po/bg/{helloglade2.po → hello_glade2.po} +4 -4
  283. data/samples/po/bg/{hellogtk.po → hello_gtk.po} +1 -1
  284. data/samples/po/bg/{hellotk.po → hello_tk.po} +2 -2
  285. data/samples/po/bs/{helloglade2.po → hello_glade2.po} +6 -6
  286. data/samples/po/bs/{hellogtk.po → hello_gtk.po} +3 -3
  287. data/samples/po/bs/{hellotk.po → hello_tk.po} +4 -4
  288. data/samples/po/ca/{helloglade2.po → hello_glade2.po} +4 -4
  289. data/samples/po/ca/{hellogtk.po → hello_gtk.po} +1 -1
  290. data/samples/po/ca/{hellotk.po → hello_tk.po} +2 -2
  291. data/samples/po/cs/hello.po +1 -1
  292. data/samples/po/cs/hello2.po +1 -1
  293. data/samples/po/cs/{helloglade2.po → hello_glade2.po} +3 -3
  294. data/samples/po/cs/{hellogtk.po → hello_gtk.po} +2 -2
  295. data/samples/po/cs/hello_noop.po +1 -1
  296. data/samples/po/cs/{hellotk.po → hello_tk.po} +2 -2
  297. data/samples/po/de/hello.po +1 -1
  298. data/samples/po/de/hello2.po +1 -1
  299. data/samples/po/de/{helloglade2.po → hello_glade2.po} +3 -3
  300. data/samples/po/de/{hellogtk.po → hello_gtk.po} +2 -2
  301. data/samples/po/de/hello_noop.po +1 -1
  302. data/samples/po/de/{hellotk.po → hello_tk.po} +2 -2
  303. data/samples/po/el/hello.po +1 -1
  304. data/samples/po/el/{helloglade2.po → hello_glade2.po} +4 -4
  305. data/samples/po/el/{hellogtk.po → hello_gtk.po} +1 -1
  306. data/samples/po/el/{hellotk.po → hello_tk.po} +2 -2
  307. data/samples/po/eo/{helloglade2.po → hello_glade2.po} +4 -4
  308. data/samples/po/eo/{hellogtk.po → hello_gtk.po} +1 -1
  309. data/samples/po/eo/{hellotk.po → hello_tk.po} +2 -2
  310. data/samples/po/es/{helloglade2.po → hello_glade2.po} +4 -4
  311. data/samples/po/es/{hellogtk.po → hello_gtk.po} +2 -2
  312. data/samples/po/es/{hellotk.po → hello_tk.po} +2 -2
  313. data/samples/po/fr/{helloglade2.po → hello_glade2.po} +4 -4
  314. data/samples/po/fr/{hellogtk.po → hello_gtk.po} +2 -2
  315. data/samples/po/fr/{hellotk.po → hello_tk.po} +2 -2
  316. data/samples/po/{helloglade2.pot → hello_glade2.pot} +4 -4
  317. data/samples/po/{hellogtk.pot → hello_gtk.pot} +1 -1
  318. data/samples/po/{hellotk.pot → hello_tk.pot} +2 -2
  319. data/samples/po/hr/{helloglade2.po → hello_glade2.po} +6 -6
  320. data/samples/po/hr/{hellogtk.po → hello_gtk.po} +3 -3
  321. data/samples/po/hr/{hellotk.po → hello_tk.po} +4 -4
  322. data/samples/po/hu/{helloglade2.po → hello_glade2.po} +4 -4
  323. data/samples/po/hu/{hellogtk.po → hello_gtk.po} +1 -1
  324. data/samples/po/hu/{hellotk.po → hello_tk.po} +2 -2
  325. data/samples/po/it/hello.po +1 -1
  326. data/samples/po/it/hello2.po +1 -1
  327. data/samples/po/it/{helloglade2.po → hello_glade2.po} +4 -4
  328. data/samples/po/it/{hellogtk.po → hello_gtk.po} +2 -2
  329. data/samples/po/it/hello_noop.po +1 -1
  330. data/samples/po/it/{hellotk.po → hello_tk.po} +2 -2
  331. data/samples/po/ja/{helloglade2.po → hello_glade2.po} +4 -4
  332. data/samples/po/ja/{hellogtk.po → hello_gtk.po} +2 -2
  333. data/samples/po/ja/{hellotk.po → hello_tk.po} +2 -2
  334. data/samples/po/ko/hello.po +1 -1
  335. data/samples/po/ko/hello2.po +1 -1
  336. data/samples/po/ko/{helloglade2.po → hello_glade2.po} +3 -3
  337. data/samples/po/ko/{hellogtk.po → hello_gtk.po} +2 -2
  338. data/samples/po/ko/hello_noop.po +1 -1
  339. data/samples/po/ko/{hellotk.po → hello_tk.po} +1 -1
  340. data/samples/po/lv/{helloglade2.po → hello_glade2.po} +4 -4
  341. data/samples/po/lv/{hellogtk.po → hello_gtk.po} +1 -1
  342. data/samples/po/lv/{hellotk.po → hello_tk.po} +2 -2
  343. data/samples/po/nb/{helloglade2.po → hello_glade2.po} +5 -6
  344. data/samples/po/nb/{hellogtk.po → hello_gtk.po} +1 -1
  345. data/samples/po/nb/{hellotk.po → hello_tk.po} +2 -2
  346. data/samples/po/nl/hello.po +1 -1
  347. data/samples/po/nl/hello2.po +1 -1
  348. data/samples/po/nl/{helloglade2.po → hello_glade2.po} +5 -5
  349. data/samples/po/nl/{hellogtk.po → hello_gtk.po} +2 -2
  350. data/samples/po/nl/hello_noop.po +1 -1
  351. data/samples/po/nl/hello_plural.po +1 -1
  352. data/samples/po/nl/{hellotk.po → hello_tk.po} +2 -2
  353. data/samples/po/pt_BR/{helloglade2.po → hello_glade2.po} +4 -4
  354. data/samples/po/pt_BR/{hellogtk.po → hello_gtk.po} +1 -1
  355. data/samples/po/pt_BR/{hellotk.po → hello_tk.po} +0 -0
  356. data/samples/po/ru/{helloglade2.po → hello_glade2.po} +5 -5
  357. data/samples/po/ru/{hellogtk.po → hello_gtk.po} +3 -3
  358. data/samples/po/ru/{hellotk.po → hello_tk.po} +3 -3
  359. data/samples/po/sr/{helloglade2.po → hello_glade2.po} +4 -4
  360. data/samples/po/sr/{hellogtk.po → hello_gtk.po} +1 -1
  361. data/samples/po/sr/{hellotk.po → hello_tk.po} +2 -2
  362. data/samples/po/sv/{helloglade2.po → hello_glade2.po} +4 -4
  363. data/samples/po/sv/{hellogtk.po → hello_gtk.po} +1 -1
  364. data/samples/po/sv/{hellotk.po → hello_tk.po} +2 -2
  365. data/samples/po/test.rb +11 -0
  366. data/samples/po/ua/{helloglade2.po → hello_glade2.po} +4 -4
  367. data/samples/po/ua/{hellogtk.po → hello_gtk.po} +1 -1
  368. data/samples/po/ua/{hellotk.po → hello_tk.po} +2 -2
  369. data/samples/po/vi/{helloglade2.po → hello_glade2.po} +4 -4
  370. data/samples/po/vi/{hellogtk.po → hello_gtk.po} +1 -1
  371. data/samples/po/vi/{hellotk.po → hello_tk.po} +2 -2
  372. data/samples/po/zh/{helloglade2.po → hello_glade2.po} +4 -4
  373. data/samples/po/zh/{hellogtk.po → hello_gtk.po} +2 -2
  374. data/samples/po/zh/{hellotk.po → hello_tk.po} +2 -2
  375. data/samples/po/zh_TW/{helloglade2.po → hello_glade2.po} +4 -4
  376. data/samples/po/zh_TW/{hellogtk.po → hello_gtk.po} +1 -1
  377. data/samples/po/zh_TW/{hellotk.po → hello_tk.po} +2 -2
  378. data/src/poparser.ry +1 -1
  379. data/test/README +1 -18
  380. data/test/Rakefile +14 -41
  381. data/test/locale/cr/LC_MESSAGES/plural.mo +0 -0
  382. data/test/locale/da/LC_MESSAGES/plural.mo +0 -0
  383. data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
  384. data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
  385. data/test/locale/fr/LC_MESSAGES/test1.mo +0 -0
  386. data/test/locale/fr/LC_MESSAGES/test2.mo +0 -0
  387. data/test/locale/fr/LC_MESSAGES/test6.mo +0 -0
  388. data/test/locale/ir/LC_MESSAGES/plural.mo +0 -0
  389. data/test/locale/ja/LC_MESSAGES/npgettext.mo +0 -0
  390. data/test/locale/ja/LC_MESSAGES/{test_nsgettext.mo → nsgettext.mo} +0 -0
  391. data/test/locale/ja/LC_MESSAGES/{test_pgettext.mo → pgettext.mo} +0 -0
  392. data/test/locale/ja/LC_MESSAGES/plural_error.mo +0 -0
  393. data/test/locale/ja/LC_MESSAGES/{test_rubyparser.mo → rubyparser.mo} +0 -0
  394. data/test/locale/ja/LC_MESSAGES/{test_sgettext.mo → sgettext.mo} +0 -0
  395. data/test/locale/ja/LC_MESSAGES/test2.mo +0 -0
  396. data/test/locale/la/LC_MESSAGES/plural.mo +0 -0
  397. data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
  398. data/test/locale/li/LC_MESSAGES/plural.mo +0 -0
  399. data/test/locale/po/LC_MESSAGES/plural.mo +0 -0
  400. data/test/locale/sl/LC_MESSAGES/plural.mo +0 -0
  401. data/test/po/fr/test1.po +3 -3
  402. data/test/po/fr/test6.po +1 -1
  403. data/test/po/ja/{test_npgettext.po → npgettext.po} +2 -2
  404. data/test/po/ja/{test_nsgettext.po → nsgettext.po} +8 -8
  405. data/test/po/ja/{test_pgettext.po → pgettext.po} +2 -2
  406. data/test/po/ja/{test_rubyparser.po → rubyparser.po} +0 -0
  407. data/test/po/ja/{test_sgettext.po → sgettext.po} +8 -8
  408. data/test/po/ja/test1.po +2 -2
  409. data/test/test_class_info.rb +80 -0
  410. data/test/test_gettext.rb +118 -257
  411. data/test/test_locale_path.rb +37 -0
  412. data/test/test_parser.rb +6 -105
  413. data/test/test_string.rb +1 -2
  414. data/test/test_textdomain_bind.rb +37 -0
  415. data/test/test_textdomain_multi.rb +69 -0
  416. data/test/test_textdomain_toplevel.rb +42 -0
  417. data/test/test_thread.rb +39 -0
  418. data/test/testlib/N_.rb +1 -1
  419. data/test/testlib/erb.rhtml +1 -1
  420. data/test/testlib/erb.rxml +1 -1
  421. data/test/testlib/gettext.rb +1 -1
  422. data/test/testlib/helper.rb +11 -0
  423. data/test/testlib/multi_textdomain.rb +119 -0
  424. data/test/testlib/ngettext.rb +1 -1
  425. data/test/testlib/npgettext.rb +1 -3
  426. data/test/testlib/nsgettext.rb +1 -3
  427. data/test/testlib/pgettext.rb +1 -3
  428. data/test/testlib/sgettext.rb +1 -3
  429. data/test/testlib/{testlib1.rb → simple.rb} +3 -4
  430. data/{samples/rails/public/favicon.ico → test/tools/files/app.pot} +0 -0
  431. data/test/{rails/public/favicon.ico → tools/files/de/app.po} +0 -0
  432. data/test/tools/files/en/app.po +0 -0
  433. data/test/tools/files/en/test.po +21 -0
  434. data/test/tools/files/simple_1.po +2 -0
  435. data/test/tools/files/simple_2.po +2 -0
  436. data/test/tools/files/simple_translation.rb +1 -0
  437. data/test/tools/files/version.po +7 -0
  438. data/test/tools/test.pot +21 -0
  439. data/test/tools/test_tools.rb +61 -0
  440. metadata +224 -853
  441. data/README +0 -177
  442. data/data/locale/bg/LC_MESSAGES/rails.mo +0 -0
  443. data/data/locale/bs/LC_MESSAGES/rails.mo +0 -0
  444. data/data/locale/ca/LC_MESSAGES/rails.mo +0 -0
  445. data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
  446. data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
  447. data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
  448. data/data/locale/eo/LC_MESSAGES/rails.mo +0 -0
  449. data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
  450. data/data/locale/et/LC_MESSAGES/rails.mo +0 -0
  451. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  452. data/data/locale/hr/LC_MESSAGES/rails.mo +0 -0
  453. data/data/locale/hu/LC_MESSAGES/rails.mo +0 -0
  454. data/data/locale/it/LC_MESSAGES/rails.mo +0 -0
  455. data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
  456. data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
  457. data/data/locale/lv/LC_MESSAGES/rails.mo +0 -0
  458. data/data/locale/nb/LC_MESSAGES/rails.mo +0 -0
  459. data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
  460. data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
  461. data/data/locale/ru/LC_MESSAGES/rails.mo +0 -0
  462. data/data/locale/sr/LC_MESSAGES/rails.mo +0 -0
  463. data/data/locale/ua/LC_MESSAGES/rails.mo +0 -0
  464. data/data/locale/vi/LC_MESSAGES/rails.mo +0 -0
  465. data/data/locale/zh/LC_MESSAGES/rails.mo +0 -0
  466. data/data/locale/zh_TW/LC_MESSAGES/rails.mo +0 -0
  467. data/doc/classes/ActionView/Helpers/FormBuilder.html +0 -154
  468. data/doc/classes/ActionView/TemplateFinder.html +0 -152
  469. data/doc/classes/ActiveRecord/Base.html +0 -360
  470. data/doc/classes/ActiveRecord/ConnectionAdapters/Column.html +0 -182
  471. data/doc/classes/ActiveRecord/Migration.html +0 -118
  472. data/doc/classes/GetText.html +0 -2003
  473. data/doc/classes/GetText/ActiveRecordParser.html +0 -236
  474. data/doc/classes/GetText/Container.html +0 -119
  475. data/doc/classes/GetText/ErbContainer.html +0 -223
  476. data/doc/classes/GetText/ErbParser.html +0 -156
  477. data/doc/classes/GetText/GladeParser.html +0 -133
  478. data/doc/classes/GetText/NoboundTextDomainError.html +0 -119
  479. data/doc/classes/GetText/PoParser.html +0 -169
  480. data/doc/classes/GetText/Rails.html +0 -293
  481. data/doc/classes/GetText/RubyParser.html +0 -133
  482. data/doc/classes/GetText/TextDomain.html +0 -572
  483. data/doc/classes/GetText/TextDomainManager.html +0 -443
  484. data/doc/classes/Iconv.html +0 -257
  485. data/doc/classes/Iconv/Failure.html +0 -105
  486. data/doc/classes/Iconv/IllegalSequence.html +0 -118
  487. data/doc/classes/Iconv/InvalidCharacter.html +0 -118
  488. data/doc/classes/Iconv/InvalidEncoding.html +0 -118
  489. data/doc/classes/Locale.html +0 -840
  490. data/doc/classes/Locale/Object.html +0 -803
  491. data/doc/classes/Locale/SystemBase.html +0 -271
  492. data/doc/classes/Locale/SystemCGI.html +0 -312
  493. data/doc/classes/Locale/SystemJRuby.html +0 -112
  494. data/doc/classes/Locale/SystemPosix.html +0 -163
  495. data/doc/classes/Locale/SystemWin32.html +0 -167
  496. data/doc/classes/Locale/SystemWin32Table.html +0 -123
  497. data/doc/classes/MOFile.html +0 -695
  498. data/doc/classes/MOFile/HeaderRev1.html +0 -150
  499. data/doc/classes/MOFile/InvalidFormat.html +0 -111
  500. data/doc/classes/Module.html +0 -158
  501. data/doc/classes/String.html +0 -225
  502. data/doc/created.rid +0 -1
  503. data/doc/files/ChangeLog.html +0 -2623
  504. data/doc/files/README.html +0 -531
  505. data/doc/files/lib/gettext/active_record_rb.html +0 -110
  506. data/doc/files/lib/gettext/cgi_rb.html +0 -110
  507. data/doc/files/lib/gettext/container_rb.html +0 -108
  508. data/doc/files/lib/gettext/erb_rb.html +0 -109
  509. data/doc/files/lib/gettext/iconv_rb.html +0 -109
  510. data/doc/files/lib/gettext/mo_rb.html +0 -109
  511. data/doc/files/lib/gettext/parser/active_record_rb.html +0 -119
  512. data/doc/files/lib/gettext/parser/erb_rb.html +0 -109
  513. data/doc/files/lib/gettext/parser/glade_rb.html +0 -109
  514. data/doc/files/lib/gettext/parser/ruby_rb.html +0 -110
  515. data/doc/files/lib/gettext/poparser_rb.html +0 -108
  516. data/doc/files/lib/gettext/rails_compat_rb.html +0 -108
  517. data/doc/files/lib/gettext/rails_rb.html +0 -112
  518. data/doc/files/lib/gettext/rgettext_rb.html +0 -110
  519. data/doc/files/lib/gettext/rmsgfmt_rb.html +0 -113
  520. data/doc/files/lib/gettext/rmsgmerge_rb.html +0 -112
  521. data/doc/files/lib/gettext/string_rb.html +0 -101
  522. data/doc/files/lib/gettext/textdomain_rb.html +0 -109
  523. data/doc/files/lib/gettext/textdomainmanager_rb.html +0 -109
  524. data/doc/files/lib/gettext/utils_rb.html +0 -111
  525. data/doc/files/lib/gettext/version_rb.html +0 -101
  526. data/doc/files/lib/gettext_rb.html +0 -113
  527. data/doc/files/lib/locale/base_rb.html +0 -101
  528. data/doc/files/lib/locale/cgi_rb.html +0 -108
  529. data/doc/files/lib/locale/jruby_rb.html +0 -110
  530. data/doc/files/lib/locale/object_rb.html +0 -101
  531. data/doc/files/lib/locale/posix_rb.html +0 -108
  532. data/doc/files/lib/locale/win32_rb.html +0 -110
  533. data/doc/files/lib/locale/win32_table_rb.html +0 -101
  534. data/doc/files/lib/locale_rb.html +0 -111
  535. data/doc/fr_class_index.html +0 -61
  536. data/doc/fr_file_index.html +0 -58
  537. data/doc/fr_method_index.html +0 -163
  538. data/doc/index.html +0 -24
  539. data/doc/rdoc-style.css +0 -208
  540. data/lib/gettext/active_record.rb +0 -357
  541. data/lib/gettext/container.rb +0 -19
  542. data/lib/gettext/erb.rb +0 -56
  543. data/lib/gettext/mo.rb +0 -320
  544. data/lib/gettext/parser/active_record.rb +0 -184
  545. data/lib/gettext/rails.rb +0 -547
  546. data/lib/gettext/rails_compat.rb +0 -16
  547. data/lib/gettext/textdomainmanager.rb +0 -103
  548. data/lib/locale.rb +0 -183
  549. data/lib/locale/base.rb +0 -60
  550. data/lib/locale/cgi.rb +0 -103
  551. data/lib/locale/jruby.rb +0 -36
  552. data/lib/locale/object.rb +0 -237
  553. data/lib/locale/posix.rb +0 -36
  554. data/lib/locale/win32.rb +0 -49
  555. data/lib/locale/win32_table.rb +0 -235
  556. data/po/bg/rails.po +0 -169
  557. data/po/bs/rails.po +0 -185
  558. data/po/ca/rails.po +0 -170
  559. data/po/cs/rails.po +0 -189
  560. data/po/el/rails.po +0 -169
  561. data/po/eo/rails.po +0 -170
  562. data/po/es/rails.po +0 -170
  563. data/po/et/rails.po +0 -170
  564. data/po/fr/rails.po +0 -174
  565. data/po/hr/rails.po +0 -186
  566. data/po/hu/rails.po +0 -170
  567. data/po/it/rails.po +0 -176
  568. data/po/ja/rails.po +0 -170
  569. data/po/ko/rails.po +0 -174
  570. data/po/lv/rails.po +0 -175
  571. data/po/nb/rails.po +0 -171
  572. data/po/nl/rails.po +0 -178
  573. data/po/pt_BR/rails.po +0 -171
  574. data/po/rails.pot +0 -170
  575. data/po/ru/rails.po +0 -178
  576. data/po/sr/rails.po +0 -178
  577. data/po/ua/rails.po +0 -184
  578. data/po/vi/rails.po +0 -170
  579. data/po/zh/rails.po +0 -166
  580. data/po/zh_TW/rails.po +0 -166
  581. data/post-setup.rb +0 -17
  582. data/pre-setup.rb +0 -20
  583. data/samples/hello_textdomain.rb +0 -21
  584. data/samples/hellogtk.rb +0 -27
  585. data/samples/rails/README +0 -73
  586. data/samples/rails/Rakefile +0 -10
  587. data/samples/rails/app/controllers/application.rb +0 -40
  588. data/samples/rails/app/controllers/articles_controller.rb +0 -96
  589. data/samples/rails/app/helpers/application_helper.rb +0 -3
  590. data/samples/rails/app/helpers/articles_helper.rb +0 -60
  591. data/samples/rails/app/models/article.rb +0 -16
  592. data/samples/rails/app/views/articles/edit.html.erb +0 -21
  593. data/samples/rails/app/views/articles/index.html.erb +0 -17
  594. data/samples/rails/app/views/articles/new.html.erb +0 -19
  595. data/samples/rails/app/views/articles/show.html.erb +0 -6
  596. data/samples/rails/app/views/layouts/articles.html.erb +0 -26
  597. data/samples/rails/config/boot.rb +0 -109
  598. data/samples/rails/config/database.yml +0 -47
  599. data/samples/rails/config/environment.rb +0 -60
  600. data/samples/rails/config/environments/development.rb +0 -18
  601. data/samples/rails/config/environments/production.rb +0 -18
  602. data/samples/rails/config/environments/test.rb +0 -22
  603. data/samples/rails/config/initializers/inflections.rb +0 -10
  604. data/samples/rails/config/initializers/mime_types.rb +0 -5
  605. data/samples/rails/config/routes.rb +0 -38
  606. data/samples/rails/db/migrate/001_create_articles.rb +0 -14
  607. data/samples/rails/db/schema.rb +0 -20
  608. data/samples/rails/lib/tasks/gettext.rake +0 -16
  609. data/samples/rails/locale/bg/LC_MESSAGES/blog.mo +0 -0
  610. data/samples/rails/locale/bs/LC_MESSAGES/blog.mo +0 -0
  611. data/samples/rails/locale/ca/LC_MESSAGES/blog.mo +0 -0
  612. data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
  613. data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
  614. data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
  615. data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
  616. data/samples/rails/locale/eo/LC_MESSAGES/blog.mo +0 -0
  617. data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
  618. data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
  619. data/samples/rails/locale/hr/LC_MESSAGES/blog.mo +0 -0
  620. data/samples/rails/locale/hu/LC_MESSAGES/blog.mo +0 -0
  621. data/samples/rails/locale/it/LC_MESSAGES/blog.mo +0 -0
  622. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  623. data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
  624. data/samples/rails/locale/lv/LC_MESSAGES/blog.mo +0 -0
  625. data/samples/rails/locale/nb/LC_MESSAGES/blog.mo +0 -0
  626. data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
  627. data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
  628. data/samples/rails/locale/ru/LC_MESSAGES/blog.mo +0 -0
  629. data/samples/rails/locale/sr/LC_MESSAGES/blog.mo +0 -0
  630. data/samples/rails/locale/ua/LC_MESSAGES/blog.mo +0 -0
  631. data/samples/rails/locale/vi/LC_MESSAGES/blog.mo +0 -0
  632. data/samples/rails/locale/zh/LC_MESSAGES/blog.mo +0 -0
  633. data/samples/rails/locale/zh_TW/LC_MESSAGES/blog.mo +0 -0
  634. data/samples/rails/po/bg/blog.po +0 -101
  635. data/samples/rails/po/blog.pot +0 -102
  636. data/samples/rails/po/bs/blog.po +0 -103
  637. data/samples/rails/po/ca/blog.po +0 -101
  638. data/samples/rails/po/cs/blog.po +0 -104
  639. data/samples/rails/po/de/blog.po +0 -104
  640. data/samples/rails/po/el/blog.po +0 -102
  641. data/samples/rails/po/en/blog.po +0 -103
  642. data/samples/rails/po/eo/blog.po +0 -102
  643. data/samples/rails/po/es/blog.po +0 -101
  644. data/samples/rails/po/fr/blog.po +0 -102
  645. data/samples/rails/po/hr/blog.po +0 -102
  646. data/samples/rails/po/hu/blog.po +0 -101
  647. data/samples/rails/po/it/blog.po +0 -102
  648. data/samples/rails/po/ja/blog.po +0 -101
  649. data/samples/rails/po/ko/blog.po +0 -102
  650. data/samples/rails/po/lv/blog.po +0 -103
  651. data/samples/rails/po/nb/blog.po +0 -102
  652. data/samples/rails/po/nl/blog.po +0 -102
  653. data/samples/rails/po/pt_BR/blog.po +0 -102
  654. data/samples/rails/po/ru/blog.po +0 -102
  655. data/samples/rails/po/sr/blog.po +0 -103
  656. data/samples/rails/po/ua/blog.po +0 -105
  657. data/samples/rails/po/vi/blog.po +0 -102
  658. data/samples/rails/po/zh/blog.po +0 -101
  659. data/samples/rails/po/zh_TW/blog.po +0 -103
  660. data/samples/rails/public/404.html +0 -30
  661. data/samples/rails/public/422.html +0 -30
  662. data/samples/rails/public/500.html +0 -30
  663. data/samples/rails/public/dispatch.cgi +0 -10
  664. data/samples/rails/public/dispatch.fcgi +0 -24
  665. data/samples/rails/public/dispatch.rb +0 -10
  666. data/samples/rails/public/images/rails.png +0 -0
  667. data/samples/rails/public/index.html +0 -277
  668. data/samples/rails/public/javascripts/application.js +0 -2
  669. data/samples/rails/public/javascripts/controls.js +0 -963
  670. data/samples/rails/public/javascripts/dragdrop.js +0 -972
  671. data/samples/rails/public/javascripts/effects.js +0 -1120
  672. data/samples/rails/public/javascripts/prototype.js +0 -4225
  673. data/samples/rails/public/robots.txt +0 -1
  674. data/samples/rails/public/stylesheets/blog.css +0 -136
  675. data/samples/rails/public/stylesheets/scaffold.css +0 -74
  676. data/samples/rails/script/about +0 -3
  677. data/samples/rails/script/breakpointer +0 -3
  678. data/samples/rails/script/console +0 -3
  679. data/samples/rails/script/destroy +0 -3
  680. data/samples/rails/script/generate +0 -3
  681. data/samples/rails/script/performance/benchmarker +0 -3
  682. data/samples/rails/script/performance/profiler +0 -3
  683. data/samples/rails/script/plugin +0 -3
  684. data/samples/rails/script/process/reaper +0 -3
  685. data/samples/rails/script/process/spawner +0 -3
  686. data/samples/rails/script/process/spinner +0 -3
  687. data/samples/rails/script/runner +0 -3
  688. data/samples/rails/script/server +0 -3
  689. data/samples/rails/test/fixtures/articles.yml +0 -5
  690. data/samples/rails/test/functional/articles_controller_test.rb +0 -51
  691. data/samples/rails/test/test_helper.rb +0 -38
  692. data/samples/rails/test/unit/article_test.rb +0 -7
  693. data/samples/rails/vendor/plugins/gettext/README +0 -17
  694. data/samples/rails/vendor/plugins/gettext/Rakefile +0 -17
  695. data/samples/rails/vendor/plugins/gettext/init.rb +0 -21
  696. data/samples/rails/vendor/plugins/gettext/lib/gettext_plugin.rb +0 -33
  697. data/samples/rails/vendor/plugins/gettext/locale/bg/LC_MESSAGES/gettext_plugin.mo +0 -0
  698. data/samples/rails/vendor/plugins/gettext/locale/bs/LC_MESSAGES/gettext_plugin.mo +0 -0
  699. data/samples/rails/vendor/plugins/gettext/locale/ca/LC_MESSAGES/gettext_plugin.mo +0 -0
  700. data/samples/rails/vendor/plugins/gettext/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
  701. data/samples/rails/vendor/plugins/gettext/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
  702. data/samples/rails/vendor/plugins/gettext/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
  703. data/samples/rails/vendor/plugins/gettext/locale/eo/LC_MESSAGES/gettext_plugin.mo +0 -0
  704. data/samples/rails/vendor/plugins/gettext/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
  705. data/samples/rails/vendor/plugins/gettext/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
  706. data/samples/rails/vendor/plugins/gettext/locale/hr/LC_MESSAGES/gettext_plugin.mo +0 -0
  707. data/samples/rails/vendor/plugins/gettext/locale/hu/LC_MESSAGES/gettext_plugin.mo +0 -0
  708. data/samples/rails/vendor/plugins/gettext/locale/it/LC_MESSAGES/gettext_plugin.mo +0 -0
  709. data/samples/rails/vendor/plugins/gettext/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
  710. data/samples/rails/vendor/plugins/gettext/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
  711. data/samples/rails/vendor/plugins/gettext/locale/lv/LC_MESSAGES/gettext_plugin.mo +0 -0
  712. data/samples/rails/vendor/plugins/gettext/locale/nb/LC_MESSAGES/gettext_plugin.mo +0 -0
  713. data/samples/rails/vendor/plugins/gettext/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
  714. data/samples/rails/vendor/plugins/gettext/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
  715. data/samples/rails/vendor/plugins/gettext/locale/ru/LC_MESSAGES/gettext_plugin.mo +0 -0
  716. data/samples/rails/vendor/plugins/gettext/locale/sr/LC_MESSAGES/gettext_plugin.mo +0 -0
  717. data/samples/rails/vendor/plugins/gettext/locale/ua/LC_MESSAGES/gettext_plugin.mo +0 -0
  718. data/samples/rails/vendor/plugins/gettext/locale/vi/LC_MESSAGES/gettext_plugin.mo +0 -0
  719. data/samples/rails/vendor/plugins/gettext/locale/zh/LC_MESSAGES/gettext_plugin.mo +0 -0
  720. data/samples/rails/vendor/plugins/gettext/locale/zh_TW/LC_MESSAGES/gettext_plugin.mo +0 -0
  721. data/samples/rails/vendor/plugins/gettext/po/bg/gettext_plugin.po +0 -27
  722. data/samples/rails/vendor/plugins/gettext/po/bs/gettext_plugin.po +0 -27
  723. data/samples/rails/vendor/plugins/gettext/po/ca/gettext_plugin.po +0 -27
  724. data/samples/rails/vendor/plugins/gettext/po/cs/gettext_plugin.po +0 -29
  725. data/samples/rails/vendor/plugins/gettext/po/de/gettext_plugin.po +0 -29
  726. data/samples/rails/vendor/plugins/gettext/po/el/gettext_plugin.po +0 -27
  727. data/samples/rails/vendor/plugins/gettext/po/eo/gettext_plugin.po +0 -28
  728. data/samples/rails/vendor/plugins/gettext/po/es/gettext_plugin.po +0 -28
  729. data/samples/rails/vendor/plugins/gettext/po/fr/gettext_plugin.po +0 -27
  730. data/samples/rails/vendor/plugins/gettext/po/gettext_plugin.pot +0 -28
  731. data/samples/rails/vendor/plugins/gettext/po/hr/gettext_plugin.po +0 -27
  732. data/samples/rails/vendor/plugins/gettext/po/hu/gettext_plugin.po +0 -27
  733. data/samples/rails/vendor/plugins/gettext/po/it/gettext_plugin.po +0 -27
  734. data/samples/rails/vendor/plugins/gettext/po/ja/gettext_plugin.po +0 -28
  735. data/samples/rails/vendor/plugins/gettext/po/ko/gettext_plugin.po +0 -27
  736. data/samples/rails/vendor/plugins/gettext/po/lv/gettext_plugin.po +0 -28
  737. data/samples/rails/vendor/plugins/gettext/po/nb/gettext_plugin.po +0 -29
  738. data/samples/rails/vendor/plugins/gettext/po/nl/gettext_plugin.po +0 -28
  739. data/samples/rails/vendor/plugins/gettext/po/pt_BR/gettext_plugin.po +0 -27
  740. data/samples/rails/vendor/plugins/gettext/po/ru/gettext_plugin.po +0 -25
  741. data/samples/rails/vendor/plugins/gettext/po/sr/gettext_plugin.po +0 -28
  742. data/samples/rails/vendor/plugins/gettext/po/ua/gettext_plugin.po +0 -30
  743. data/samples/rails/vendor/plugins/gettext/po/vi/gettext_plugin.po +0 -27
  744. data/samples/rails/vendor/plugins/gettext/po/zh/gettext_plugin.po +0 -27
  745. data/samples/rails/vendor/plugins/gettext/po/zh_TW/gettext_plugin.po +0 -29
  746. data/setup.rb +0 -1585
  747. data/test/benchmark.rb +0 -28
  748. data/test/db/mysql.drop.sql +0 -5
  749. data/test/db/mysql.sql +0 -57
  750. data/test/fixtures/book.rb +0 -3
  751. data/test/fixtures/developer.rb +0 -5
  752. data/test/fixtures/developers.yml +0 -21
  753. data/test/fixtures/inept_wizard.rb +0 -3
  754. data/test/fixtures/people.yml +0 -6
  755. data/test/fixtures/reply.rb +0 -40
  756. data/test/fixtures/topic.rb +0 -68
  757. data/test/fixtures/topics.yml +0 -22
  758. data/test/fixtures/user.rb +0 -3
  759. data/test/fixtures/wizard.rb +0 -5
  760. data/test/locale/ja/LC_MESSAGES/active_record.mo +0 -0
  761. data/test/locale/ja/LC_MESSAGES/test_npgettext.mo +0 -0
  762. data/test/po/active_record.pot +0 -393
  763. data/test/po/ja/active_record.po +0 -392
  764. data/test/rails/README +0 -5
  765. data/test/rails/Rakefile +0 -36
  766. data/test/rails/app/controllers/application.rb +0 -8
  767. data/test/rails/app/controllers/articles_controller.rb +0 -61
  768. data/test/rails/app/controllers/mailer_controller.rb +0 -19
  769. data/test/rails/app/controllers/users_controller.rb +0 -11
  770. data/test/rails/app/helpers/application_helper.rb +0 -3
  771. data/test/rails/app/helpers/articles_helper.rb +0 -2
  772. data/test/rails/app/helpers/mailer_helper.rb +0 -2
  773. data/test/rails/app/models/article.rb +0 -5
  774. data/test/rails/app/models/mailer.rb +0 -38
  775. data/test/rails/app/models/user.rb +0 -4
  776. data/test/rails/app/views/articles/_form.html.erb +0 -13
  777. data/test/rails/app/views/articles/_form_fr.html.erb +0 -1
  778. data/test/rails/app/views/articles/active_form_error.html.erb +0 -1
  779. data/test/rails/app/views/articles/change_title_error_messages_for.html.erb +0 -21
  780. data/test/rails/app/views/articles/edit.html.erb +0 -9
  781. data/test/rails/app/views/articles/list.html.erb +0 -27
  782. data/test/rails/app/views/articles/list_fr.html.erb +0 -1
  783. data/test/rails/app/views/articles/multi_error_messages_for.html.erb +0 -19
  784. data/test/rails/app/views/articles/new.html.erb +0 -8
  785. data/test/rails/app/views/articles/show.html.erb +0 -29
  786. data/test/rails/app/views/layouts/application.html.erb +0 -14
  787. data/test/rails/app/views/layouts/mailer.html.erb +0 -20
  788. data/test/rails/app/views/layouts/users.html.erb +0 -13
  789. data/test/rails/app/views/mailer/coverpage.rhtml +0 -6
  790. data/test/rails/app/views/mailer/coverpage_fr.rhtml +0 -6
  791. data/test/rails/app/views/mailer/singlepart.rhtml +0 -3
  792. data/test/rails/app/views/mailer/singlepart_fr.rhtml +0 -3
  793. data/test/rails/app/views/users/custom_error_message.html.erb +0 -13
  794. data/test/rails/app/views/users/custom_error_message_fr.html.erb +0 -13
  795. data/test/rails/config/boot.rb +0 -109
  796. data/test/rails/config/database.yml +0 -36
  797. data/test/rails/config/environment.rb +0 -70
  798. data/test/rails/config/environments/development.rb +0 -18
  799. data/test/rails/config/environments/production.rb +0 -18
  800. data/test/rails/config/environments/test.rb +0 -19
  801. data/test/rails/config/routes.rb +0 -23
  802. data/test/rails/db/schema.rb +0 -34
  803. data/test/rails/po/ja/rails_test.po +0 -149
  804. data/test/rails/po/rails_test.pot +0 -149
  805. data/test/rails/public/404.html +0 -30
  806. data/test/rails/public/500.html +0 -30
  807. data/test/rails/public/dispatch.cgi +0 -10
  808. data/test/rails/public/dispatch.fcgi +0 -24
  809. data/test/rails/public/dispatch.rb +0 -10
  810. data/test/rails/public/images/rails.png +0 -0
  811. data/test/rails/public/index.html +0 -277
  812. data/test/rails/public/javascripts/application.js +0 -2
  813. data/test/rails/public/javascripts/controls.js +0 -963
  814. data/test/rails/public/javascripts/dragdrop.js +0 -972
  815. data/test/rails/public/javascripts/effects.js +0 -1120
  816. data/test/rails/public/javascripts/prototype.js +0 -4225
  817. data/test/rails/public/robots.txt +0 -1
  818. data/test/rails/public/stylesheets/scaffold.css +0 -74
  819. data/test/rails/script/about +0 -3
  820. data/test/rails/script/breakpointer +0 -3
  821. data/test/rails/script/console +0 -3
  822. data/test/rails/script/destroy +0 -3
  823. data/test/rails/script/generate +0 -3
  824. data/test/rails/script/performance/benchmarker +0 -3
  825. data/test/rails/script/performance/profiler +0 -3
  826. data/test/rails/script/plugin +0 -3
  827. data/test/rails/script/process/inspector +0 -3
  828. data/test/rails/script/process/reaper +0 -3
  829. data/test/rails/script/process/spawner +0 -3
  830. data/test/rails/script/runner +0 -3
  831. data/test/rails/script/server +0 -3
  832. data/test/rails/test/fixtures/articles.yml +0 -11
  833. data/test/rails/test/fixtures/users.yml +0 -5
  834. data/test/rails/test/functional/articles_controller_test.rb +0 -119
  835. data/test/rails/test/functional/mailer_controller_test.rb +0 -95
  836. data/test/rails/test/functional/users_controller_test.rb +0 -65
  837. data/test/rails/test/integration/general_stories_test.rb +0 -58
  838. data/test/rails/test/result/en/create_error.html +0 -95
  839. data/test/rails/test/result/en/custom_error_message.html +0 -83
  840. data/test/rails/test/result/en/custom_error_message_with_plural.html +0 -83
  841. data/test/rails/test/result/en/list.html +0 -62
  842. data/test/rails/test/result/en/multi_error_messages_for.html +0 -153
  843. data/test/rails/test/result/en/multipart.html +0 -67
  844. data/test/rails/test/result/en/new.html +0 -95
  845. data/test/rails/test/result/en/show.html +0 -51
  846. data/test/rails/test/result/en/singlepart.html +0 -10
  847. data/test/rails/test/result/fr/custom_error_message.html +0 -83
  848. data/test/rails/test/result/fr/custom_error_message_with_plural.html +0 -83
  849. data/test/rails/test/result/fr/list.html +0 -15
  850. data/test/rails/test/result/fr/multipart.html +0 -67
  851. data/test/rails/test/result/fr/new.html +0 -23
  852. data/test/rails/test/result/fr/singlepart.html +0 -10
  853. data/test/rails/test/result/ja/create_error.html +0 -95
  854. data/test/rails/test/result/ja/custom_error_message.html +0 -83
  855. data/test/rails/test/result/ja/custom_error_message_with_plural.html +0 -83
  856. data/test/rails/test/result/ja/list.html +0 -62
  857. data/test/rails/test/result/ja/multi_error_messages_for.html +0 -153
  858. data/test/rails/test/result/ja/multipart.html +0 -67
  859. data/test/rails/test/result/ja/new.html +0 -95
  860. data/test/rails/test/result/ja/show.html +0 -51
  861. data/test/rails/test/result/ja/singlepart.html +0 -10
  862. data/test/rails/test/test_helper.rb +0 -28
  863. data/test/rails/test/unit/article_test.rb +0 -18
  864. data/test/test.bat +0 -2
  865. data/test/test.sh +0 -13
  866. data/test/test_active_record.rb +0 -2606
  867. data/test/test_cgi.rb +0 -91
  868. data/test/test_erb.rhtml +0 -15
  869. data/test/test_erb.rxml +0 -16
  870. data/test/test_gettext_toplevel.rb +0 -44
  871. data/test/test_gladeparser.glade +0 -183
  872. data/test/test_java.sh +0 -12
  873. data/test/test_locale.rb +0 -250
  874. data/test/test_multi_textdomain.rb +0 -49
  875. data/test/test_rails.rb +0 -45
  876. data/test/test_rails_caching.rb +0 -232
  877. data/test/testlib/testlib2.rb +0 -11
  878. data/test/testlib/testlib3.rb +0 -12
  879. data/test/testlib/testlib4.rb +0 -11
  880. data/test/testlib/testlib5.rb +0 -70
  881. data/test/testlib/testlib6.rb +0 -19
@@ -1,67 +0,0 @@
1
- Date: Mon, 1 Jan 2007 00:00:00 +0900
2
- From: mutoh@highway.ne.jp
3
- To: mutoh@highway.ne.jp
4
- Subject: $B%^%k%A%Q!<%H%F%9%H%a!<%k(B
5
- Mime-Version: 1.0
6
- Content-Type: multipart/mixed; boundary=mimepart_4681148438839_1f9d155555598700316
7
-
8
-
9
- --mimepart_4681148438839_1f9d155555598700316
10
- Content-Type: text/plain; charset=iso-2022-jp
11
- Content-Transfer-Encoding: 7bit
12
- Content-Disposition: inline
13
-
14
- Hi foo,
15
-
16
- $B%5%s%W%k$H$7$F(Bpublic/images/*$B$rE:IU$7$^$7$?!#(B
17
-
18
- --
19
- bar@example.com
20
-
21
- --mimepart_4681148438839_1f9d155555598700316
22
- Content-Type: application/octet-stream; name=rails.png
23
- Content-Transfer-Encoding: Base64
24
- Content-Disposition: attachment; filename=rails.png
25
-
26
- iVBORw0KGgoAAAANSUhEUgAAADIAAABACAMAAABvC9RJAAAABGdBTUEAANbY
27
- 1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADA
28
- UExURbhJOOnNsM6Hd3wYIqYdJc+VirVVSJgaIvPl27Cmpf///5InK4s2Qsh0
29
- atqkkbU7NK4gKNCrpIkVHcNpSLAqLPXr47Z6eMl8VuzVvvv18fjv6d62rb9R
30
- T9ehcpRHSLIyL86NYerMxqQ8NbpGQ7IuN8VyTOzZ1N+1k/v39akVHsRmXapJ
31
- Pe/cyfLg06RcWOXEob9hRL9bVb1YPubDuv79/JwwMK4lLP3699rDwrFlafv4
32
- +p9QS/nz8MVhZYYdIq0eIJkvcAEAAAXBSURBVHjalNdbY6JKDABgHK4dlqt4
33
- RUVERVSqomA9pfD//9VJZkCp+7R5cHctXzMzhIQVKKXb4Z9/iIVA6VB0XVVV
34
- XTc//I5VJ/BfuS5JkioKIFQJQ9WVrL9h0edx5pFl+Nk/K4Ll2bYkCl9MQBb1
35
- oAjZeTP6rWQtNc+b/hkYkICRT1fiJFeUDKI/wtgsTS5HJR3Ab0GDpEBSqTwH
36
- JGEkO4+Wy+XpTmOUm9HcnMOf/X6WGYIFKwMiNmSlKLAwJOcNISGlJRkR87TV
37
- tKmW9mLSF65XBVbGCQpdeZFzf0S2A9MMp/QVWmxcfVgZI+2yngS2vSHxlr7F
38
- 1DFgZU+SK7+y9Pumpu3eDU2NIHiSQ0sETuLxKT6NnwubpmmqTSi9yUHBibtS
39
- OBHOZj+De2f2ThBx3EvvcN02ni9lspTN8EYJz+LqSkuuNB1ZBRn3eg06HdPw
40
- msZzUyba+GxcDcziPpMoAqHTgS8ZRyTMnE6j4OLT49w0ZXnZzwQhQPJMoggz
41
- OU1ns+N4zAygniFJSUCICUHgjmYNOTTCKqRkT4JeioYjGb7DCJaQhoz6Z2GF
42
- hB1wZFmBZxdFkpiD45EZQLESG4wk2Xw+J0tIg6SC6/FqL/AKIMZAS9MW7a3e
43
- yeJp5nMoPVjaAUhuFTZE4WHY1nGgcXMcH334DbHHiLRBA5Wq4CHbPBipzckA
44
- DEepkdhFIMHPgFg8DSNuSwLPK6JBOW1Mmo7xcon9EMySmwO7L20W2JFDy+m0
45
- QZqZSPYzJCVmS1s9SW06M8+blfdJWaIBNDBIlLyIN4e6WW4YQVNbE7pzCpPe
46
- 77sJN4PjPu1ZrzzSHtOwE3Nd2E1CoF59C0r3dt/tWKLpNfDvpJPGiiHNmRNR
47
- AqJRujew0G8sUTmdmEngX7q7IfF81BIXjksgvhDypwMTTco7qeFIiqJzAKf5
48
- plmYKEoB1svlTlsDiW5GjeWA0RDbfBJXrCyIQH49soDuP7XneV2T7JevLCIS
49
- K+w+57fJPvLsX0gSgCgtWUFbm01+9YbJfuvPWBU90QbqsiWuLgiW8dZP9iGd
50
- RsUL2dbyRWBWQBrnjRiX680oAq9F9hmqsiE4XXJBCN+IXHv7ixc0xisC1uCz
51
- J1GtrHwjJtRpwIITAedIQ9TD50rPjdsbCQMrCDqmj1NndGaVLMmO8/FN3tup
52
- Zr0MIAvH1HnDSeBA5PI72V0Cdocbk+EkhPaLD3Ki+I4jq8P3hVGCW2mNhaMz
53
- g15U4XyJiCwP1aH2TkxD3s/aRAK0amzB+IiJFeymKCT5652EsL2pwVdnMQDd
54
- TkciVhUcdC470/cZdIHEISu/QMhgulrr9dptSFWJfz4+/kpDLkQ2BWYgwRpD
55
- 4gSNC+TD2f6eXFe2fUzirZtQO2QBRJadr+7qyswSBDbt7UYUfxMIv3NyssVe
56
- QuyGFAVUFid4APpi8R3x152LQZrYB+2jv16zYu4SPDQ3YYFF6lm4ILt+9gr+
57
- mEkvgteL0NDZKGFIynME9QthwPct0fNczyts6EkB97pIJKn6s4KhYzVbSdZ4
58
- cJ4qtUTfYkPdPhI7ueBft5ek+oaenETagPXLmmjw9dRIXuQ/XrpRsh7wus/F
59
- T3gddKMblYEks+bWdkhJQ9mn9CeBa65ySO/f4ucN3gcPO06gk8g/+z3MQPam
60
- xMnQXTFyp3to6buGLF7k6vs4aTtk60O3mCEhtQykQlK1JOKFJCddgluRayTl
61
- oOwSAocOp3INwwFNiy6BDu64NhKmG/K9o040m63hsCPLB1J3iPNFy0uCxB9+
62
- dckNYjbDiXOnoc3eYEW3EnVY5p+STqIkwqOFhxEIRcIPd8YPefoD+1IrRqrP
63
- z4W4ePxEtfd4rNTD45Hrq8fjgB8YwfoHgw1b9xNbXyXyQktqKDtX1fHtVIdP
64
- LCMWecHqFetNFb/YK1xjJFttgl/YifYZcMUh5VOsSaN2o+LB8+jsK7hwSKmw
65
- +Jf/iAzxTfh/AQYADd4StjMb1WUAAAAASUVORK5CYII=
66
-
67
- --mimepart_4681148438839_1f9d155555598700316--
@@ -1,95 +0,0 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
4
- <title>Ruby-GetText-Package Test Application</title>
5
- <link href="/stylesheets/scaffold.css" media="screen" rel="Stylesheet" type="text/css" />
6
- </head>
7
- <body>
8
-
9
- <p style="color: green"></p>
10
-
11
- <h1>新しい記事</h1>
12
-
13
- <form action="/articles/create" method="post">
14
-
15
-
16
- <!--[form:article]-->
17
- <p><label for="article_title">タイトル</label><br/>
18
- <input id="article_title" name="article[title]" size="30" type="text" value="" /></p>
19
-
20
- <p><label for="article_description">内容</label><br/>
21
- <textarea cols="40" id="article_description" name="article[description]" rows="20"></textarea></p>
22
-
23
- <p><label for="article_lastupdate">最終更新日</label><br/>
24
- <select id="article_lastupdate_1i" name="article[lastupdate(1i)]">
25
- <option value="2002">2002</option>
26
- <option value="2003">2003</option>
27
- <option value="2004">2004</option>
28
- <option value="2005">2005</option>
29
- <option value="2006">2006</option>
30
- <option selected="selected" value="2007">2007</option>
31
- <option value="2008">2008</option>
32
- <option value="2009">2009</option>
33
- <option value="2010">2010</option>
34
- <option value="2011">2011</option>
35
- <option value="2012">2012</option>
36
- </select>
37
- <select id="article_lastupdate_2i" name="article[lastupdate(2i)]">
38
- <option value="1">January</option>
39
- <option value="2">February</option>
40
- <option value="3">March</option>
41
- <option selected="selected" value="4">April</option>
42
- <option value="5">May</option>
43
- <option value="6">June</option>
44
- <option value="7">July</option>
45
- <option value="8">August</option>
46
- <option value="9">September</option>
47
- <option value="10">October</option>
48
- <option value="11">November</option>
49
- <option value="12">December</option>
50
- </select>
51
- <select id="article_lastupdate_3i" name="article[lastupdate(3i)]">
52
- <option selected="selected" value="1">1</option>
53
- <option value="2">2</option>
54
- <option value="3">3</option>
55
- <option value="4">4</option>
56
- <option value="5">5</option>
57
- <option value="6">6</option>
58
- <option value="7">7</option>
59
- <option value="8">8</option>
60
- <option value="9">9</option>
61
- <option value="10">10</option>
62
- <option value="11">11</option>
63
- <option value="12">12</option>
64
- <option value="13">13</option>
65
- <option value="14">14</option>
66
- <option value="15">15</option>
67
- <option value="16">16</option>
68
- <option value="17">17</option>
69
- <option value="18">18</option>
70
- <option value="19">19</option>
71
- <option value="20">20</option>
72
- <option value="21">21</option>
73
- <option value="22">22</option>
74
- <option value="23">23</option>
75
- <option value="24">24</option>
76
- <option value="25">25</option>
77
- <option value="26">26</option>
78
- <option value="27">27</option>
79
- <option value="28">28</option>
80
- <option value="29">29</option>
81
- <option value="30">30</option>
82
- <option value="31">31</option>
83
- </select>
84
- </p>
85
- <!--[eoform:article]-->
86
-
87
-
88
- <input name="commit" type="submit" value="作成" />
89
- </form>
90
-
91
- <a href="/articles/list">戻る</a>
92
-
93
-
94
- </body>
95
- </html>
@@ -1,51 +0,0 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
4
- <title>Ruby-GetText-Package Test Application</title>
5
- <link href="/stylesheets/scaffold.css" media="screen" rel="Stylesheet" type="text/css" />
6
- </head>
7
- <body>
8
-
9
- <p style="color: green"></p>
10
-
11
-
12
- <p>
13
- <b>タイトル:</b> タイトル1
14
- </p>
15
-
16
- <p>
17
- <b>内容:</b> 内容1
18
- </p>
19
-
20
- <p>
21
- <b>最終更新日:</b> 2007-01-01
22
- </p>
23
-
24
-
25
- <a href="/articles/edit/1">編集</a> |
26
- <a href="/articles/list">戻る</a>
27
-
28
- <br/>
29
- <h2>test for distance_of_time_in_words</h2>
30
-
31
- 5秒以内<br/>
32
- 10秒以内<br/>
33
- 30秒前後<br/>
34
- 1分未満<br/>
35
- 1分<br/>
36
- 2分<br/>
37
- 約1時間<br/>
38
- 約2時間<br/>
39
- 1日<br/>
40
- 2日<br/>
41
- 約1ヵ月<br/>
42
- 2ヶ月<br/>
43
- 約1年<br/>
44
- 2年以上<br/>
45
- 4年以上<br/>
46
-
47
-
48
-
49
-
50
- </body>
51
- </html>
@@ -1,10 +0,0 @@
1
- Date: Mon, 1 Jan 2007 00:00:00 +0900
2
- From: mutoh@highway.ne.jp
3
- To: mutoh@highway.ne.jp
4
- Subject: $B%7%s%0%k%Q!<%H%F%9%H%a!<%k(B
5
- Mime-Version: 1.0
6
- Content-Type: text/plain; charset=iso-2022-jp
7
-
8
- $B$3$s$K$A$o(B foo$B$5$s(B
9
-
10
- $B%7%s%0%k%Q!<%H%a!<%k$G$9!#$$$$$G$9$+!)(B
@@ -1,28 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
- require 'test_help'
4
-
5
- class Test::Unit::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
- self.use_transactional_fixtures = true
19
-
20
- # Instantiated fixtures are slow, but give you @david where otherwise you
21
- # would need people(:david). If you don't want to migrate your existing
22
- # test cases which use the @david style and don't mind the speed hit (each
23
- # instantiated fixtures translates to a database query per test method),
24
- # then set this back to true.
25
- self.use_instantiated_fixtures = false
26
-
27
- # Add more helper methods to be used by all tests here...
28
- end
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
-
3
- class ArticleTest < Test::Unit::TestCase
4
- fixtures :articles
5
-
6
- # Replace this with your real tests.
7
- def test_first
8
- article = articles(:first)
9
- assert_equal 1, article.id
10
- assert_equal "内容1", article.description
11
- assert_equal Date.parse("2007-01-01"), article.lastupdate
12
-
13
- article = articles(:second)
14
- assert_equal 2, article.id
15
- assert_equal "内容2", article.description
16
- assert_equal Date.parse("2007-01-02"), article.lastupdate
17
- end
18
- end
data/test/test.bat DELETED
@@ -1,2 +0,0 @@
1
- ruby -I../lib -I../ext/gettext gettext_runner.rb
2
-
data/test/test.sh DELETED
@@ -1,13 +0,0 @@
1
- #!/bin/sh
2
-
3
- export LC_ALL="ja_JP.UTF-8";
4
- export LANG="ja_JP.UTF-8";
5
- rake rebuilddb
6
- for target in test_*.rb
7
- do
8
- ruby -I../lib $target
9
- done
10
- exit
11
- cd rails
12
- rake -I../../lib test
13
- cd ..
@@ -1,2606 +0,0 @@
1
- $KCODE = "U"
2
- $:.unshift(File.dirname(__FILE__) + '/../lib')
3
-
4
- require 'rubygems'
5
- require 'gettext'
6
- require 'gettext/active_record'
7
- require 'gettext/parser/active_record'
8
- require 'test/unit'
9
- require 'active_record'
10
- require 'active_record/fixtures'
11
- require 'fixtures/topic'
12
- require 'fixtures/reply'
13
- require 'fixtures/developer'
14
- require 'fixtures/wizard'
15
- require 'fixtures/inept_wizard'
16
- require 'logger'
17
-
18
- AR_TEST_VERSION = /activerecord-([^\/]+)/.match($:.join)[1]
19
-
20
- if AR_TEST_VERSION > "2.0.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
- p $!
37
- end
38
-
39
- ActiveRecord::Base.establish_connection(
40
- :adapter => "mysql",
41
- :username => "root",
42
- :password => "",
43
- :encoding => "utf8",
44
- :socket => "/var/lib/mysql/mysql.sock",
45
- :database => 'activerecord_unittest'
46
- )
47
-
48
- # Make with_scope public for tests
49
- class << ActiveRecord::Base
50
- public :with_scope, :with_exclusive_scope
51
- end
52
-
53
- class Test::Unit::TestCase #:nodoc:
54
- include GetText
55
- bindtextdomain("active_record", "locale")
56
- textdomain_to(ActiveRecord::Base, "active_record")
57
- textdomain_to(ActiveRecord::Validations, "active_record")
58
- self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
59
- end
60
-
61
- # The following methods in Topic are used in test_conditional_validation_*
62
- class Topic
63
- def condition_is_true
64
- return true
65
- end
66
-
67
- def condition_is_true_but_its_not
68
- return false
69
- end
70
- end
71
-
72
- class ProtectedPerson < ActiveRecord::Base
73
- set_table_name 'people'
74
- attr_accessor :addon
75
- attr_protected :first_name
76
- end
77
-
78
- class MyModel
79
- attr_accessor :title
80
- def save; end
81
- def save!; end
82
- def update_attribute(name, value); end
83
- def new_record?
84
- false
85
- end
86
- def self.human_attribute_name(name)
87
- name
88
- end
89
- include ActiveRecord::Validations
90
-
91
- validates_presence_of :title
92
- end
93
-
94
- class Conjurer < IneptWizard
95
- end
96
-
97
- class Thaumaturgist < IneptWizard
98
- end
99
-
100
- class ValidationsTest < Test::Unit::TestCase
101
- fixtures :topics, :developers
102
-
103
- def setup
104
- bindtextdomain_to(Topic, "active_record")
105
-
106
- if AR_TEST_VERSION < "2.1.0"
107
- Topic.write_inheritable_attribute(:validate, nil)
108
- Topic.write_inheritable_attribute(:validate_on_create, nil)
109
- Topic.write_inheritable_attribute(:validate_on_update, nil)
110
- else
111
- Topic.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
112
- Topic.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
113
- Topic.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
114
- end
115
- end
116
-
117
-
118
- def test_single_attr_validation_and_error_msg
119
- GetText.set_locale_all "ja_JP.UTF-8"
120
- r = Reply.new
121
- r.title = "There's no content!"
122
- r.save
123
- assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid"
124
- assert_equal "空です。", r.errors.on("content"), "A reply without content should contain an error"
125
- assert_equal "Reply内容 空です。", r.errors.full_messages[0], "A reply without content should contain an error"
126
- assert_equal 1, r.errors.count
127
-
128
- GetText.set_locale_all "en"
129
- r = Reply.new
130
- r.title = "There's no content!"
131
- r.save
132
- assert_equal "Empty", r.errors.on("content"), "A reply without content should contain an error"
133
- end
134
-
135
- def test_double_attr_validation_and_error_msg
136
- GetText.set_locale_all "ja_JP.UTF-8"
137
- r = Reply.new
138
- assert !r.save
139
-
140
- assert r.errors.invalid?("title"), "A reply without title should mark that attribute as invalid"
141
- assert_equal "Replyタイトル 空です。", r.errors.full_messages[0]
142
- assert_equal "空です。", r.errors.on("title")
143
-
144
- assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid"
145
- assert_equal "Reply内容 空です。", r.errors.full_messages[1]
146
- assert_equal "空です。", r.errors.on("content")
147
-
148
- assert_equal 2, r.errors.count
149
-
150
- GetText.set_locale_all "en"
151
- r = Reply.new
152
- assert !r.save
153
-
154
- assert r.errors.invalid?("title"), "A reply without title should mark that attribute as invalid"
155
- assert_equal "Title Empty", r.errors.full_messages[0]
156
- assert_equal "Empty", r.errors.on("title"), "A reply without title should contain an error"
157
-
158
- assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid"
159
- assert_equal "Content Empty", r.errors.full_messages[1]
160
- assert_equal "Empty", r.errors.on("content"), "A reply without content should contain an error"
161
-
162
- assert_equal 2, r.errors.count
163
- end
164
-
165
- def test_error_on_create
166
- GetText.set_locale_all "ja_JP.UTF-8"
167
- r = Reply.new
168
- r.title = "Wrong Create"
169
- assert !r.save
170
- assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid"
171
- assert_equal "Replyタイトル が不正に生成されました。", r.errors.full_messages[0]
172
- assert_equal "が不正に生成されました。", r.errors.on("title")
173
-
174
- GetText.set_locale_all "en"
175
- r = Reply.new
176
- r.title = "Wrong Create"
177
- assert !r.save
178
- assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid"
179
- assert_equal "Title is Wrong Create", r.errors.full_messages[0]
180
- assert_equal "is Wrong Create", r.errors.on("title")
181
- end
182
-
183
-
184
- def test_error_on_update
185
- GetText.set_locale_all "ja_JP.UTF-8"
186
- r = Reply.new
187
- r.title = "Bad"
188
- r.content = "Good"
189
- assert r.save, "First save should be successful"
190
- r.title = "Wrong Update"
191
- assert !r.save, "Second save should fail"
192
- assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid"
193
- assert_equal "Replyタイトル が不正に更新されました。", r.errors.full_messages[0]
194
- assert_equal "が不正に更新されました。", r.errors.on("title")
195
-
196
- GetText.set_locale_all "en"
197
- r = Reply.new
198
- r.title = "Bad"
199
- r.content = "Good"
200
- assert r.save, "First save should be successful"
201
-
202
- r.title = "Wrong Update"
203
- assert !r.save, "Second save should fail"
204
-
205
- assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid"
206
- assert_equal "Title is Wrong Update", r.errors.full_messages[0]
207
- assert_equal "is Wrong Update", r.errors.on("title")
208
- end
209
-
210
- def test_invalid_record_exception
211
- assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
212
- assert_raises(ActiveRecord::RecordInvalid) { Reply.new.save! }
213
-
214
- GetText.set_locale_all "ja_JP.UTF-8"
215
- begin
216
- r = Reply.new
217
- r.save!
218
- flunk
219
- rescue ActiveRecord::RecordInvalid => invalid
220
- assert_equal r, invalid.record
221
- assert_equal "入力値が正しくありません。: Replyタイトル 空です。, Reply内容 空です。", invalid.message
222
- end
223
-
224
- GetText.set_locale_all "en"
225
- begin
226
- r = Reply.new
227
- r.save!
228
- flunk
229
- rescue ActiveRecord::RecordInvalid => invalid
230
- assert_equal r, invalid.record
231
- assert_equal "Validation failed: Title Empty, Content Empty", invalid.message
232
- end
233
- end
234
-
235
- def test_exception_on_create_bang_many
236
- assert_raises(ActiveRecord::RecordInvalid) do
237
- Reply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }])
238
- end
239
-
240
- GetText.set_locale_all "ja_JP.UTF-8"
241
- begin
242
- Reply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }])
243
- rescue ActiveRecord::RecordInvalid => invalid
244
- assert_equal "入力値が正しくありません。: Reply内容 空です。", invalid.message
245
- end
246
- GetText.set_locale_all "en"
247
- begin
248
- Reply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }])
249
- rescue ActiveRecord::RecordInvalid => invalid
250
- assert_equal "Validation failed: Content Empty", invalid.message
251
- end
252
- end
253
-
254
-
255
- def test_exception_on_create_bang_with_block
256
- assert_raises(ActiveRecord::RecordInvalid) do
257
- Reply.create!({ "title" => "OK" }) do |r|
258
- r.content = nil
259
- end
260
- end
261
-
262
- GetText.set_locale_all "ja_JP.UTF-8"
263
- begin
264
- Reply.create!({ "title" => "OK" }) do |r|
265
- r.content = nil
266
- end
267
- rescue ActiveRecord::RecordInvalid => invalid
268
- assert_equal "入力値が正しくありません。: Reply内容 空です。", invalid.message
269
- end
270
-
271
- GetText.set_locale_all "en"
272
- begin
273
- Reply.create!({ "title" => "OK" }) do |r|
274
- r.content = nil
275
- end
276
- rescue ActiveRecord::RecordInvalid => invalid
277
- assert_equal "Validation failed: Content Empty", invalid.message
278
- end
279
- end
280
-
281
- def test_exception_on_create_bang_many_with_block
282
- assert_raises(ActiveRecord::RecordInvalid) do
283
- Reply.create!([{ "title" => "OK" }, { "title" => "Wrong Create" }]) do |r|
284
- r.content = nil
285
- end
286
- end
287
- GetText.set_locale_all "ja_JP.UTF-8"
288
- begin
289
- Reply.create!([{ "title" => "OK" }, { "title" => "Wrong Create" }]) do |r|
290
- r.content = nil
291
- end
292
- rescue ActiveRecord::RecordInvalid => invalid
293
- assert_equal "入力値が正しくありません。: Reply内容 空です。", invalid.message
294
- end
295
-
296
- GetText.set_locale_all "en"
297
- begin
298
- Reply.create!([{ "title" => "OK" }, { "title" => "Wrong Create" }]) do |r|
299
- r.content = nil
300
- end
301
- rescue ActiveRecord::RecordInvalid => invalid
302
- assert_equal "Validation failed: Content Empty", invalid.message
303
- end
304
- end
305
-
306
- def test_scoped_create_without_attributes
307
- Reply.with_scope(:create => {}) do
308
- assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
309
- end
310
-
311
- GetText.set_locale_all "ja_JP.UTF-8"
312
- Reply.with_scope(:create => {}) do
313
- begin
314
- Reply.create!
315
- rescue ActiveRecord::RecordInvalid => invalid
316
- assert_equal "入力値が正しくありません。: Replyタイトル 空です。, Reply内容 空です。", invalid.message
317
- end
318
- end
319
-
320
- GetText.set_locale_all "en"
321
- Reply.with_scope(:create => {}) do
322
- begin
323
- Reply.create!
324
- rescue ActiveRecord::RecordInvalid => invalid
325
- assert_equal "Validation failed: Title Empty, Content Empty", invalid.message
326
- end
327
- end
328
- end
329
-
330
- def test_single_error_per_attr_iteration
331
- GetText.set_locale_all "ja_JP.UTF-8"
332
- r = Reply.new
333
- r.save
334
-
335
- errors = []
336
- r.errors.each { |attr, msg| errors << [attr, msg] }
337
-
338
- assert errors.include?(["title", "空です。"])
339
- assert errors.include?(["content", "空です。"])
340
-
341
- GetText.set_locale_all "en"
342
- r = Reply.new
343
- r.save
344
-
345
- errors = []
346
- r.errors.each { |attr, msg| errors << [attr, msg] }
347
-
348
- assert errors.include?(["title", "Empty"])
349
- assert errors.include?(["content", "Empty"])
350
- end
351
-
352
- def test_multiple_errors_per_attr_iteration_with_full_error_composition
353
- GetText.set_locale_all "ja_JP.UTF-8"
354
- r = Reply.new
355
- r.title = "Wrong Create"
356
- r.content = "Mismatch"
357
- r.save
358
-
359
- errors = []
360
- r.errors.each_full { |error| errors << error }
361
- assert_equal "Replyタイトル が不正に生成されました。", errors[0]
362
- assert_equal "Replyタイトル は内容がミスマッチです。", errors[1]
363
- assert_equal 2, r.errors.count
364
-
365
- GetText.set_locale_all "en"
366
- r = Reply.new
367
- r.title = "Wrong Create"
368
- r.content = "Mismatch"
369
- r.save
370
-
371
- errors = []
372
- r.errors.each_full { |error| errors << error }
373
-
374
- assert_equal "Title is Wrong Create", errors[0]
375
- assert_equal "Title is Content Mismatch", errors[1]
376
- assert_equal 2, r.errors.count
377
- end
378
-
379
- def test_errors_on_base
380
- GetText.set_locale_all "ja_JP.UTF-8"
381
- r = Reply.new
382
- r.content = "Mismatch"
383
- r.save
384
- r.errors.add_to_base "リプライはdignifyされてません。"
385
-
386
- errors = []
387
- r.errors.each_full { |error| errors << error }
388
-
389
- assert_equal "リプライはdignifyされてません。", r.errors.on_base
390
-
391
- assert errors.include?("Replyタイトル 空です。")
392
- assert errors.include?("リプライはdignifyされてません。")
393
- assert_equal 2, r.errors.count
394
-
395
- GetText.set_locale_all "en"
396
- r = Reply.new
397
- r.content = "Mismatch"
398
- r.save
399
- r.errors.add_to_base "Reply is not dignifying"
400
-
401
- errors = []
402
- r.errors.each_full { |error| errors << error }
403
-
404
- assert_equal "Reply is not dignifying", r.errors.on_base
405
-
406
- assert errors.include?("Title Empty")
407
- assert errors.include?("Reply is not dignifying")
408
- assert_equal 2, r.errors.count
409
- end
410
-
411
- def test_validates_each
412
- perform = true
413
- hits = 0
414
- Topic.validates_each(:title, :content, [:title, :content]) do |record, attr|
415
- if perform
416
- record.errors.add attr, N_('gotcha')
417
- hits += 1
418
- end
419
- end
420
-
421
- GetText.set_locale_all "ja_JP.UTF-8"
422
- t = Topic.new("title" => "valid", "content" => "whatever")
423
- assert !t.save
424
- assert_equal 4, hits
425
- assert_equal ["タイトル ごっちゃ", "タイトル ごっちゃ",
426
- "内容 ごっちゃ", "内容 ごっちゃ"], t.errors.full_messages
427
- assert_equal ["ごっちゃ", "ごっちゃ"], t.errors.on(:title)
428
- assert_equal ["ごっちゃ", "ごっちゃ"], t.errors.on(:content)
429
-
430
- GetText.set_locale_all "en"
431
- hits = 0
432
- t = Topic.new("title" => "valid", "content" => "whatever")
433
- assert !t.save
434
- assert_equal 4, hits
435
- assert_equal ["Title gotcha", "Title gotcha",
436
- "Content gotcha", "Content gotcha"], t.errors.full_messages
437
-
438
- assert_equal ["gotcha", "gotcha"], t.errors.on(:title)
439
- assert_equal ["gotcha", "gotcha"], t.errors.on(:content)
440
-
441
- ensure
442
- perform = false
443
- end
444
-
445
- =begin
446
- #Don't need this
447
- def test_no_title_confirmation
448
- end
449
- def test_title_confirmation
450
- end
451
- def test_terms_of_service_agreement_no_acceptance
452
- end
453
- =end
454
-
455
- def test_errors_on_boundary_breaking
456
- GetText.set_locale_all "ja_JP.UTF-8"
457
- developer = Developer.new("name" => "xs")
458
- assert !developer.save
459
- assert_equal "開発者名は3文字以上で入力してください。", developer.errors.full_messages[0]
460
- assert_equal "開発者名は3文字以上で入力してください。", developer.errors.on("name")
461
-
462
- developer.name = "All too very long for this boundary, it really is"
463
- assert !developer.save
464
- assert_equal "開発者名は20文字以内で入力してください。", developer.errors.full_messages[0]
465
- assert_equal "開発者名は20文字以内で入力してください。", developer.errors.on("name")
466
-
467
- developer.name = "ちょうどぴったり12"
468
- assert developer.save
469
-
470
- GetText.set_locale_all "en"
471
- developer = Developer.new("name" => "xs")
472
- assert !developer.save
473
- assert_equal "Name is too short (minimum is 3 characters)", developer.errors.full_messages[0]
474
- assert_equal "Name is too short (minimum is 3 characters)", developer.errors.on("name")
475
-
476
- developer.name = "All too very long for this boundary, it really is"
477
- assert !developer.save
478
- assert_equal "Name is too long (maximum is 20 characters)", developer.errors.full_messages[0]
479
- assert_equal "Name is too long (maximum is 20 characters)", developer.errors.on("name")
480
-
481
- developer.name = "Just right"
482
- assert developer.save
483
- end
484
-
485
- def test_terms_of_service_agreement
486
- GetText.set_locale_all "ja_JP.UTF-8"
487
- Topic.validates_acceptance_of(:terms_of_service, :on => :create)
488
- t = Topic.create("title" => "We should be confirmed","terms_of_service" => "")
489
- assert !t.save
490
- assert_equal "利用規約を受諾してください。", t.errors.full_messages[0]
491
- assert_equal "利用規約を受諾してください。", t.errors.on(:terms_of_service)
492
-
493
- t.terms_of_service = "1"
494
- assert t.save
495
-
496
- GetText.set_locale_all "en"
497
- t = Topic.create("title" => "We should be confirmed","terms_of_service" => "")
498
- assert !t.save
499
- assert_equal "Terms of service must be accepted", t.errors.full_messages[0]
500
- assert_equal "Terms of service must be accepted", t.errors.on(:terms_of_service)
501
-
502
- t.terms_of_service = "1"
503
- assert t.save
504
- end
505
-
506
- def test_eula_fn
507
- GetText.set_locale_all "ja_JP.UTF-8"
508
- Topic.validates_acceptance_of(:eula, :message => N_("%{fn} must be abided"), :on => :create)
509
-
510
- t = Topic.create("title" => "We should be confirmed","eula" => "")
511
- assert !t.save
512
- assert_equal "Eulaに従ってください。", t.errors.full_messages[0]
513
- assert_equal "Eulaに従ってください。", t.errors.on(:eula)
514
-
515
- t.eula = "1"
516
- assert t.save
517
-
518
- GetText.set_locale_all "en"
519
- t = Topic.create("title" => "We should be confirmed","eula" => "")
520
- assert !t.save
521
- assert_equal "Eula must be abided", t.errors.full_messages[0]
522
- assert_equal "Eula must be abided", t.errors.on(:eula)
523
-
524
- t.eula = "1"
525
- assert t.save
526
- end
527
-
528
- def test_eula
529
- GetText.set_locale_all "ja_JP.UTF-8"
530
- Topic.validates_acceptance_of(:eula, :message => N_("must be abided"), :on => :create)
531
-
532
- t = Topic.create("title" => "We should be confirmed","eula" => "")
533
- assert !t.save
534
- assert_equal "Eula に従ってください。", t.errors.full_messages[0]
535
- assert_equal "に従ってください。", t.errors.on(:eula)
536
-
537
- t.eula = "1"
538
- assert t.save
539
-
540
- GetText.set_locale_all "en"
541
- t = Topic.create("title" => "We should be confirmed","eula" => "")
542
- assert !t.save
543
- assert_equal "Eula must be abided", t.errors.full_messages[0]
544
- assert_equal "must be abided", t.errors.on(:eula)
545
-
546
- t.eula = "1"
547
- assert t.save
548
- end
549
-
550
- def test_terms_of_service_agreement_with_accept_value
551
- Topic.validates_acceptance_of(:terms_of_service, :on => :create, :accept => "I agree.")
552
-
553
- GetText.set_locale_all "ja_JP.UTF-8"
554
- t = Topic.create("title" => "We should be confirmed", "terms_of_service" => "")
555
- assert !t.save
556
- assert_equal "利用規約を受諾してください。", t.errors.full_messages[0]
557
- assert_equal "利用規約を受諾してください。", t.errors.on(:terms_of_service)
558
-
559
- t.terms_of_service = "I agree."
560
- assert t.save
561
-
562
- GetText.set_locale_all "en"
563
- t = Topic.create("title" => "We should be confirmed", "terms_of_service" => "")
564
- assert !t.save
565
- assert_equal "Terms of service must be accepted", t.errors.full_messages[0]
566
- assert_equal "Terms of service must be accepted", t.errors.on(:terms_of_service)
567
-
568
- t.terms_of_service = "I agree."
569
- assert t.save
570
- end
571
-
572
- =begin
573
- #Don't need this
574
- def test_validates_acceptance_of_as_database_column
575
- end
576
- def test_validates_acceptance_of_with_non_existant_table
577
- end
578
- =end
579
-
580
- def test_validate_presences
581
- Topic.validates_presence_of(:title, :content)
582
-
583
- GetText.set_locale_all "ja_JP.UTF-8"
584
- t = Topic.create
585
- assert !t.save
586
- assert_equal "タイトルを入力してください。", t.errors.full_messages[0]
587
- assert_equal "内容を入力してください。", t.errors.full_messages[1]
588
- assert_equal "タイトルを入力してください。", t.errors.on(:title)
589
- assert_equal "内容を入力してください。", t.errors.on(:content)
590
-
591
- t.title = "something"
592
- t.content = " "
593
-
594
- assert !t.save
595
- assert_equal "内容を入力してください。", t.errors.full_messages[0]
596
- assert_equal "内容を入力してください。", t.errors.on(:content)
597
-
598
- t.content = "like stuff"
599
-
600
- assert t.save
601
-
602
- GetText.set_locale_all "en"
603
- t = Topic.create
604
- assert !t.save
605
- assert_equal "Title can't be blank", t.errors.full_messages[0]
606
- assert_equal "Content can't be blank", t.errors.full_messages[1]
607
- assert_equal "Title can't be blank", t.errors.on(:title)
608
- assert_equal "Content can't be blank", t.errors.on(:content)
609
-
610
- t.title = "something"
611
- t.content = " "
612
-
613
- assert !t.save
614
- assert_equal "Content can't be blank", t.errors.full_messages[0]
615
- assert_equal "Content can't be blank", t.errors.on(:content)
616
-
617
- t.content = "like stuff"
618
-
619
- assert t.save
620
- end
621
-
622
- def test_validate_uniqueness
623
- Topic.validates_uniqueness_of(:title)
624
-
625
- GetText.set_locale_all "ja_JP.UTF-8"
626
- t = Topic.new("title" => "I'm unique!")
627
- assert t.save, "Should save t as unique"
628
-
629
- t.content = "Remaining unique"
630
- assert t.save, "Should still save t as unique"
631
-
632
- t2 = Topic.new("title" => "I'm unique!")
633
- assert !t2.valid?, "Shouldn't be valid"
634
- assert !t2.save, "Shouldn't save t2 as unique"
635
- assert_equal "タイトルはすでに存在します。", t2.errors.full_messages[0]
636
- assert_equal "タイトルはすでに存在します。", t2.errors.on(:title)
637
-
638
- GetText.set_locale_all "en"
639
- t = Topic.new("title" => "I'm unique2!")
640
- assert t.save, "Should save t as unique"
641
-
642
- t.content = "Remaining unique2"
643
- assert t.save, "Should still save t as unique"
644
-
645
- t2 = Topic.new("title" => "I'm unique2!")
646
- assert !t2.valid?, "Shouldn't be valid"
647
- assert !t2.save, "Shouldn't save t2 as unique"
648
- assert_equal "Title has already been taken", t2.errors.full_messages[0]
649
- assert_equal "Title has already been taken", t2.errors.on(:title)
650
- end
651
-
652
- =begin
653
- #Don't need this
654
- def test_validate_uniqueness_with_scope
655
- end
656
- def test_validate_uniqueness_scoped_to_defining_class
657
- end
658
- def test_validate_uniqueness_with_scope_array
659
- end
660
- def test_validate_case_insensitive_uniqueness
661
- end
662
- def test_validate_case_sensitive_uniqueness
663
- end
664
- =end
665
-
666
- def test_validate_straight_inheritance_uniqueness
667
- GetText.set_locale_all "ja_JP.UTF-8"
668
- w1 = IneptWizard.create(:name => "I18nRincewind", :city => "I18nAnkh-Morpork")
669
- assert w1.valid?, "Saving w1"
670
-
671
- # Should use validation from base class (which is abstract)
672
- w2 = IneptWizard.new(:name => "I18nRincewind", :city => "I18nQuirm")
673
- assert !w2.valid?, "w2 shouldn't be valid"
674
- assert w2.errors.on(:name), "Should have errors for name"
675
- assert_equal "不器用な魔術師名はすでに存在します。", w2.errors.on(:name), "Should have uniqueness message for name"
676
-
677
- w3 = Conjurer.new(:name => "I18nRincewind", :city => "I18nQuirm")
678
- assert !w3.valid?, "w3 shouldn't be valid"
679
- assert w3.errors.on(:name), "Should have errors for name"
680
- assert_equal "手品師名はすでに存在します。", w3.errors.on(:name), "Should have uniqueness message for name"
681
-
682
- w4 = Conjurer.create(:name => "I18nThe Amazing Bonko", :city => "I18nQuirm")
683
- assert w4.valid?, "Saving w4"
684
-
685
- w5 = Thaumaturgist.new(:name => "I18nThe Amazing Bonko", :city => "I18nLancre")
686
- assert !w5.valid?, "w5 shouldn't be valid"
687
- assert w5.errors.on(:name), "Should have errors for name"
688
- assert_equal "奇術師名はすでに存在します。", w5.errors.on(:name), "Should have uniqueness message for name"
689
-
690
- w6 = Thaumaturgist.new(:name => "I18nMustrum Ridcully", :city => "I18nQuirm")
691
- assert !w6.valid?, "w6 shouldn't be valid"
692
- assert w6.errors.on(:city), "Should have errors for city"
693
- assert_equal "奇術師町はすでに存在します。", w6.errors.on(:city), "Should have uniqueness message for city"
694
-
695
- GetText.set_locale_all "en"
696
- w1 = IneptWizard.create(:name => "Rincewind", :city => "Ankh-Morpork")
697
- assert w1.valid?, "Saving w1"
698
-
699
- # Should use validation from base class (which is abstract)
700
- w2 = IneptWizard.new(:name => "Rincewind", :city => "Quirm")
701
- assert !w2.valid?, "w2 shouldn't be valid"
702
- assert w2.errors.on(:name), "Should have errors for name"
703
- assert_equal "Name has already been taken", w2.errors.on(:name), "Should have uniqueness message for name"
704
-
705
- w3 = Conjurer.new(:name => "Rincewind", :city => "Quirm")
706
- assert !w3.valid?, "w3 shouldn't be valid"
707
- assert w3.errors.on(:name), "Should have errors for name"
708
- assert_equal "Name has already been taken", w3.errors.on(:name), "Should have uniqueness message for name"
709
-
710
- w4 = Conjurer.create(:name => "The Amazing Bonko", :city => "Quirm")
711
- assert w4.valid?, "Saving w4"
712
-
713
- w5 = Thaumaturgist.new(:name => "The Amazing Bonko", :city => "Lancre")
714
- assert !w5.valid?, "w5 shouldn't be valid"
715
- assert w5.errors.on(:name), "Should have errors for name"
716
- assert_equal "Name has already been taken", w5.errors.on(:name), "Should have uniqueness message for name"
717
-
718
- w6 = Thaumaturgist.new(:name => "Mustrum Ridcully", :city => "Quirm")
719
- assert !w6.valid?, "w6 shouldn't be valid"
720
- assert w6.errors.on(:city), "Should have errors for city"
721
- assert_equal "City has already been taken", w6.errors.on(:city), "Should have uniqueness message for city"
722
- end
723
-
724
-
725
- def test_validate_format_fn
726
- Topic.validates_format_of(:title, :content, :with => /^Validation\smacros \w+!$/, :message => N_("%{fn} is bad data"))
727
-
728
- GetText.set_locale_all "ja_JP.UTF-8"
729
- t = Topic.create("title" => "i'm incorrect", "content" => "Validation macros rule!")
730
- assert !t.valid?, "Shouldn't be valid"
731
- assert !t.save, "Shouldn't save because it's invalid"
732
- assert_equal "タイトルは悪いデータです。", t.errors.full_messages[0]
733
- assert_equal "タイトルは悪いデータです。", t.errors.on(:title)
734
- assert_nil t.errors.on(:content)
735
-
736
- GetText.set_locale_all "en"
737
- assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) }
738
- t = Topic.create("title" => "i'm incorrect", "content" => "Validation macros rule!")
739
- assert !t.valid?, "Shouldn't be valid"
740
- assert !t.save, "Shouldn't save because it's invalid"
741
- assert_equal "Title is bad data", t.errors.full_messages[0]
742
- assert_equal "Title is bad data", t.errors.on(:title)
743
- assert_nil t.errors.on(:content)
744
- end
745
-
746
- def test_validate_format
747
- Topic.validates_format_of(:title, :content, :with => /^Validation\smacros \w+!$/, :message => N_("is bad data"))
748
-
749
- GetText.set_locale_all "ja_JP.UTF-8"
750
- t = Topic.create("title" => "i'm incorrect", "content" => "Validation macros rule!")
751
- assert !t.valid?, "Shouldn't be valid"
752
- assert !t.save, "Shouldn't save because it's invalid"
753
- assert_equal "タイトル は悪いデータです。", t.errors.full_messages[0]
754
- assert_equal "は悪いデータです。", t.errors.on(:title)
755
- assert_nil t.errors.on(:content)
756
-
757
- GetText.set_locale_all "en"
758
- assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) }
759
- t = Topic.create("title" => "i'm incorrect", "content" => "Validation macros rule!")
760
- assert !t.valid?, "Shouldn't be valid"
761
- assert !t.save, "Shouldn't save because it's invalid"
762
- assert_equal "Title is bad data", t.errors.full_messages[0]
763
- assert_equal "is bad data", t.errors.on(:title)
764
- assert_nil t.errors.on(:content)
765
-
766
- t.title = "Validation macros rule!"
767
-
768
- assert t.save
769
- assert_nil t.errors.on(:title)
770
-
771
- assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) }
772
- end
773
-
774
- =begin
775
- # Don't need this
776
- def test_validate_format_with_allow_blank
777
- end
778
- =end
779
- def test_validate_format_numeric_fn
780
- Topic.validates_format_of(:title, :content, :with => /^[1-9][0-9]*$/, :message => N_("%{fn} is bad data"))
781
-
782
- GetText.set_locale_all "ja_JP.UTF-8"
783
- t = Topic.create("title" => "72x", "content" => "6789")
784
- assert !t.valid?, "Shouldn't be valid"
785
- assert !t.save, "Shouldn't save because it's invalid"
786
- assert_equal "タイトルは悪いデータです。", t.errors.on(:title)
787
- assert_nil t.errors.on(:content)
788
-
789
- t.title = "-11"
790
- assert !t.valid?, "Shouldn't be valid"
791
-
792
- t.title = "03"
793
- assert !t.valid?, "Shouldn't be valid"
794
-
795
- t.title = "z44"
796
- assert !t.valid?, "Shouldn't be valid"
797
-
798
- t.title = "5v7"
799
- assert !t.valid?, "Shouldn't be valid"
800
-
801
- t.title = "1"
802
-
803
- assert t.save
804
- assert_nil t.errors.on(:title)
805
-
806
- GetText.set_locale_all "en"
807
- t = Topic.create("title" => "72x", "content" => "6789")
808
- assert !t.valid?, "Shouldn't be valid"
809
- assert !t.save, "Shouldn't save because it's invalid"
810
- assert_equal "Title is bad data", t.errors.on(:title)
811
- assert_nil t.errors.on(:content)
812
-
813
- t.title = "-11"
814
- assert !t.valid?, "Shouldn't be valid"
815
-
816
- t.title = "03"
817
- assert !t.valid?, "Shouldn't be valid"
818
-
819
- t.title = "z44"
820
- assert !t.valid?, "Shouldn't be valid"
821
-
822
- t.title = "5v7"
823
- assert !t.valid?, "Shouldn't be valid"
824
-
825
- t.title = "1"
826
-
827
- assert t.save
828
- assert_nil t.errors.on(:title)
829
- end
830
-
831
- def test_validate_format_numeric
832
- Topic.validates_format_of(:title, :content, :with => /^[1-9][0-9]*$/, :message => N_("is bad data"))
833
-
834
- GetText.set_locale_all "ja_JP.UTF-8"
835
- t = Topic.create("title" => "72x", "content" => "6789")
836
- assert !t.valid?, "Shouldn't be valid"
837
- assert !t.save, "Shouldn't save because it's invalid"
838
- assert_equal "は悪いデータです。", t.errors.on(:title)
839
- assert_nil t.errors.on(:content)
840
-
841
- t.title = "-11"
842
- assert !t.valid?, "Shouldn't be valid"
843
-
844
- t.title = "03"
845
- assert !t.valid?, "Shouldn't be valid"
846
-
847
- t.title = "z44"
848
- assert !t.valid?, "Shouldn't be valid"
849
-
850
- t.title = "5v7"
851
- assert !t.valid?, "Shouldn't be valid"
852
-
853
- t.title = "1"
854
-
855
- assert t.save
856
- assert_nil t.errors.on(:title)
857
-
858
- GetText.set_locale_all "en"
859
- t = Topic.create("title" => "72x", "content" => "6789")
860
- assert !t.valid?, "Shouldn't be valid"
861
- assert !t.save, "Shouldn't save because it's invalid"
862
- assert_equal "is bad data", t.errors.on(:title)
863
- assert_nil t.errors.on(:content)
864
-
865
- t.title = "-11"
866
- assert !t.valid?, "Shouldn't be valid"
867
-
868
- t.title = "03"
869
- assert !t.valid?, "Shouldn't be valid"
870
-
871
- t.title = "z44"
872
- assert !t.valid?, "Shouldn't be valid"
873
-
874
- t.title = "5v7"
875
- assert !t.valid?, "Shouldn't be valid"
876
-
877
- t.title = "1"
878
-
879
- assert t.save
880
- assert_nil t.errors.on(:title)
881
- end
882
-
883
- def test_validate_format_with_formatted_message_fn
884
- Topic.validates_format_of(:title, :with => /^Valid Title$/, :message => N_("%{fn} can not be %{val}"))
885
-
886
- GetText.set_locale_all "ja_JP.UTF-8"
887
- t = Topic.create(:title => 'Invalid title')
888
- assert_equal "Invalid titleはタイトルではありません。", t.errors.full_messages[0]
889
- assert_equal "Invalid titleはタイトルではありません。", t.errors.on(:title)
890
-
891
- GetText.set_locale_all "en"
892
- t = Topic.create(:title => 'Invalid title')
893
- assert_equal "Title can not be Invalid title", t.errors.full_messages[0]
894
- assert_equal "Title can not be Invalid title", t.errors.on(:title)
895
- end
896
-
897
- def test_validate_format_with_formatted_message
898
- Topic.validates_format_of(:title, :with => /^Valid Title$/, :message => N_("can not be %{val}"))
899
-
900
- GetText.set_locale_all "ja_JP.UTF-8"
901
- t = Topic.create(:title => 'Invalid title')
902
- assert_equal "タイトル はInvalid titleではありません。", t.errors.full_messages[0]
903
- assert_equal "はInvalid titleではありません。", t.errors.on(:title)
904
-
905
- GetText.set_locale_all "en"
906
- t = Topic.create(:title => 'Invalid title')
907
- assert_equal "Title can not be Invalid title", t.errors.full_messages[0]
908
- assert_equal "can not be Invalid title", t.errors.on(:title)
909
- end
910
-
911
- def test_validates_inclusion_of
912
- Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ) )
913
-
914
- GetText.set_locale_all "ja_JP.UTF-8"
915
- t = Topic.create("title" => "a", "content" => "I know you are but what am I?")
916
- assert t.valid?
917
- t.title = "uhoh"
918
- assert !t.valid?
919
- assert t.errors.on(:title)
920
- assert_equal "タイトルは一覧にありません。", t.errors.full_messages[0]
921
- assert_equal "タイトルは一覧にありません。", t.errors.on(:title)
922
-
923
- GetText.set_locale_all "en"
924
- t = Topic.create("title" => "a", "content" => "I know you are but what am I?")
925
- assert t.valid?
926
- t.title = "uhoh"
927
- assert !t.valid?
928
- assert t.errors.on(:title)
929
- assert_equal "Title is not included in the list", t.errors.full_messages[0]
930
- assert_equal "Title is not included in the list", t.errors.on(:title)
931
- end
932
-
933
- =begin
934
- # Don't need this
935
- def test_validates_inclusion_of_with_allow_nil
936
- end
937
- def test_numericality_with_getter_method
938
- end
939
- def test_validates_length_of_with_allow_nil
940
- end
941
- def test_validates_length_of_with_allow_blank
942
- end
943
- =end
944
-
945
- def test_validates_inclusion_of_with_formatted_message_fn
946
- Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :message => N_("%{fn} option %{val} is not in the list") )
947
- GetText.set_locale_all "ja_JP.UTF-8"
948
-
949
- assert Topic.create("title" => "a", "content" => "abc").valid?
950
-
951
- t = Topic.create("title" => "uhoh", "content" => "abc")
952
- assert !t.valid?
953
- assert t.errors.on(:title)
954
- assert_equal "オプションuhohはタイトル一覧にありません。", t.errors.full_messages[0]
955
- assert_equal "オプションuhohはタイトル一覧にありません。", t.errors["title"]
956
-
957
- GetText.set_locale_all "en"
958
- assert Topic.create("title" => "a", "content" => "abc").valid?
959
-
960
- t = Topic.create("title" => "uhoh", "content" => "abc")
961
- assert !t.valid?
962
- assert t.errors.on(:title)
963
- assert_equal "Title option uhoh is not in the list", t.errors.full_messages[0]
964
- assert_equal "Title option uhoh is not in the list", t.errors["title"]
965
- end
966
-
967
- def test_validates_inclusion_of_with_formatted_message
968
- Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :message => N_("option %{val} is not in the list") )
969
- GetText.set_locale_all "ja_JP.UTF-8"
970
-
971
- assert Topic.create("title" => "a", "content" => "abc").valid?
972
-
973
- t = Topic.create("title" => "uhoh", "content" => "abc")
974
- assert !t.valid?
975
- assert t.errors.on(:title)
976
- assert_equal "タイトル オプションuhohは一覧にありません。", t.errors.full_messages[0]
977
- assert_equal "オプションuhohは一覧にありません。", t.errors["title"]
978
-
979
- GetText.set_locale_all "en"
980
- assert Topic.create("title" => "a", "content" => "abc").valid?
981
-
982
- t = Topic.create("title" => "uhoh", "content" => "abc")
983
- assert !t.valid?
984
- assert t.errors.on(:title)
985
- assert_equal "Title option uhoh is not in the list", t.errors.full_messages[0]
986
- assert_equal "option uhoh is not in the list", t.errors["title"]
987
- end
988
-
989
- =begin
990
- Don't need this
991
- def test_numericality_with_allow_nil_and_getter_method
992
- end
993
- def test_validates_exclusion_of
994
- end
995
- =end
996
- def test_validates_exclusion_of_with_formatted_message_fn
997
- GetText.set_locale_all "ja_JP.UTF-8"
998
- Topic.validates_exclusion_of( :title, :in => %w( abe monkey ), :message => N_("%{fn} option %{val} is restricted") )
999
-
1000
- assert Topic.create("title" => "something", "content" => "abc")
1001
-
1002
- t = Topic.create("title" => "monkey")
1003
- assert !t.valid?
1004
- assert t.errors.on(:title)
1005
- assert_equal "オプションタイトルmonkeyは制限されています。", t.errors.full_messages[0]
1006
- assert_equal "オプションタイトルmonkeyは制限されています。", t.errors["title"]
1007
-
1008
- GetText.set_locale_all "en"
1009
- assert Topic.create("title" => "something", "content" => "abc")
1010
-
1011
- t = Topic.create("title" => "monkey")
1012
- assert !t.valid?
1013
- assert t.errors.on(:title)
1014
- assert_equal "Title option monkey is restricted", t.errors.full_messages[0]
1015
- assert_equal "Title option monkey is restricted", t.errors["title"]
1016
- end
1017
-
1018
- def test_validates_exclusion_of_with_formatted_message
1019
- GetText.set_locale_all "ja_JP.UTF-8"
1020
- Topic.validates_exclusion_of( :title, :in => %w( abe monkey ), :message => N_("option %{val} is restricted") )
1021
-
1022
- assert Topic.create("title" => "something", "content" => "abc")
1023
-
1024
- t = Topic.create("title" => "monkey")
1025
- assert !t.valid?
1026
- assert t.errors.on(:title)
1027
- assert_equal "タイトル オプションmonkeyは制限されています。", t.errors.full_messages[0]
1028
- assert_equal "オプションmonkeyは制限されています。", t.errors["title"]
1029
-
1030
- GetText.set_locale_all "en"
1031
- assert Topic.create("title" => "something", "content" => "abc")
1032
-
1033
- t = Topic.create("title" => "monkey")
1034
- assert !t.valid?
1035
- assert t.errors.on(:title)
1036
- assert_equal "Title option monkey is restricted", t.errors.full_messages[0]
1037
- assert_equal "option monkey is restricted", t.errors["title"]
1038
- end
1039
-
1040
- def test_validates_length_of_using_minimum
1041
- Topic.validates_length_of :title, :minimum => 5
1042
-
1043
- GetText.set_locale_all "ja_JP.UTF-8"
1044
- t = Topic.create("title" => "valid", "content" => "whatever")
1045
- assert t.valid?
1046
-
1047
- t.title = "not"
1048
- assert !t.valid?
1049
- assert t.errors.on(:title)
1050
- assert_equal "タイトルは5文字以上で入力してください。", t.errors.full_messages[0]
1051
- assert_equal "タイトルは5文字以上で入力してください。", t.errors.on("title")
1052
-
1053
- GetText.set_locale_all "en"
1054
- t = Topic.create("title" => "valid", "content" => "whatever")
1055
- assert t.valid?
1056
-
1057
- t.title = "not"
1058
- assert !t.valid?
1059
- assert t.errors.on(:title)
1060
- assert_equal "Title is too short (minimum is 5 characters)", t.errors.full_messages[0]
1061
- assert_equal "Title is too short (minimum is 5 characters)", t.errors.on("title")
1062
- end
1063
-
1064
- def test_validates_length_of_using_maximum
1065
- Topic.validates_length_of :title, :maximum => 5
1066
- GetText.set_locale_all "ja_JP.UTF-8"
1067
- t = Topic.create("title" => "valid", "content" => "whatever")
1068
- assert t.valid?
1069
-
1070
- t.title = "notvalid"
1071
- assert !t.valid?
1072
- assert t.errors.on(:title)
1073
- assert_equal "タイトルは5文字以内で入力してください。", t.errors.full_messages[0]
1074
- assert_equal "タイトルは5文字以内で入力してください。", t.errors.on("title")
1075
-
1076
- GetText.set_locale_all "en"
1077
- t = Topic.create("title" => "valid", "content" => "whatever")
1078
- assert t.valid?
1079
-
1080
- t.title = "notvalid"
1081
- assert !t.valid?
1082
- assert t.errors.on(:title)
1083
- assert_equal "Title is too long (maximum is 5 characters)", t.errors.full_messages[0]
1084
- assert_equal "Title is too long (maximum is 5 characters)", t.errors.on("title")
1085
- end
1086
-
1087
- =begin
1088
- # Don't need this
1089
- def test_optionally_validates_length_of_using_minimum
1090
- end
1091
- =end
1092
-
1093
- def test_validates_length_of_using_within
1094
- Topic.validates_length_of(:title, :content, :within => 3..5)
1095
-
1096
- GetText.set_locale_all "ja_JP.UTF-8"
1097
- t = Topic.new("title" => "a!", "content" => "I'm ooooooooh so very long")
1098
- assert !t.valid?
1099
- assert_equal "タイトルは3文字以上で入力してください。", t.errors.full_messages[0]
1100
- assert_equal "内容は5文字以内で入力してください。", t.errors.full_messages[1]
1101
- assert_equal "タイトルは3文字以上で入力してください。", t.errors.on(:title)
1102
- assert_equal "内容は5文字以内で入力してください。", t.errors.on(:content)
1103
-
1104
- t.title = nil
1105
- t.content = nil
1106
- assert !t.valid?
1107
- assert_equal "タイトルは3文字以上で入力してください。", t.errors.full_messages[0]
1108
- assert_equal "内容は3文字以上で入力してください。", t.errors.full_messages[1]
1109
- assert_equal "タイトルは3文字以上で入力してください。", t.errors.on(:title)
1110
- assert_equal "内容は3文字以上で入力してください。", t.errors.on(:content)
1111
-
1112
- GetText.set_locale_all "en"
1113
- t = Topic.new("title" => "a!", "content" => "I'm ooooooooh so very long")
1114
- assert !t.valid?
1115
- assert_equal "Title is too short (minimum is 3 characters)", t.errors.full_messages[0]
1116
- assert_equal "Content is too long (maximum is 5 characters)", t.errors.full_messages[1]
1117
- assert_equal "Title is too short (minimum is 3 characters)", t.errors.on(:title)
1118
- assert_equal "Content is too long (maximum is 5 characters)", t.errors.on(:content)
1119
-
1120
- t.title = nil
1121
- t.content = nil
1122
- assert !t.valid?
1123
- assert_equal "Title is too short (minimum is 3 characters)", t.errors.full_messages[0]
1124
- assert_equal "Content is too short (minimum is 3 characters)", t.errors.full_messages[1]
1125
- assert_equal "Title is too short (minimum is 3 characters)", t.errors.on(:title)
1126
- assert_equal "Content is too short (minimum is 3 characters)", t.errors.on(:content)
1127
- end
1128
-
1129
- =begin
1130
- # Don't need this
1131
- def test_optionally_validates_length_of_using_within
1132
- end
1133
- =end
1134
-
1135
- def test_optionally_validates_length_of_using_within_on_create_fn
1136
- Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_short => N_("my string(%{fn}) is too short: %d"), :too_long => N_("my string(%{fn}) is too long: %d")
1137
-
1138
- GetText.set_locale_all "ja_JP.UTF-8"
1139
- t = Topic.create("title" => "thisisnotvalid", "content" => "whatever")
1140
- assert !t.save
1141
- assert t.errors.on(:title)
1142
- assert_equal "文字列:タイトルは長すぎ: 10", t.errors.full_messages[0]
1143
- assert_equal "文字列:タイトルは長すぎ: 10", t.errors.on(:title)
1144
-
1145
- GetText.set_locale_all "en"
1146
- t = Topic.create("title" => "thisisnotvalid", "content" => "whatever")
1147
- assert !t.save
1148
- assert t.errors.on(:title)
1149
- assert_equal "my string(Title) is too long: 10", t.errors.full_messages[0]
1150
- assert_equal "my string(Title) is too long: 10", t.errors.on(:title)
1151
- end
1152
-
1153
- def test_optionally_validates_length_of_using_within_on_create
1154
- Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_short => N_("my string is too short: %d"), :too_long => N_("my string is too long: %d")
1155
-
1156
- GetText.set_locale_all "ja_JP.UTF-8"
1157
- t = Topic.create("title" => "thisisnotvalid", "content" => "whatever")
1158
- assert !t.save
1159
- assert t.errors.on(:title)
1160
- assert_equal "タイトル 文字列は長すぎ: 10", t.errors.full_messages[0]
1161
- assert_equal "文字列は長すぎ: 10", t.errors.on(:title)
1162
-
1163
- GetText.set_locale_all "en"
1164
- t = Topic.create("title" => "thisisnotvalid", "content" => "whatever")
1165
- assert !t.save
1166
- assert t.errors.on(:title)
1167
- assert_equal "Title my string is too long: 10", t.errors.full_messages[0]
1168
- assert_equal "my string is too long: 10", t.errors.on(:title)
1169
- end
1170
-
1171
- def test_optionally_validates_length_of_using_within_on_update_fn
1172
- Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => N_("my string(%{fn}) is too short: %d"), :too_long => N_("my string(%{fn}) is too long: %d")
1173
- GetText.set_locale_all "ja_JP.UTF-8"
1174
- t = Topic.create("title" => "vali", "content" => "whatever")
1175
- assert !t.save
1176
- assert t.errors.on(:title)
1177
-
1178
- t.title = "not"
1179
- assert !t.save
1180
- assert t.errors.on(:title)
1181
- assert_equal "文字列:タイトルは短すぎ: 5", t.errors.full_messages[0]
1182
- assert_equal "文字列:タイトルは短すぎ: 5", t.errors.on(:title)
1183
-
1184
- GetText.set_locale_all "en"
1185
- t = Topic.create("title" => "vali", "content" => "whatever")
1186
- assert !t.save
1187
- assert t.errors.on(:title)
1188
-
1189
- t.title = "not"
1190
- assert !t.save
1191
- assert t.errors.on(:title)
1192
- assert_equal "my string(Title) is too short: 5", t.errors.full_messages[0]
1193
- assert_equal "my string(Title) is too short: 5", t.errors.on(:title)
1194
-
1195
- end
1196
-
1197
- def test_optionally_validates_length_of_using_within_on_update
1198
- Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => N_("my string is too short: %d"), :too_long => N_("my string is too long: %d")
1199
- GetText.set_locale_all "ja_JP.UTF-8"
1200
- t = Topic.create("title" => "vali", "content" => "whatever")
1201
- assert !t.save
1202
- assert t.errors.on(:title)
1203
-
1204
- t.title = "not"
1205
- assert !t.save
1206
- assert t.errors.on(:title)
1207
- assert_equal "タイトル 文字列は短すぎ: 5", t.errors.full_messages[0]
1208
- assert_equal "文字列は短すぎ: 5", t.errors.on(:title)
1209
-
1210
- GetText.set_locale_all "en"
1211
- t = Topic.create("title" => "vali", "content" => "whatever")
1212
- assert !t.save
1213
- assert t.errors.on(:title)
1214
-
1215
- t.title = "not"
1216
- assert !t.save
1217
- assert t.errors.on(:title)
1218
- assert_equal "Title my string is too short: 5", t.errors.full_messages[0]
1219
- assert_equal "my string is too short: 5", t.errors.on(:title)
1220
-
1221
- end
1222
-
1223
- def test_validates_length_of_using_is
1224
- Topic.validates_length_of :title, :is => 5
1225
-
1226
- GetText.set_locale_all "ja_JP.UTF-8"
1227
- t = Topic.create("title" => "valid", "content" => "whatever")
1228
- assert t.valid?
1229
-
1230
- t.title = "notvalid"
1231
- assert !t.valid?
1232
- assert t.errors.on(:title)
1233
- assert_equal "タイトルは5文字で入力してください。", t.errors.full_messages[0]
1234
- assert_equal "タイトルは5文字で入力してください。", t.errors.on("title")
1235
-
1236
- GetText.set_locale_all "en"
1237
- t = Topic.create("title" => "valid", "content" => "whatever")
1238
- assert t.valid?
1239
-
1240
- t.title = "notvalid"
1241
- assert !t.valid?
1242
- assert t.errors.on(:title)
1243
- assert_equal "Title is the wrong length (should be 5 characters)", t.errors.full_messages[0]
1244
- assert_equal "Title is the wrong length (should be 5 characters)", t.errors.on("title")
1245
-
1246
- end
1247
-
1248
- =begin
1249
- # Don't need this
1250
- def test_optionally_validates_length_of_using_is
1251
- end
1252
- def test_validates_length_of_using_bignum
1253
- end
1254
- =end
1255
-
1256
- def test_validates_length_with_globaly_modified_error_message_fn
1257
- ActiveRecord::Errors.default_error_messages[:too_short] = N_('%{fn} %d dayo')
1258
- Topic.validates_length_of :title, :minimum => 10
1259
-
1260
- GetText.set_locale_all "ja_JP.UTF-8"
1261
- t = Topic.create(:title => 'too short')
1262
- assert !t.valid?
1263
- assert_equal 'タイトルは10以上だよ。', t.errors.full_messages[0]
1264
- assert_equal 'タイトルは10以上だよ。', t.errors.on('title')
1265
-
1266
- GetText.set_locale_all "en"
1267
- t = Topic.create(:title => 'too short')
1268
- assert !t.valid?
1269
- assert_equal 'Title 10 dayo', t.errors.full_messages[0]
1270
- assert_equal 'Title 10 dayo', t.errors.on('title')
1271
- end
1272
-
1273
- def test_validates_length_with_globaly_modified_error_message
1274
- ActiveRecord::Errors.default_error_messages[:too_short] = N_('%d dayo')
1275
- Topic.validates_length_of :title, :minimum => 10
1276
-
1277
- GetText.set_locale_all "ja_JP.UTF-8"
1278
- t = Topic.create(:title => 'too short')
1279
- assert !t.valid?
1280
- assert_equal 'タイトル は10以上だよ。', t.errors.full_messages[0]
1281
- assert_equal 'は10以上だよ。', t.errors.on('title')
1282
-
1283
- GetText.set_locale_all "en"
1284
- t = Topic.create(:title => 'too short')
1285
- assert !t.valid?
1286
- assert_equal 'Title 10 dayo', t.errors.full_messages[0]
1287
- assert_equal '10 dayo', t.errors.on('title')
1288
- end
1289
-
1290
- =begin
1291
- def test_validates_size_of_association
1292
- end
1293
- def test_validates_size_of_association_using_within
1294
- end
1295
- def test_validates_length_of_nasty_params
1296
- end
1297
- =end
1298
-
1299
- def test_validates_length_of_custom_errors_for_minimum_with_message_fn
1300
- Topic.validates_length_of( :title, :minimum => 5, :message => N_("%{fn} hoo %d") )
1301
- GetText.set_locale_all "ja_JP.UTF-8"
1302
- t = Topic.create("title" => "uhoh", "content" => "whatever")
1303
- assert !t.valid?
1304
- assert t.errors.on(:title)
1305
- assert_equal "タイトルふー5", t.errors.full_messages[0]
1306
- assert_equal "タイトルふー5", t.errors.on("title")
1307
-
1308
- GetText.set_locale_all "en"
1309
- t = Topic.create("title" => "uhoh", "content" => "whatever")
1310
- assert !t.valid?
1311
- assert t.errors.on(:title)
1312
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1313
- assert_equal "Title hoo 5", t.errors.on("title")
1314
- end
1315
-
1316
- def test_validates_length_of_custom_errors_for_minimum_with_message
1317
- Topic.validates_length_of( :title, :minimum => 5, :message => N_("hoo %d") )
1318
- GetText.set_locale_all "ja_JP.UTF-8"
1319
- t = Topic.create("title" => "uhoh", "content" => "whatever")
1320
- assert !t.valid?
1321
- assert t.errors.on(:title)
1322
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
1323
- assert_equal "ふー5", t.errors.on("title")
1324
-
1325
- GetText.set_locale_all "en"
1326
- t = Topic.create("title" => "uhoh", "content" => "whatever")
1327
- assert !t.valid?
1328
- assert t.errors.on(:title)
1329
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1330
- assert_equal "hoo 5", t.errors.on("title")
1331
- end
1332
-
1333
- def test_validates_length_of_custom_errors_for_minimum_with_too_short_fn
1334
- Topic.validates_length_of( :title, :minimum=>5, :too_short => N_("%{fn} hoo %d") )
1335
-
1336
- GetText.set_locale_all "ja_JP.UTF-8"
1337
- t = Topic.create("title" => "uhoh", "content" => "whatever")
1338
- assert !t.valid?
1339
- assert t.errors.on(:title)
1340
- assert_equal "タイトルふー5", t.errors.full_messages[0]
1341
- assert_equal "タイトルふー5", t.errors.on("title")
1342
-
1343
- GetText.set_locale_all "en"
1344
- t = Topic.create("title" => "uhoh", "content" => "whatever")
1345
- assert !t.valid?
1346
- assert t.errors.on(:title)
1347
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1348
- assert_equal "Title hoo 5", t.errors.on("title")
1349
- end
1350
-
1351
- def test_validates_length_of_custom_errors_for_minimum_with_too_short
1352
- Topic.validates_length_of( :title, :minimum=>5, :too_short => N_("hoo %d") )
1353
-
1354
- GetText.set_locale_all "ja_JP.UTF-8"
1355
- t = Topic.create("title" => "uhoh", "content" => "whatever")
1356
- assert !t.valid?
1357
- assert t.errors.on(:title)
1358
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
1359
- assert_equal "ふー5", t.errors.on("title")
1360
-
1361
- GetText.set_locale_all "en"
1362
- t = Topic.create("title" => "uhoh", "content" => "whatever")
1363
- assert !t.valid?
1364
- assert t.errors.on(:title)
1365
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1366
- assert_equal "hoo 5", t.errors.on("title")
1367
- end
1368
-
1369
- def test_validates_length_of_custom_errors_for_maximum_with_message_fn
1370
- Topic.validates_length_of( :title, :maximum=>5, :message => N_("%{fn} hoo %d"))
1371
-
1372
- GetText.set_locale_all "ja_JP.UTF-8"
1373
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1374
- assert !t.valid?
1375
- assert t.errors.on(:title)
1376
- assert_equal "タイトルふー5", t.errors.full_messages[0]
1377
- assert_equal "タイトルふー5", t.errors.on("title")
1378
-
1379
- GetText.set_locale_all "en"
1380
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1381
- assert !t.valid?
1382
- assert t.errors.on(:title)
1383
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1384
- assert_equal "Title hoo 5", t.errors.on("title")
1385
- end
1386
-
1387
- def test_validates_length_of_custom_errors_for_maximum_with_message
1388
- Topic.validates_length_of( :title, :maximum=>5, :message => N_("hoo %d"))
1389
-
1390
- GetText.set_locale_all "ja_JP.UTF-8"
1391
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1392
- assert !t.valid?
1393
- assert t.errors.on(:title)
1394
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
1395
- assert_equal "ふー5", t.errors.on("title")
1396
-
1397
- GetText.set_locale_all "en"
1398
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1399
- assert !t.valid?
1400
- assert t.errors.on(:title)
1401
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1402
- assert_equal "hoo 5", t.errors.on("title")
1403
- end
1404
- def test_validates_length_of_custom_errors_for_maximum_with_too_long_fn
1405
- Topic.validates_length_of( :title, :maximum=>5, :too_long => N_("%{fn} hoo %d"))
1406
-
1407
- GetText.set_locale_all "ja_JP.UTF-8"
1408
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1409
- assert !t.valid?
1410
- assert t.errors.on(:title)
1411
- assert_equal "タイトルふー5", t.errors.full_messages[0]
1412
- assert_equal "タイトルふー5", t.errors.on("title")
1413
-
1414
- GetText.set_locale_all "en"
1415
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1416
- assert !t.valid?
1417
- assert t.errors.on(:title)
1418
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1419
- assert_equal "Title hoo 5", t.errors.on("title")
1420
- end
1421
-
1422
- def test_validates_length_of_custom_errors_for_maximum_with_too_long
1423
- Topic.validates_length_of( :title, :maximum=>5, :too_long => N_("hoo %d"))
1424
-
1425
- GetText.set_locale_all "ja_JP.UTF-8"
1426
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1427
- assert !t.valid?
1428
- assert t.errors.on(:title)
1429
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
1430
- assert_equal "ふー5", t.errors.on("title")
1431
-
1432
- GetText.set_locale_all "en"
1433
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1434
- assert !t.valid?
1435
- assert t.errors.on(:title)
1436
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1437
- assert_equal "hoo 5", t.errors.on("title")
1438
- end
1439
-
1440
- def test_validates_length_of_custom_errors_for_is_with_message_fn
1441
- Topic.validates_length_of( :title, :is=>5, :message=> N_("%{fn} hoo %d") )
1442
- GetText.set_locale_all "ja_JP.UTF-8"
1443
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1444
- assert !t.valid?
1445
- assert t.errors.on(:title)
1446
- assert_equal "タイトルふー5", t.errors.full_messages[0]
1447
- assert_equal "タイトルふー5", t.errors.on("title")
1448
-
1449
- GetText.set_locale_all "en"
1450
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1451
- assert !t.valid?
1452
- assert t.errors.on(:title)
1453
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1454
- assert_equal "Title hoo 5", t.errors.on("title")
1455
- end
1456
-
1457
- def test_validates_length_of_custom_errors_for_is_with_message
1458
- Topic.validates_length_of( :title, :is=>5, :message=> N_("hoo %d") )
1459
- GetText.set_locale_all "ja_JP.UTF-8"
1460
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1461
- assert !t.valid?
1462
- assert t.errors.on(:title)
1463
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
1464
- assert_equal "ふー5", t.errors.on("title")
1465
-
1466
- GetText.set_locale_all "en"
1467
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1468
- assert !t.valid?
1469
- assert t.errors.on(:title)
1470
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1471
- assert_equal "hoo 5", t.errors.on("title")
1472
- end
1473
-
1474
- def test_validates_length_of_custom_errors_for_is_with_wrong_length_fn
1475
- Topic.validates_length_of( :title, :is=>5, :wrong_length=> N_("hoo %d") )
1476
- GetText.set_locale_all "ja_JP.UTF-8"
1477
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1478
- assert !t.valid?
1479
- assert t.errors.on(:title)
1480
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
1481
- assert_equal "ふー5", t.errors.on("title")
1482
-
1483
- GetText.set_locale_all "en"
1484
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1485
- assert !t.valid?
1486
- assert t.errors.on(:title)
1487
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1488
- assert_equal "hoo 5", t.errors.on("title")
1489
- end
1490
-
1491
- def test_validates_length_of_custom_errors_for_is_with_wrong_length
1492
- Topic.validates_length_of( :title, :is=>5, :wrong_length=> N_("hoo %d") )
1493
- GetText.set_locale_all "ja_JP.UTF-8"
1494
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1495
- assert !t.valid?
1496
- assert t.errors.on(:title)
1497
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
1498
- assert_equal "ふー5", t.errors.on("title")
1499
-
1500
- GetText.set_locale_all "en"
1501
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
1502
- assert !t.valid?
1503
- assert t.errors.on(:title)
1504
- assert_equal "Title hoo 5", t.errors.full_messages[0]
1505
- assert_equal "hoo 5", t.errors.on("title")
1506
- end
1507
-
1508
- =begin
1509
- def test_validates_length_of_using_minimum_utf8
1510
- end
1511
- def test_validates_length_of_using_maximum_utf8
1512
- end
1513
- def test_validates_length_of_using_within_utf8
1514
- end
1515
- def test_optionally_validates_length_of_using_within_utf8
1516
- end
1517
- def test_optionally_validates_length_of_using_within_on_create_utf8
1518
- end
1519
- def test_optionally_validates_length_of_using_within_on_update_utf8
1520
- end
1521
- def test_validates_length_of_using_is_utf8
1522
- end
1523
- def test_validates_size_of_association_utf8
1524
- end
1525
- def test_validates_associated_many
1526
- end
1527
- def test_validates_associated_one
1528
- end
1529
- =end
1530
-
1531
- def test_validate_block_fn
1532
- Topic.validate { |topic| topic.errors.add("title", N_("%{fn} will never be valid")) }
1533
- GetText.set_locale_all "ja_JP.UTF-8"
1534
- t = Topic.create("title" => "Title", "content" => "whatever")
1535
- assert !t.valid?
1536
- assert t.errors.on(:title)
1537
- assert_equal "タイトルは決して正しくならないでしょう。", t.errors.full_messages[0]
1538
- assert_equal "タイトルは決して正しくならないでしょう。", t.errors.on("title")
1539
-
1540
- GetText.set_locale_all "en"
1541
- t = Topic.create("title" => "Title", "content" => "whatever")
1542
- assert !t.valid?
1543
- assert t.errors.on(:title)
1544
- assert_equal "Title will never be valid", t.errors.full_messages[0]
1545
- assert_equal "Title will never be valid", t.errors.on("title")
1546
- end
1547
-
1548
- def test_validate_block
1549
- Topic.validate { |topic| topic.errors.add("title", N_("will never be valid")) }
1550
- GetText.set_locale_all "ja_JP.UTF-8"
1551
- t = Topic.create("title" => "Title", "content" => "whatever")
1552
- assert !t.valid?
1553
- assert t.errors.on(:title)
1554
- assert_equal "タイトル は決して正しくならないでしょう。", t.errors.full_messages[0]
1555
- assert_equal "は決して正しくならないでしょう。", t.errors.on("title")
1556
-
1557
- GetText.set_locale_all "en"
1558
- t = Topic.create("title" => "Title", "content" => "whatever")
1559
- assert !t.valid?
1560
- assert t.errors.on(:title)
1561
- assert_equal "Title will never be valid", t.errors.full_messages[0]
1562
- assert_equal "will never be valid", t.errors.on("title")
1563
- end
1564
-
1565
- =begin
1566
- def test_invalid_validator
1567
- end
1568
- def test_throw_away_typing
1569
- end
1570
- =end
1571
-
1572
- def test_validates_acceptance_of_with_custom_error_using_quotes_fn
1573
- Developer.validates_acceptance_of :salary, :message=> N_("%{fn} contains 'single' and \"double\" quotes")
1574
-
1575
- GetText.set_locale_all "ja_JP.UTF-8"
1576
- d = Developer.new
1577
- d.salary = "0"
1578
- assert !d.valid?
1579
- if AR_6657
1580
- assert_equal "給料は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).last
1581
- else
1582
- assert_equal "給料は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).first
1583
- end
1584
- GetText.set_locale_all "en"
1585
- d = Developer.new
1586
- d.salary = "0"
1587
- assert !d.valid?
1588
- if AR_6657
1589
- assert_equal "Salary contains 'single' and \"double\" quotes", d.errors.on(:salary).last
1590
- else
1591
- assert_equal "Salary contains 'single' and \"double\" quotes", d.errors.on(:salary).first
1592
- end
1593
- end
1594
-
1595
- def test_validates_acceptance_of_with_custom_error_using_quotes
1596
- Developer.validates_acceptance_of :salary, :message=> N_("This string contains 'single' and \"double\" quotes")
1597
-
1598
- GetText.set_locale_all "ja_JP.UTF-8"
1599
- d = Developer.new
1600
- d.salary = "0"
1601
- assert !d.valid?
1602
- if AR_6657
1603
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).last
1604
- else
1605
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).first
1606
- end
1607
- GetText.set_locale_all "en"
1608
- d = Developer.new
1609
- d.salary = "0"
1610
- assert !d.valid?
1611
- if AR_6657
1612
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).last
1613
- else
1614
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).first
1615
- end
1616
- end
1617
-
1618
- def test_validates_confirmation_of_with_custom_error_using_quotes_fn
1619
- Developer.validates_confirmation_of :name, :message=> N_("%{fn} contains 'single' and \"double\" quotes")
1620
-
1621
- GetText.set_locale_all "ja_JP.UTF-8"
1622
- d = Developer.new
1623
- d.name = "John"
1624
- d.name_confirmation = "Johnny"
1625
- assert !d.valid?
1626
- if AR_6657
1627
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
1628
- else
1629
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
1630
- end
1631
- GetText.set_locale_all "en"
1632
- d = Developer.new
1633
- d.name = "John"
1634
- d.name_confirmation = "Johnny"
1635
- assert !d.valid?
1636
- if AR_6657
1637
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
1638
- else
1639
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
1640
- end
1641
- end
1642
-
1643
- def test_validates_confirmation_of_with_custom_error_using_quotes
1644
- Developer.validates_confirmation_of :name, :message=> N_("This string contains 'single' and \"double\" quotes")
1645
-
1646
- GetText.set_locale_all "ja_JP.UTF-8"
1647
- d = Developer.new
1648
- d.name = "John"
1649
- d.name_confirmation = "Johnny"
1650
- assert !d.valid?
1651
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name)
1652
-
1653
- GetText.set_locale_all "en"
1654
- d = Developer.new
1655
- d.name = "John"
1656
- d.name_confirmation = "Johnny"
1657
- assert !d.valid?
1658
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name)
1659
- end
1660
-
1661
- def test_validates_format_of_with_custom_error_using_quotes_fn
1662
- Developer.validates_format_of :name, :with => /^(A-Z*)$/, :message => "%{fn} contains 'single' and \"double\" quotes"
1663
-
1664
- GetText.set_locale_all "ja_JP.UTF-8"
1665
- d = Developer.new
1666
- d.name = "John 32"
1667
- assert !d.valid?
1668
- if AR_6657
1669
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
1670
- else
1671
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
1672
- end
1673
-
1674
- GetText.set_locale_all "en"
1675
- d = Developer.new
1676
- d.name = "John 32"
1677
- assert !d.valid?
1678
- if AR_6657
1679
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
1680
- else
1681
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
1682
- end
1683
- end
1684
-
1685
- def test_validates_format_of_with_custom_error_using_quotes
1686
- Developer.validates_format_of :name, :with => /^(A-Z*)$/, :message => "This string contains 'single' and \"double\" quotes"
1687
-
1688
- GetText.set_locale_all "ja_JP.UTF-8"
1689
- d = Developer.new
1690
- d.name = "John 32"
1691
- assert !d.valid?
1692
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name)
1693
-
1694
- GetText.set_locale_all "en"
1695
- d = Developer.new
1696
- d.name = "John 32"
1697
- assert !d.valid?
1698
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name)
1699
- end
1700
-
1701
- def test_validates_inclusion_of_with_custom_error_using_quotes_fn
1702
- Developer.validates_inclusion_of :salary, :in => 1000..80000, :message=> N_("%{fn} contains 'single' and \"double\" quotes")
1703
-
1704
- GetText.set_locale_all "ja_JP.UTF-8"
1705
- d = Developer.new
1706
- d.salary = "90,000"
1707
- assert !d.valid?
1708
- if AR_6657
1709
- assert_equal "給料は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).last
1710
- else
1711
- assert_equal "給料は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).first
1712
- end
1713
- GetText.set_locale_all "en"
1714
- d = Developer.new
1715
- d.salary = "90,000"
1716
- assert !d.valid?
1717
- if AR_6657
1718
- assert_equal "Salary contains 'single' and \"double\" quotes", d.errors.on(:salary).last
1719
- else
1720
- assert_equal "Salary contains 'single' and \"double\" quotes", d.errors.on(:salary).first
1721
- end
1722
- end
1723
-
1724
- def test_validates_inclusion_of_with_custom_error_using_quotes
1725
- Developer.validates_inclusion_of :salary, :in => 1000..80000, :message=> N_("This string contains 'single' and \"double\" quotes")
1726
-
1727
- GetText.set_locale_all "ja_JP.UTF-8"
1728
- d = Developer.new
1729
- d.salary = "90,000"
1730
- assert !d.valid?
1731
- if AR_6657
1732
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).last
1733
- else
1734
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:salary).first
1735
- end
1736
- GetText.set_locale_all "en"
1737
- d = Developer.new
1738
- d.salary = "90,000"
1739
- assert !d.valid?
1740
- if AR_6657
1741
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).last
1742
- else
1743
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).first
1744
- end
1745
- end
1746
-
1747
- def test_validates_length_of_with_custom_too_long_using_quotes_fn
1748
- Developer.validates_length_of :name, :maximum => 4, :too_long=> N_("%{fn} contains 'single' and \"double\" quotes")
1749
-
1750
- GetText.set_locale_all "ja_JP.UTF-8"
1751
- d = Developer.new
1752
- d.name = "Jeffrey"
1753
- assert !d.valid?
1754
- if AR_6657
1755
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
1756
- else
1757
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
1758
- end
1759
- GetText.set_locale_all "en"
1760
- d = Developer.new
1761
- d.name = "Jeffrey"
1762
- assert !d.valid?
1763
- if AR_6657
1764
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
1765
- else
1766
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
1767
- end
1768
- end
1769
-
1770
- def test_validates_length_of_with_custom_too_long_using_quotes
1771
- Developer.validates_length_of :name, :maximum => 4, :too_long=> N_("This string contains 'single' and \"double\" quotes")
1772
-
1773
- GetText.set_locale_all "ja_JP.UTF-8"
1774
- d = Developer.new
1775
- d.name = "Jeffrey"
1776
- assert !d.valid?
1777
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
1778
-
1779
- GetText.set_locale_all "en"
1780
- d = Developer.new
1781
- d.name = "Jeffrey"
1782
- assert !d.valid?
1783
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).last
1784
- end
1785
-
1786
- def test_validates_length_of_with_custom_too_short_using_quotes_fn
1787
- Developer.validates_length_of :name, :minimum => 4, :too_short=> N_("%{fn} contains 'single' and \"double\" quotes")
1788
- GetText.set_locale_all "ja_JP.UTF-8"
1789
- d = Developer.new
1790
- d.name = "Joe"
1791
- assert !d.valid?
1792
- if AR_6657
1793
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
1794
- else
1795
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
1796
- end
1797
- GetText.set_locale_all "en"
1798
- d = Developer.new
1799
- d.name = "Joe"
1800
- assert !d.valid?
1801
- if AR_6657
1802
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
1803
- else
1804
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
1805
- end
1806
- end
1807
-
1808
- def test_validates_length_of_with_custom_too_short_using_quotes
1809
- Developer.validates_length_of :name, :minimum => 4, :too_short=> N_("This string contains 'single' and \"double\" quotes")
1810
- GetText.set_locale_all "ja_JP.UTF-8"
1811
- d = Developer.new
1812
- d.name = "Joe"
1813
- assert !d.valid?
1814
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
1815
-
1816
- GetText.set_locale_all "en"
1817
- d = Developer.new
1818
- d.name = "Joe"
1819
- assert !d.valid?
1820
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).last
1821
- end
1822
-
1823
- def test_validates_length_of_with_custom_message_using_quotes_fn
1824
- GetText.set_locale_all "ja_JP.UTF-8"
1825
- Developer.validates_length_of :name, :minimum => 4, :message=> N_("%{fn} contains 'single' and \"double\" quotes")
1826
- d = Developer.new
1827
- d.name = "Joe"
1828
- assert !d.valid?
1829
- if AR_6657
1830
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
1831
- else
1832
- assert_equal "開発者名は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
1833
- end
1834
- GetText.set_locale_all "en"
1835
- d = Developer.new
1836
- d.name = "Joe"
1837
- assert !d.valid?
1838
- if AR_6657
1839
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).last
1840
- else
1841
- assert_equal "Name contains 'single' and \"double\" quotes", d.errors.on(:name).first
1842
- end
1843
- end
1844
-
1845
- def test_validates_length_of_with_custom_message_using_quotes
1846
- GetText.set_locale_all "ja_JP.UTF-8"
1847
- Developer.validates_length_of :name, :minimum => 4, :message=> N_("This string contains 'single' and \"double\" quotes")
1848
- d = Developer.new
1849
- d.name = "Joe"
1850
- assert !d.valid?
1851
- if AR_6657
1852
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).last
1853
- else
1854
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:name).first
1855
- end
1856
- GetText.set_locale_all "en"
1857
- d = Developer.new
1858
- d.name = "Joe"
1859
- assert !d.valid?
1860
- if AR_6657
1861
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).last
1862
- else
1863
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name).first
1864
- end
1865
- end
1866
-
1867
- def test_validates_presence_of_with_custom_message_using_quotes_fn
1868
- # This test depends on test_validates_presence_of_with_custom_message_using_quotes
1869
- GetText.set_locale_all "ja_JP.UTF-8"
1870
- Developer.validates_presence_of :non_existent, :message=> N_("%{fn} contains 'single' and \"double\" quotes")
1871
- d = Developer.new
1872
- d.name = "Joe"
1873
- assert !d.valid?
1874
-
1875
- if AR_6657
1876
- assert_equal "存在しないは'シングル' \"ダブル\"クオートを含む。", d.errors.on(:non_existent).last
1877
- else
1878
- assert_equal "存在しないは'シングル' \"ダブル\"クオートを含む。", d.errors.on(:non_existent).first
1879
- end
1880
- GetText.set_locale_all "en"
1881
- d = Developer.new
1882
- d.name = "Joe"
1883
- assert !d.valid?
1884
- if AR_6657
1885
- assert_equal "Non existent contains 'single' and \"double\" quotes", d.errors.on(:non_existent).last
1886
- else
1887
- assert_equal "Non existent contains 'single' and \"double\" quotes", d.errors.on(:non_existent).first
1888
- end
1889
- end
1890
-
1891
- def test_validates_presence_of_with_custom_message_using_quotes
1892
- GetText.set_locale_all "ja_JP.UTF-8"
1893
- Developer.validates_presence_of :non_existent, :message=> N_("This string contains 'single' and \"double\" quotes")
1894
- d = Developer.new
1895
- d.name = "Joe"
1896
- assert !d.valid?
1897
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", d.errors.on(:non_existent)
1898
- GetText.set_locale_all "en"
1899
- d = Developer.new
1900
- d.name = "Joe"
1901
- assert !d.valid?
1902
- assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:non_existent)
1903
- end
1904
-
1905
- def test_validates_uniqueness_of_with_custom_message_using_quotes_fn
1906
- Developer.validates_uniqueness_of :name, :message=> N_("%{fn} contains 'single' and \"double\" quotes")
1907
-
1908
- GetText.set_locale_all "ja_JP.UTF-8"
1909
- d = Developer.new
1910
- d.name = "David"
1911
- assert !d.valid?
1912
- if AR_6657
1913
- assert_equal d.errors.on(:name).last, "開発者名は'シングル' \"ダブル\"クオートを含む。"
1914
- else
1915
- assert_equal d.errors.on(:name).first, "開発者名は'シングル' \"ダブル\"クオートを含む。"
1916
- end
1917
-
1918
- GetText.set_locale_all "en"
1919
- d = Developer.new
1920
- d.name = "David"
1921
- assert !d.valid?
1922
- if AR_6657
1923
- assert_equal d.errors.on(:name).last, "Name contains 'single' and \"double\" quotes"
1924
- else
1925
- assert_equal d.errors.on(:name).first, "Name contains 'single' and \"double\" quotes"
1926
- end
1927
- end
1928
-
1929
- def test_validates_uniqueness_of_with_custom_message_using_quotes
1930
- Developer.validates_uniqueness_of :name, :message=> N_("This string contains 'single' and \"double\" quotes")
1931
-
1932
- GetText.set_locale_all "ja_JP.UTF-8"
1933
- d = Developer.new
1934
- d.name = "David"
1935
- assert !d.valid?
1936
- if AR_6657
1937
- assert_equal d.errors.on(:name).first, "この文字列は'シングル' \"ダブル\"クオートを含む。"
1938
- else
1939
- assert_equal d.errors.on(:name).last, "この文字列は'シングル' \"ダブル\"クオートを含む。"
1940
- end
1941
- GetText.set_locale_all "en"
1942
- d = Developer.new
1943
- d.name = "David"
1944
- assert !d.valid?
1945
- if AR_6657
1946
- assert_equal d.errors.on(:name).first, "This string contains 'single' and \"double\" quotes"
1947
- else
1948
- assert_equal d.errors.on(:name).last, "This string contains 'single' and \"double\" quotes"
1949
- end
1950
- end
1951
-
1952
- def test_validates_associated_with_custom_message_using_quotes_fn
1953
- Reply.validates_associated :topic, :message => N_("%{fn} contains 'single' and \"double\" quotes")
1954
- Topic.validates_presence_of :content
1955
- r = Reply.create("title" => "A reply", "content" => "with content!")
1956
- r.topic = Topic.create("title" => "uhohuhoh")
1957
- assert !r.valid?
1958
- assert r.errors.on(:topic)
1959
- r.topic.content = "non-empty"
1960
- assert r.valid?
1961
-
1962
- GetText.set_locale_all "ja_JP.UTF-8"
1963
- r = Reply.create("title" => "A reply", "content" => "with content!")
1964
- r.topic = Topic.create("title" => "uhohuhoh")
1965
- assert !r.valid?
1966
- if AR_6657
1967
- assert_equal "Replyトピックは'シングル' \"ダブル\"クオートを含む。", r.errors.on(:topic).last
1968
- else
1969
- assert_equal "Replyトピックは'シングル' \"ダブル\"クオートを含む。", r.errors.on(:topic).first
1970
- end
1971
-
1972
- GetText.set_locale_all "en"
1973
- r = Reply.create("title" => "A reply", "content" => "with content!")
1974
- r.topic = Topic.create("title" => "uhohuhoh")
1975
- assert !r.valid?
1976
- if AR_6657
1977
- assert_equal "Topic contains 'single' and \"double\" quotes", r.errors.on(:topic).last
1978
- else
1979
- assert_equal "Topic contains 'single' and \"double\" quotes", r.errors.on(:topic).first
1980
- end
1981
- end
1982
-
1983
- def test_validates_associated_with_custom_message_using_quotes
1984
- Reply.validates_associated :topic, :message => N_("This string contains 'single' and \"double\" quotes")
1985
- Topic.validates_presence_of :content
1986
- r = Reply.create("title" => "A reply", "content" => "with content!")
1987
- r.topic = Topic.create("title" => "uhohuhoh")
1988
- assert !r.valid?
1989
- assert r.errors.on(:topic)
1990
- r.topic.content = "non-empty"
1991
- assert r.valid?
1992
-
1993
- GetText.set_locale_all "ja_JP.UTF-8"
1994
- r = Reply.create("title" => "A reply", "content" => "with content!")
1995
- r.topic = Topic.create("title" => "uhohuhoh")
1996
- assert !r.valid?
1997
- assert_equal "この文字列は'シングル' \"ダブル\"クオートを含む。", r.errors.on(:topic)
1998
-
1999
- GetText.set_locale_all "en"
2000
- r = Reply.create("title" => "A reply", "content" => "with content!")
2001
- r.topic = Topic.create("title" => "uhohuhoh")
2002
- assert !r.valid?
2003
- assert_equal "This string contains 'single' and \"double\" quotes", r.errors.on(:topic)
2004
- end
2005
-
2006
- =begin
2007
- def test_if_validation_using_method_true
2008
- end
2009
- def test_unless_validation_using_method_true
2010
- end
2011
- def test_if_validation_using_method_false
2012
- end
2013
- =end
2014
- def test_unless_validation_using_method_false_fn
2015
- # When the method returns false
2016
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("%{fn} hoo %d"), :unless => :condition_is_true_but_its_not )
2017
-
2018
- GetText.set_locale_all "ja"
2019
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2020
- assert !t.valid?
2021
- assert t.errors.on(:title)
2022
- assert_equal "タイトルふー5", t.errors.full_messages[0]
2023
- assert_equal "タイトルふー5", t.errors["title"]
2024
-
2025
- GetText.set_locale_all "en"
2026
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2027
- assert !t.valid?
2028
- assert t.errors.on(:title)
2029
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2030
- assert_equal "Title hoo 5", t.errors["title"]
2031
- end
2032
-
2033
- def test_unless_validation_using_method_false
2034
- # When the method returns false
2035
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("hoo %d"), :unless => :condition_is_true_but_its_not )
2036
-
2037
- GetText.set_locale_all "ja"
2038
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2039
- assert !t.valid?
2040
- assert t.errors.on(:title)
2041
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
2042
- assert_equal "ふー5", t.errors["title"]
2043
-
2044
- GetText.set_locale_all "en"
2045
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2046
- assert !t.valid?
2047
- assert t.errors.on(:title)
2048
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2049
- assert_equal "hoo 5", t.errors["title"]
2050
- end
2051
-
2052
- def test_if_validation_using_string_true_fn
2053
- # When the evaluated string returns true
2054
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("%{fn} hoo %d"), :if => "a = 1; a == 1" )
2055
-
2056
- GetText.set_locale_all "ja"
2057
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2058
- assert !t.valid?
2059
- assert t.errors.on(:title)
2060
- assert_equal "タイトルふー5", t.errors.full_messages[0]
2061
- assert_equal "タイトルふー5", t.errors["title"]
2062
-
2063
- GetText.set_locale_all "en"
2064
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2065
- assert !t.valid?
2066
- assert t.errors.on(:title)
2067
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2068
- assert_equal "Title hoo 5", t.errors["title"]
2069
- end
2070
-
2071
- def test_if_validation_using_string_true
2072
- # When the evaluated string returns true
2073
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("hoo %d"), :if => "a = 1; a == 1" )
2074
-
2075
- GetText.set_locale_all "ja"
2076
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2077
- assert !t.valid?
2078
- assert t.errors.on(:title)
2079
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
2080
- assert_equal "ふー5", t.errors["title"]
2081
-
2082
- GetText.set_locale_all "en"
2083
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2084
- assert !t.valid?
2085
- assert t.errors.on(:title)
2086
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2087
- assert_equal "hoo 5", t.errors["title"]
2088
- end
2089
-
2090
- =begin
2091
- def test_unless_validation_using_string_true
2092
- end
2093
- def test_if_validation_using_string_false
2094
- end
2095
- =end
2096
- def test_unless_validation_using_string_false
2097
- # When the evaluated string returns false
2098
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("hoo %d"), :unless => "false")
2099
-
2100
- GetText.set_locale_all "ja"
2101
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2102
- assert !t.valid?
2103
- assert t.errors.on(:title)
2104
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
2105
- assert_equal "ふー5", t.errors["title"]
2106
-
2107
- GetText.set_locale_all "en"
2108
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2109
- assert !t.valid?
2110
- assert t.errors.on(:title)
2111
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2112
- assert_equal "hoo 5", t.errors["title"]
2113
- end
2114
-
2115
- def test_if_validation_using_block_true_fn
2116
- # When the block returns true
2117
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("%{fn} hoo %d"),
2118
- :if => Proc.new { |r| r.content.size > 4 } )
2119
-
2120
- GetText.set_locale_all "ja"
2121
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2122
- assert !t.valid?
2123
- assert t.errors.on(:title)
2124
- assert_equal "タイトルふー5", t.errors.full_messages[0]
2125
- assert_equal "タイトルふー5", t.errors["title"]
2126
-
2127
- GetText.set_locale_all "en"
2128
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2129
- assert !t.valid?
2130
- assert t.errors.on(:title)
2131
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2132
- assert_equal "Title hoo 5", t.errors["title"]
2133
- end
2134
-
2135
- def test_if_validation_using_block_true
2136
- # When the block returns true
2137
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("hoo %d"),
2138
- :if => Proc.new { |r| r.content.size > 4 } )
2139
-
2140
- GetText.set_locale_all "ja"
2141
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2142
- assert !t.valid?
2143
- assert t.errors.on(:title)
2144
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
2145
- assert_equal "ふー5", t.errors["title"]
2146
-
2147
- GetText.set_locale_all "en"
2148
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2149
- assert !t.valid?
2150
- assert t.errors.on(:title)
2151
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2152
- assert_equal "hoo 5", t.errors["title"]
2153
- end
2154
-
2155
- def test_conditional_validation_using_method_true_fn
2156
- # When the method returns true
2157
- Topic.validates_length_of( :title, :maximum=>5, :too_long=> N_("%{fn} hoo %d"), :if => :condition_is_true )
2158
- GetText.set_locale_all "ja_JP.UTF-8"
2159
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2160
- assert !t.valid?
2161
- assert t.errors.on(:title)
2162
- assert_equal "タイトルふー5", t.errors.full_messages[0]
2163
- assert_equal "タイトルふー5", t.errors.on("title")
2164
-
2165
- GetText.set_locale_all "en"
2166
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2167
- assert !t.valid?
2168
- assert t.errors.on(:title)
2169
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2170
- assert_equal "Title hoo 5", t.errors.on("title")
2171
- end
2172
-
2173
- =begin
2174
- Don't need this
2175
- def test_unless_validation_using_block_true
2176
- end
2177
- def test_if_validation_using_block_false
2178
- end
2179
- =end
2180
-
2181
- def test_unless_validation_using_block_false_fn
2182
- # When the block returns false
2183
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("%{fn} hoo %d"),
2184
- :unless => Proc.new { |r| r.title != "uhohuhoh"} )
2185
-
2186
- GetText.set_locale_all "ja_JP.UTF-8"
2187
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2188
- assert !t.valid?
2189
- assert t.errors.on(:title)
2190
- assert_equal "タイトルふー5", t.errors.full_messages[0]
2191
- assert_equal "タイトルふー5", t.errors.on("title")
2192
-
2193
- GetText.set_locale_all "en"
2194
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2195
- assert !t.valid?
2196
- assert t.errors.on(:title)
2197
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2198
- assert_equal "Title hoo 5", t.errors["title"]
2199
- end
2200
-
2201
- def test_unless_validation_using_block_false
2202
- # When the block returns false
2203
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>N_("hoo %d"),
2204
- :unless => Proc.new { |r| r.title != "uhohuhoh"} )
2205
-
2206
- GetText.set_locale_all "ja_JP.UTF-8"
2207
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2208
- assert !t.valid?
2209
- assert t.errors.on(:title)
2210
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
2211
- assert_equal "ふー5", t.errors.on("title")
2212
-
2213
- GetText.set_locale_all "en"
2214
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2215
- assert !t.valid?
2216
- assert t.errors.on(:title)
2217
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2218
- assert_equal "hoo 5", t.errors["title"]
2219
- end
2220
-
2221
- def test_conditional_validation_using_method_true
2222
- # When the method returns true
2223
- Topic.validates_length_of( :title, :maximum=>5, :too_long=> N_("hoo %d"), :if => :condition_is_true )
2224
- GetText.set_locale_all "ja_JP.UTF-8"
2225
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2226
- assert !t.valid?
2227
- assert t.errors.on(:title)
2228
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
2229
- assert_equal "ふー5", t.errors.on("title")
2230
-
2231
- GetText.set_locale_all "en"
2232
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2233
- assert !t.valid?
2234
- assert t.errors.on(:title)
2235
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2236
- assert_equal "hoo 5", t.errors.on("title")
2237
- end
2238
-
2239
- def test_conditional_validation_using_string_true_fn
2240
- # When the evaluated string returns true
2241
- Topic.validates_length_of( :title, :maximum=>5, :too_long=> N_("%{fn} hoo %d"), :if => "a = 1; a == 1" )
2242
-
2243
- GetText.set_locale_all "ja_JP.UTF-8"
2244
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2245
- assert !t.valid?
2246
- assert t.errors.on(:title)
2247
- assert_equal "タイトルふー5", t.errors.full_messages[0]
2248
- assert_equal "タイトルふー5", t.errors.on("title")
2249
-
2250
- GetText.set_locale_all "en"
2251
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2252
- assert !t.valid?
2253
- assert t.errors.on(:title)
2254
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2255
- assert_equal "Title hoo 5", t.errors.on("title")
2256
- end
2257
-
2258
- def test_conditional_validation_using_string_true
2259
- # When the evaluated string returns true
2260
- Topic.validates_length_of( :title, :maximum=>5, :too_long=> N_("hoo %d"), :if => "a = 1; a == 1" )
2261
-
2262
- GetText.set_locale_all "ja_JP.UTF-8"
2263
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2264
- assert !t.valid?
2265
- assert t.errors.on(:title)
2266
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
2267
- assert_equal "ふー5", t.errors.on("title")
2268
-
2269
- GetText.set_locale_all "en"
2270
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2271
- assert !t.valid?
2272
- assert t.errors.on(:title)
2273
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2274
- assert_equal "hoo 5", t.errors.on("title")
2275
- end
2276
-
2277
- def test_conditional_validation_using_block_true_fn
2278
- # When the block returns true
2279
- GetText.set_locale_all "ja_JP.UTF-8"
2280
- Topic.validates_length_of( :title, :maximum=>5, :too_long => N_("%{fn} hoo %d"),
2281
- :if => Proc.new { |r| r.content.size > 4 } )
2282
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2283
- assert !t.valid?
2284
- assert t.errors.on(:title)
2285
- assert_equal "タイトルふー5", t.errors.full_messages[0]
2286
- assert_equal "タイトルふー5", t.errors.on("title")
2287
-
2288
- GetText.set_locale_all "en"
2289
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2290
- assert !t.valid?
2291
- assert t.errors.on(:title)
2292
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2293
- assert_equal "Title hoo 5", t.errors.on("title")
2294
-
2295
- end
2296
-
2297
- def test_conditional_validation_using_block_true
2298
- # When the block returns true
2299
- GetText.set_locale_all "ja_JP.UTF-8"
2300
- Topic.validates_length_of( :title, :maximum=>5, :too_long => N_("hoo %d"),
2301
- :if => Proc.new { |r| r.content.size > 4 } )
2302
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2303
- assert !t.valid?
2304
- assert t.errors.on(:title)
2305
- assert_equal "タイトル ふー5", t.errors.full_messages[0]
2306
- assert_equal "ふー5", t.errors.on("title")
2307
-
2308
- GetText.set_locale_all "en"
2309
- t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
2310
- assert !t.valid?
2311
- assert t.errors.on(:title)
2312
- assert_equal "Title hoo 5", t.errors.full_messages[0]
2313
- assert_equal "hoo 5", t.errors.on("title")
2314
-
2315
- end
2316
-
2317
- def test_validates_associated_missing
2318
- GetText.set_locale_all "ja_JP.UTF-8"
2319
- Reply.validates_presence_of(:topic)
2320
- r = Reply.create("title" => "A reply", "content" => "with content!")
2321
- # In this case, rgettext doesn't pick up the names of relations as msgid,
2322
- # so you need to define N_() in the model class
2323
- assert_equal "Replyトピックを入力してください。", r.errors.on(:topic)
2324
-
2325
- GetText.set_locale_all "en"
2326
- r = Reply.create("title" => "A reply", "content" => "with content!")
2327
- assert_equal "Topic can't be blank", r.errors.on(:topic)
2328
- assert_equal "Topic can't be blank", r.errors.full_messages[0]
2329
- end
2330
-
2331
- def test_errors_to_xml
2332
- GetText.set_locale_all "ja_JP.UTF-8"
2333
- r = Reply.new :title => "Wrong Create"
2334
- assert !r.valid?
2335
- xml = r.errors.to_xml(:skip_instruct => true)
2336
- assert_equal "<errors>", xml.first(8)
2337
- assert xml.include?("<error>Reply&#12479;&#12452;&#12488;&#12523; &#12364;&#19981;&#27491;&#12395;&#29983;&#25104;&#12373;&#12428;&#12414;&#12375;&#12383;&#12290;</error>")
2338
- assert xml.include?("<error>Reply&#20869;&#23481; &#31354;&#12391;&#12377;&#12290;</error>")
2339
-
2340
- GetText.set_locale_all "en"
2341
- r = Reply.new :title => "Wrong Create"
2342
- assert !r.valid?
2343
- xml = r.errors.to_xml(:skip_instruct => true)
2344
- assert_equal "<errors>", xml.first(8)
2345
- assert xml.include?("<error>Title is Wrong Create</error>")
2346
- assert xml.include?("<error>Content Empty</error>")
2347
- end
2348
-
2349
- def test_validation_order
2350
- if AR_6657
2351
- Topic.validates_presence_of :title
2352
- Topic.validates_length_of :title, :minimum => 2
2353
-
2354
- GetText.set_locale_all "ja_JP.UTF-8"
2355
- t = Topic.new("title" => "")
2356
- assert !t.valid?
2357
- assert_equal "タイトルを入力してください。", t.errors.on("title").first
2358
-
2359
- GetText.set_locale_all "en"
2360
- t = Topic.new("title" => "")
2361
- assert !t.valid?
2362
- assert_equal "Title can't be blank", t.errors.on("title").first
2363
- end
2364
- end
2365
-
2366
- =begin
2367
- #Don't need this
2368
- def test_validation_with_if_as_string
2369
- end
2370
- =end
2371
-
2372
- def test_default_validates_numericality_of
2373
- GetText.set_locale_all "ja_JP.UTF-8"
2374
- Topic.validates_numericality_of :approved
2375
- topic = Topic.create("title" => "numeric test", "content" => "whatever", "approved" => "aaa")
2376
- assert_equal "承認は数値で入力してください。", topic.errors.on(:approved)
2377
-
2378
- GetText.set_locale_all "en"
2379
- topic = Topic.create("title" => "numeric test", "content" => "whatever", "approved" => "aaa")
2380
- assert_equal "Approved is not a number", topic.errors.on(:approved)
2381
- assert_equal "Approved is not a number", topic.errors.full_messages[0]
2382
- end
2383
-
2384
- def test_inherited_messages
2385
- GetText.set_locale_all "ja_JP.UTF-8"
2386
- Topic.validates_presence_of(:title, :content)
2387
-
2388
- GetText.set_locale_all "ja_JP.UTF-8"
2389
- t = Topic.create
2390
- assert !t.save
2391
- assert_equal "タイトルを入力してください。", t.errors.full_messages[0]
2392
- assert_equal "内容を入力してください。", t.errors.full_messages[1]
2393
- assert_equal "タイトルを入力してください。", t.errors.on(:title)
2394
- assert_equal "内容を入力してください。", t.errors.on(:content)
2395
-
2396
- t = Reply.create
2397
- assert !t.save
2398
- assert_equal "Replyタイトルを入力してください。", t.errors.full_messages[0]
2399
- assert_equal "Replyタイトル 空です。", t.errors.full_messages[1]
2400
- assert_equal "Reply内容を入力してください。", t.errors.full_messages[2]
2401
- assert_equal "Reply内容 空です。", t.errors.full_messages[3]
2402
- assert_equal ["Replyタイトルを入力してください。","空です。"], t.errors.on(:title)
2403
- assert_equal ["Reply内容を入力してください。", "空です。"], t.errors.on(:content)
2404
-
2405
- t = Reply.create
2406
- t.title = "Wrong Create"
2407
- assert !t.save
2408
- assert_equal "Replyタイトル が不正に生成されました。", t.errors.full_messages[0]
2409
- assert_equal "Reply内容を入力してください。", t.errors.full_messages[1]
2410
- assert_equal "Reply内容 空です。", t.errors.full_messages[2]
2411
-
2412
- t = SillyReply.create
2413
- assert !t.save
2414
- assert_equal "Sillyタイトルを入力してください。", t.errors.full_messages[0]
2415
- assert_equal "Sillyタイトル 空です。", t.errors.full_messages[1]
2416
- assert_equal "Silly内容を入力してください。", t.errors.full_messages[2]
2417
- assert_equal "Silly内容 空です。", t.errors.full_messages[3]
2418
- assert_equal ["Sillyタイトルを入力してください。","空です。"], t.errors.on(:title)
2419
- assert_equal ["Silly内容を入力してください。","空です。"], t.errors.on(:content)
2420
-
2421
- t = SillyReply.create
2422
- t.title = "Wrong Create"
2423
- assert !t.save
2424
- assert_equal "Sillyタイトル が不正に生成されました。", t.errors.full_messages[0]
2425
- assert_equal "Silly内容を入力してください。", t.errors.full_messages[1]
2426
- assert_equal "Silly内容 空です。", t.errors.full_messages[2]
2427
- end
2428
-
2429
- def test_original_model_with_validation
2430
- GetText.set_locale_all "ja_JP.UTF-8"
2431
- t = MyModel.new
2432
- t.title = nil
2433
- t.save
2434
- assert_equal "Titleを入力してください。", t.errors.full_messages[0]
2435
- assert_equal "Titleを入力してください。", t.errors.on(:title)
2436
-
2437
- GetText.set_locale_all "en"
2438
- t = MyModel.new
2439
- t.title = nil
2440
- t.save
2441
- assert_equal "Title can't be blank", t.errors.full_messages[0]
2442
- assert_equal "Title can't be blank", t.errors.on(:title)
2443
- end
2444
- end
2445
-
2446
- class ValidatesNumericalityTest < Test::Unit::TestCase
2447
- include GetText
2448
-
2449
- NIL = [nil]
2450
- BLANK = ["", " ", " \t \r \n"]
2451
- BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significent digits
2452
- FLOAT_STRINGS = %w(0.0 +0.0 -0.0 10.0 10.5 -10.5 -0.0001 -090.1 90.1e1 -90.1e5 -90.1e-5 90e-5)
2453
- INTEGER_STRINGS = %w(0 +0 -0 10 +10 -10 0090 -090)
2454
- FLOATS = [0.0, 10.0, 10.5, -10.5, -0.0001] + FLOAT_STRINGS
2455
- INTEGERS = [0, 10, -10] + INTEGER_STRINGS
2456
- BIGDECIMAL = BIGDECIMAL_STRINGS.collect! { |bd| BigDecimal.new(bd) }
2457
- JUNK = ["not a number", "42 not a number", "0xdeadbeef", "00-1", "--3", "+-3", "+3-1", "-+019.0", "12.12.13.12", "123\nnot a number"]
2458
-
2459
- def setup
2460
- bindtextdomain_to(Topic, "active_record")
2461
-
2462
- Topic.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
2463
- Topic.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
2464
- Topic.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
2465
- end
2466
-
2467
- def test_default_validates_numericality_of
2468
- Topic.validates_numericality_of :approved
2469
-
2470
- invalid!(NIL + BLANK + JUNK)
2471
- # valid!(FLOATS + INTEGERS + BIGDECIMAL)
2472
- end
2473
-
2474
- def test_validates_numericality_of_with_nil_allowed
2475
- Topic.validates_numericality_of :approved, :allow_nil => true
2476
-
2477
- invalid!(BLANK + JUNK)
2478
- # valid!(NIL + FLOATS + INTEGERS + BIGDECIMAL)
2479
- end
2480
-
2481
- def test_validates_numericality_of_with_integer_only
2482
- Topic.validates_numericality_of :approved, :only_integer => true
2483
-
2484
- invalid!(NIL + BLANK + JUNK + FLOATS + BIGDECIMAL)
2485
- # valid!(INTEGERS)
2486
- end
2487
-
2488
- def test_validates_numericality_of_with_integer_only_and_nil_allowed
2489
- Topic.validates_numericality_of :approved, :only_integer => true, :allow_nil => true
2490
-
2491
- invalid!(BLANK + JUNK + FLOATS + BIGDECIMAL)
2492
- # valid!(NIL + INTEGERS)
2493
- end
2494
-
2495
- def test_validates_numericality_with_greater_than
2496
- Topic.validates_numericality_of :approved, :greater_than => 10
2497
-
2498
- invalid!([-10, 10], 'Approved must be greater than 10',
2499
- '承認は10より大きい値にしてください。')
2500
- # valid!([11])
2501
- end
2502
-
2503
- def test_validates_numericality_with_greater_than_or_equal
2504
- Topic.validates_numericality_of :approved, :greater_than_or_equal_to => 10
2505
-
2506
- invalid!([-9, 9], 'Approved must be greater than or equal to 10',
2507
- "承認は10以上の値にしてください。")
2508
- # valid!([10])
2509
- end
2510
-
2511
- def test_validates_numericality_with_equal_to
2512
- Topic.validates_numericality_of :approved, :equal_to => 10
2513
-
2514
- invalid!([-10, 11], 'Approved must be equal to 10',
2515
- "承認は10にしてください。")
2516
- # valid!([10])
2517
- end
2518
-
2519
- def test_validates_numericality_with_less_than
2520
- Topic.validates_numericality_of :approved, :less_than => 10
2521
-
2522
- invalid!([10], 'Approved must be less than 10',
2523
- "承認は10より小さい値にしてください。")
2524
- # valid!([-9, 9])
2525
- end
2526
-
2527
- def test_validates_numericality_with_less_than_or_equal_to
2528
- Topic.validates_numericality_of :approved, :less_than_or_equal_to => 10
2529
-
2530
- invalid!([11], 'Approved must be less than or equal to 10')
2531
- # valid!([-10, 10])
2532
- end
2533
-
2534
- def test_validates_numericality_with_odd
2535
- Topic.validates_numericality_of :approved, :odd => true
2536
-
2537
- invalid!([-2, 2], 'Approved must be odd',
2538
- "承認は奇数にしてください。")
2539
- # valid!([-1, 1])
2540
- end
2541
-
2542
- def test_validates_numericality_with_even
2543
- Topic.validates_numericality_of :approved, :even => true
2544
-
2545
- invalid!([-1, 1], 'Approved must be even',
2546
- "承認は偶数にしてください。")
2547
- # valid!([-2, 2])
2548
- end
2549
-
2550
- def test_validates_numericality_with_greater_than_less_than_and_even
2551
- Topic.validates_numericality_of :approved, :greater_than => 1, :less_than => 4, :even => true
2552
-
2553
- invalid!([1, 3, 4])
2554
- # valid!([2])
2555
- end
2556
-
2557
- def test_validates_numericality_with_numeric_message
2558
- Topic.validates_numericality_of :approved, :less_than => 4, :message => N_("smaller than %d")
2559
- topic = Topic.new("title" => "numeric test", "approved" => 10)
2560
-
2561
- assert !topic.valid?
2562
- assert_equal "Approved smaller than 4", topic.errors.full_messages[0]
2563
- assert_equal "smaller than 4", topic.errors.on(:approved)
2564
-
2565
- Topic.validates_numericality_of :approved, :greater_than => 4, :message => N_("greater than %d")
2566
- topic = Topic.new("title" => "numeric test", "approved" => 1)
2567
-
2568
- assert !topic.valid?
2569
- assert_equal "Approved greater than 4", topic.errors.full_messages[0]
2570
- assert_equal "greater than 4", topic.errors.on(:approved)
2571
- end
2572
-
2573
- private
2574
- def invalid!(values, error=nil, errorj=nil)
2575
- with_each_topic_approved_value(values) do |topic, value|
2576
- GetText.set_locale_all "ja"
2577
- assert !topic.valid?, "#{value.inspect} not rejected as a number"
2578
- assert topic.errors.on(:approved)
2579
- assert_equal errorj, topic.errors.full_messages[0] if errorj
2580
- assert_equal errorj, topic.errors.on(:approved) if errorj
2581
- end
2582
-
2583
- with_each_topic_approved_value(values) do |topic, value|
2584
- GetText.set_locale_all "en"
2585
- assert !topic.valid?, "#{value.inspect} not rejected as a number"
2586
- assert topic.errors.on(:approved)
2587
- assert_equal error, topic.errors.full_messages[0] if error
2588
- assert_equal error, topic.errors.on(:approved) if error
2589
- end
2590
- end
2591
- =begin
2592
- # Don't need this
2593
- def valid!(values)
2594
- with_each_topic_approved_value(values) do |topic, value|
2595
- assert topic.valid?, "#{value.inspect} not accepted as a number"
2596
- end
2597
- end
2598
- =end
2599
- def with_each_topic_approved_value(values)
2600
- topic = Topic.new("title" => "numeric test", "content" => "whatever")
2601
- values.each do |value|
2602
- topic.approved = value
2603
- yield topic, value
2604
- end
2605
- end
2606
- end