motiro 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. data/LICENSE +280 -0
  2. data/README +28 -0
  3. data/README.en +175 -0
  4. data/README.pt-br +175 -0
  5. data/Rakefile +10 -0
  6. data/app/controllers/account_controller.rb +62 -0
  7. data/app/controllers/application.rb +72 -0
  8. data/app/controllers/edition_controller.rb +13 -0
  9. data/app/controllers/javascript_controller.rb +21 -0
  10. data/app/controllers/report_controller.rb +79 -0
  11. data/app/controllers/root_controller.rb +7 -0
  12. data/app/controllers/wiki_controller.rb +102 -0
  13. data/app/core/cache_reporter.rb +53 -0
  14. data/app/core/cache_reporter_fetcher.rb +33 -0
  15. data/app/core/chief_editor.rb +69 -0
  16. data/app/core/reporter.rb +105 -0
  17. data/app/core/reporter_driver.rb +36 -0
  18. data/app/core/reporter_fetcher.rb +39 -0
  19. data/app/core/settings.rb +43 -0
  20. data/app/core/version.rb +1 -0
  21. data/app/core/wiki_page_not_found.rb +33 -0
  22. data/app/core/wiki_reporter.rb +83 -0
  23. data/app/helpers/account_helper.rb +2 -0
  24. data/app/helpers/application_helper.rb +68 -0
  25. data/app/helpers/default_page_provider.rb +28 -0
  26. data/app/helpers/report_helper.rb +2 -0
  27. data/app/helpers/root_helper.rb +2 -0
  28. data/app/helpers/wiki_helper.rb +3 -0
  29. data/app/models/change.rb +96 -0
  30. data/app/models/diff_table_builder.rb +285 -0
  31. data/app/models/event.rb +18 -0
  32. data/app/models/headline.rb +109 -0
  33. data/app/models/page.rb +114 -0
  34. data/app/models/page_sweeper.rb +26 -0
  35. data/app/models/user.rb +85 -0
  36. data/app/ports/chdir_runner.rb +36 -0
  37. data/app/ports/reporter_loader.rb +9 -0
  38. data/app/ports/runner.rb +64 -0
  39. data/app/reporters/darcs_connection.rb +54 -0
  40. data/app/reporters/darcs_reporter.rb +104 -0
  41. data/app/reporters/darcs_settings.rb +9 -0
  42. data/app/reporters/darcs_temp_repo.rb +40 -0
  43. data/app/reporters/events_reporter.rb +28 -0
  44. data/app/reporters/features_reporter.rb +24 -0
  45. data/app/reporters/subversion_reporter.rb +203 -0
  46. data/app/reporters/svn_connection.rb +62 -0
  47. data/app/reporters/svn_settings.rb +40 -0
  48. data/app/views/account/_authorization.rhtml +54 -0
  49. data/app/views/account/_availability.rhtml +5 -0
  50. data/app/views/account/availability.rhtml +1 -0
  51. data/app/views/account/login.rhtml +22 -0
  52. data/app/views/account/logout.rhtml +10 -0
  53. data/app/views/javascript/motiro.rjs +132 -0
  54. data/app/views/javascript/niftycube.rjs +300 -0
  55. data/app/views/layouts/_bottom.rhtml +5 -0
  56. data/app/views/layouts/_header.rhtml +7 -0
  57. data/app/views/layouts/_top.rhtml +25 -0
  58. data/app/views/layouts/application.rhtml +3 -0
  59. data/app/views/layouts/scaffold.rhtml +13 -0
  60. data/app/views/layouts/wiki_edit.rhtml +26 -0
  61. data/app/views/report/list.rhtml +32 -0
  62. data/app/views/report/older.rhtml +26 -0
  63. data/app/views/report/rss.rxml +29 -0
  64. data/app/views/report/show.rhtml +20 -0
  65. data/app/views/root/index.rhtml +33 -0
  66. data/app/views/wiki/_editbar.rhtml +26 -0
  67. data/app/views/wiki/_properties_edit.rhtml +5 -0
  68. data/app/views/wiki/_properties_show.rhtml +5 -0
  69. data/app/views/wiki/edit.rhtml +56 -0
  70. data/app/views/wiki/properties_edit.rhtml +1 -0
  71. data/app/views/wiki/show.rhtml +9 -0
  72. data/bin/motiro +44 -0
  73. data/config/boot.rb +19 -0
  74. data/config/database.yml +14 -0
  75. data/config/environment.rb +64 -0
  76. data/config/environments/development.rb +20 -0
  77. data/config/environments/production.rb +19 -0
  78. data/config/environments/test.rb +19 -0
  79. data/config/motiro.yml +43 -0
  80. data/config/routes.rb +79 -0
  81. data/db/migrate/005_globalize_migration.rb +11363 -0
  82. data/db/migrate/006_remove_headline_title.rb +14 -0
  83. data/db/migrate/007_stretch_rid.rb +11 -0
  84. data/db/migrate/008_add_page_editors.rb +12 -0
  85. data/db/migrate/009_add_page_original_author.rb +12 -0
  86. data/db/migrate/010_remove_empty_string_defaults_from_pages.rb +17 -0
  87. data/db/migrate/011_add_title_and_kind_to_pages.rb +13 -0
  88. data/db/migrate/012_page_modification_info.rb +13 -0
  89. data/db/migrate/013_nullify_initial_page_attributes.rb +21 -0
  90. data/db/migrate/014_events_are_wiki_pages.rb +13 -0
  91. data/db/migrate/015_migrate_previous_event_data.rb +23 -0
  92. data/db/migrate/1_initial_structure.rb +36 -0
  93. data/db/migrate/2_add_authentication.rb +12 -0
  94. data/db/migrate/3_drop_articles.rb +26 -0
  95. data/db/migrate/4_add_page_editing.rb +14 -0
  96. data/db/motirodb.sqlite.initial +0 -0
  97. data/db/schema_version +1 -0
  98. data/db/translation/pt-BR.rb +76 -0
  99. data/doc/README_FOR_APP +2 -0
  100. data/installer/rails_installer_defaults.yml +5 -0
  101. data/lib/import_translations.rb +154 -0
  102. data/lib/login_system.rb +89 -0
  103. data/lib/relative_time.rb +48 -0
  104. data/lib/string_extensions.rb +10 -0
  105. data/lib/stub_hash.rb +22 -0
  106. data/lib/tasks/packaging.rake +93 -0
  107. data/lib/tasks/testing.rake +32 -0
  108. data/lib/tick_daemon.rb +41 -0
  109. data/lib/translator.rb +67 -0
  110. data/lib/wiki_renderer.rb +42 -0
  111. data/lib/wiki_url_generator.rb +29 -0
  112. data/log/.keepdir +0 -0
  113. data/public/404.html +8 -0
  114. data/public/500.html +8 -0
  115. data/public/dispatch.cgi +10 -0
  116. data/public/dispatch.fcgi +24 -0
  117. data/public/dispatch.rb +10 -0
  118. data/public/favicon.ico +0 -0
  119. data/public/images/calendar.png +0 -0
  120. data/public/images/rss.png +0 -0
  121. data/public/javascripts/controls.js +750 -0
  122. data/public/javascripts/dragdrop.js +584 -0
  123. data/public/javascripts/effects.js +854 -0
  124. data/public/javascripts/prototype.js +1785 -0
  125. data/public/robots.txt +1 -0
  126. data/public/stylesheets/motiro.css +269 -0
  127. data/public/stylesheets/niftyCorners.css +35 -0
  128. data/public/stylesheets/scaffold.css +74 -0
  129. data/script/about +3 -0
  130. data/script/breakpointer +3 -0
  131. data/script/console +3 -0
  132. data/script/destroy +3 -0
  133. data/script/generate +3 -0
  134. data/script/performance/benchmarker +3 -0
  135. data/script/performance/profiler +3 -0
  136. data/script/plugin +3 -0
  137. data/script/process/reaper +3 -0
  138. data/script/process/spawner +3 -0
  139. data/script/process/spinner +3 -0
  140. data/script/runner +3 -0
  141. data/script/server +3 -0
  142. data/script/ticker +29 -0
  143. data/test/acceptance/account_test.rb +186 -0
  144. data/test/acceptance/darcs_test.rb +62 -0
  145. data/test/acceptance/events_test.rb +47 -0
  146. data/test/acceptance/main_page_test.rb +92 -0
  147. data/test/acceptance/subversion_test.rb +319 -0
  148. data/test/acceptance/ts_all_suites.rb +27 -0
  149. data/test/acceptance/wiki_test.rb +202 -0
  150. data/test/contract/darcs_test.rb +51 -0
  151. data/test/contract/remote_darcs_test.rb +61 -0
  152. data/test/contract/svn_test.rb +53 -0
  153. data/test/fixtures/changes.yml +25 -0
  154. data/test/fixtures/headlines.yml +45 -0
  155. data/test/fixtures/pages.yml +98 -0
  156. data/test/fixtures/users.yml +31 -0
  157. data/test/functional/account_controller_test.rb +96 -0
  158. data/test/functional/report_controller_test.rb +113 -0
  159. data/test/functional/report_features_test.rb +38 -0
  160. data/test/functional/report_subversion_test.rb +79 -0
  161. data/test/functional/root_controller_test.rb +127 -0
  162. data/test/functional/wiki_controller_test.rb +280 -0
  163. data/test/lib/acceptance_test_case.rb +43 -0
  164. data/test/lib/configuration.rb +53 -0
  165. data/test/lib/darcs_excerpts.rb +181 -0
  166. data/test/lib/darcs_repo.rb +77 -0
  167. data/test/lib/live_mode_test.rb +51 -0
  168. data/test/lib/local_svn.rb +157 -0
  169. data/test/lib/netutils.rb +42 -0
  170. data/test/lib/platform_thread.rb +62 -0
  171. data/test/lib/repoutils.rb +23 -0
  172. data/test/lib/selenium_extensions.rb +32 -0
  173. data/test/lib/stubio.rb +37 -0
  174. data/test/lib/svn_excerpts.rb +288 -0
  175. data/test/lib/test_configuration.rb +14 -0
  176. data/test/lib/webserver.rb +71 -0
  177. data/test/meta/configuration_test.rb +72 -0
  178. data/test/meta/darcs_repo_test.rb +118 -0
  179. data/test/meta/local_svn_test.rb +125 -0
  180. data/test/meta/platform_thread_test.rb +46 -0
  181. data/test/meta/stubio_test.rb +44 -0
  182. data/test/mocks/headline.rb +34 -0
  183. data/test/mocks/svn_reporter.rb +29 -0
  184. data/test/stubs/svn_settings.rb +19 -0
  185. data/test/stubs/url_generator.rb +24 -0
  186. data/test/test_helper.rb +36 -0
  187. data/test/unit/cache_reporter_fetcher_test.rb +46 -0
  188. data/test/unit/cache_reporter_test.rb +97 -0
  189. data/test/unit/caching_test.rb +78 -0
  190. data/test/unit/change_test.rb +152 -0
  191. data/test/unit/chdir_runner_test.rb +77 -0
  192. data/test/unit/chief_editor_test.rb +234 -0
  193. data/test/unit/darcs_connection_test.rb +109 -0
  194. data/test/unit/darcs_reporter_test.rb +146 -0
  195. data/test/unit/darcs_settings_test.rb +37 -0
  196. data/test/unit/darcs_temp_repo_test.rb +51 -0
  197. data/test/unit/default_page_provider_test.rb +46 -0
  198. data/test/unit/diff_table_builder_test.rb +602 -0
  199. data/test/unit/headline_test.rb +259 -0
  200. data/test/unit/page_test.rb +145 -0
  201. data/test/unit/relative_time_test.rb +56 -0
  202. data/test/unit/reporter_driver_test.rb +85 -0
  203. data/test/unit/reporter_fetcher_test.rb +31 -0
  204. data/test/unit/reporter_test.rb +81 -0
  205. data/test/unit/runner_test.rb +93 -0
  206. data/test/unit/settings_test.rb +55 -0
  207. data/test/unit/string_extensions_test.rb +10 -0
  208. data/test/unit/svn_connection_test.rb +183 -0
  209. data/test/unit/svn_reporter_interaction_test.rb +38 -0
  210. data/test/unit/svn_reporter_test.rb +286 -0
  211. data/test/unit/svn_settings_test.rb +86 -0
  212. data/test/unit/translator_test.rb +96 -0
  213. data/test/unit/user_test.rb +125 -0
  214. data/test/unit/wiki_renderer_test.rb +87 -0
  215. data/test/unit/wiki_reporter_test.rb +94 -0
  216. data/test/unit/wiki_url_generator_test.rb +31 -0
  217. data/vendor/motiro-installer.rb +159 -0
  218. data/vendor/plugins/globalize/LICENSE +9 -0
  219. data/vendor/plugins/globalize/README +49 -0
  220. data/vendor/plugins/globalize/data/country_data.csv +240 -0
  221. data/vendor/plugins/globalize/data/language_data.csv +188 -0
  222. data/vendor/plugins/globalize/data/translation_data.csv +3421 -0
  223. data/vendor/plugins/globalize/generators/globalize/USAGE +10 -0
  224. data/vendor/plugins/globalize/generators/globalize/globalize_generator.rb +42 -0
  225. data/vendor/plugins/globalize/generators/globalize/templates/migration.rb.gz +0 -0
  226. data/vendor/plugins/globalize/generators/globalize/templates/tiny_migration.rb.gz +0 -0
  227. data/vendor/plugins/globalize/init.rb +30 -0
  228. data/vendor/plugins/globalize/lib/globalize/localization/core_ext.rb +170 -0
  229. data/vendor/plugins/globalize/lib/globalize/localization/core_ext_hooks.rb +33 -0
  230. data/vendor/plugins/globalize/lib/globalize/localization/db_translate.rb +494 -0
  231. data/vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb +152 -0
  232. data/vendor/plugins/globalize/lib/globalize/localization/locale.rb +173 -0
  233. data/vendor/plugins/globalize/lib/globalize/localization/rfc_3066.rb +40 -0
  234. data/vendor/plugins/globalize/lib/globalize/models/country.rb +24 -0
  235. data/vendor/plugins/globalize/lib/globalize/models/currency.rb +188 -0
  236. data/vendor/plugins/globalize/lib/globalize/models/language.rb +84 -0
  237. data/vendor/plugins/globalize/lib/globalize/models/model_translation.rb +4 -0
  238. data/vendor/plugins/globalize/lib/globalize/models/translation.rb +9 -0
  239. data/vendor/plugins/globalize/lib/globalize/models/view_translation.rb +14 -0
  240. data/vendor/plugins/globalize/lib/globalize/rails/action_mailer.rb +125 -0
  241. data/vendor/plugins/globalize/lib/globalize/rails/action_view.rb +79 -0
  242. data/vendor/plugins/globalize/lib/globalize/rails/active_record.rb +129 -0
  243. data/vendor/plugins/globalize/lib/globalize/rails/active_record_helper.rb +33 -0
  244. data/vendor/plugins/globalize/populators/pop_dates.rb +81 -0
  245. data/vendor/plugins/globalize/populators/pop_migration.rb +18 -0
  246. data/vendor/plugins/globalize/populators/pop_pluralization.rb +26 -0
  247. data/vendor/plugins/globalize/populators/pop_seps.rb +32 -0
  248. data/vendor/plugins/globalize/tasks/data.rake +130 -0
  249. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en-US.plain.text.rhtml +1 -0
  250. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en.plain.text.rhtml +1 -0
  251. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.he.plain.text.rhtml +1 -0
  252. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.plain.text.rhtml +1 -0
  253. data/vendor/plugins/globalize/test/action_mailer_test.rb +54 -0
  254. data/vendor/plugins/globalize/test/config/database.yml.default +16 -0
  255. data/vendor/plugins/globalize/test/config/database.yml.example +22 -0
  256. data/vendor/plugins/globalize/test/core_ext_test.rb +61 -0
  257. data/vendor/plugins/globalize/test/currency_test.rb +141 -0
  258. data/vendor/plugins/globalize/test/date_helper_test.rb +634 -0
  259. data/vendor/plugins/globalize/test/db/schema.rb +90 -0
  260. data/vendor/plugins/globalize/test/db_translation_test.rb +374 -0
  261. data/vendor/plugins/globalize/test/fixtures/globalize_categories.yml +7 -0
  262. data/vendor/plugins/globalize/test/fixtures/globalize_categories_products.yml +7 -0
  263. data/vendor/plugins/globalize/test/fixtures/globalize_countries.yml +41 -0
  264. data/vendor/plugins/globalize/test/fixtures/globalize_languages.yml +64 -0
  265. data/vendor/plugins/globalize/test/fixtures/globalize_manufacturers.yml +5 -0
  266. data/vendor/plugins/globalize/test/fixtures/globalize_products.yml +29 -0
  267. data/vendor/plugins/globalize/test/fixtures/globalize_simples.yml +5 -0
  268. data/vendor/plugins/globalize/test/fixtures/globalize_translations.yml +354 -0
  269. data/vendor/plugins/globalize/test/locale_test.rb +27 -0
  270. data/vendor/plugins/globalize/test/mime_responds_test.rb +358 -0
  271. data/vendor/plugins/globalize/test/model_test.rb +17 -0
  272. data/vendor/plugins/globalize/test/standard_data_test_helper.rb +33 -0
  273. data/vendor/plugins/globalize/test/test_helper.rb +19 -0
  274. data/vendor/plugins/globalize/test/test_standard_data.rb +54 -0
  275. data/vendor/plugins/globalize/test/validation_test.rb +29 -0
  276. data/vendor/plugins/globalize/test/view_picking_test.rb +49 -0
  277. data/vendor/plugins/globalize/test/view_translation_test.rb +237 -0
  278. data/vendor/plugins/globalize/test/views/layouts/standard.rhtml +1 -0
  279. data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rhtml +1 -0
  280. data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rjs +1 -0
  281. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rhtml +1 -0
  282. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rjs +1 -0
  283. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rxml +1 -0
  284. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rhtml +1 -0
  285. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rjs +1 -0
  286. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rxml +1 -0
  287. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rhtml +1 -0
  288. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rjs +1 -0
  289. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rxml +1 -0
  290. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rhtml +1 -0
  291. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rjs +1 -0
  292. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rxml +1 -0
  293. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rhtml +1 -0
  294. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rjs +1 -0
  295. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rxml +1 -0
  296. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rhtml +1 -0
  297. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rjs +1 -0
  298. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rxml +1 -0
  299. data/vendor/plugins/globalize/test/views/test.he-IL.rhtml +1 -0
  300. data/vendor/plugins/globalize/test/views/test.rhtml +1 -0
  301. data/vendor/plugins/globalize/test/views/test2.he.rhtml +1 -0
  302. data/vendor/plugins/globalize/test/views/test2.rhtml +1 -0
  303. data/vendor/plugins/test_xml/MIT-LICENSE +20 -0
  304. data/vendor/plugins/test_xml/README +20 -0
  305. data/vendor/plugins/test_xml/Rakefile +22 -0
  306. data/vendor/plugins/test_xml/init.rb +7 -0
  307. data/vendor/plugins/test_xml/lib/xml_assertions.rb +22 -0
  308. data/vendor/plugins/test_xml/test/test_xml_test.rb +40 -0
  309. metadata +505 -0
@@ -0,0 +1,90 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ create_table :globalize_simples, :force => true do |t|
4
+ t.column :name, :string
5
+ t.column :description, :string
6
+ end
7
+
8
+ create_table :globalize_products, :force => true do |t|
9
+ t.column :code, :string
10
+ t.column :manufacturer_id, :integer
11
+ t.column :name, :string
12
+ t.column :description, :string
13
+ t.column :specs, :string
14
+ end
15
+
16
+ add_index :globalize_products, :code, :unique
17
+ add_index :globalize_products, :manufacturer_id
18
+
19
+ create_table :globalize_manufacturers, :force => true do |t|
20
+ t.column :code, :string
21
+ t.column :name, :string
22
+ end
23
+
24
+ add_index :globalize_manufacturers, :code, :unique
25
+
26
+ create_table :globalize_categories, :force => true do |t|
27
+ t.column :code, :string
28
+ t.column :name, :string
29
+ end
30
+
31
+ add_index :globalize_categories, :code, :unique
32
+
33
+ create_table :globalize_categories_products, :id => false, :force => true do |t|
34
+ t.column :category_id, :integer
35
+ t.column :product_id, :integer
36
+ end
37
+
38
+ add_index :globalize_categories_products, :category_id
39
+ add_index :globalize_categories_products, :product_id
40
+
41
+ create_table :globalize_countries, :force => true do |t|
42
+ t.column :code, :string, :limit => 2
43
+ t.column :english_name, :string
44
+ t.column :date_format, :string
45
+ t.column :currency_format, :string
46
+ t.column :currency_code, :string, :limit => 3
47
+ t.column :thousands_sep, :string, :limit => 1
48
+ t.column :decimal_sep, :string, :limit => 1
49
+ t.column :currency_decimal_sep, :string, :limit => 1
50
+ t.column :number_grouping_scheme, :string
51
+ end
52
+ add_index :globalize_countries, :code
53
+
54
+ create_table :globalize_translations, :force => true do |t|
55
+ t.column :type, :string
56
+ t.column :tr_key, :string
57
+ t.column :table_name, :string
58
+ t.column :item_id, :integer
59
+ t.column :facet, :string
60
+ t.column :language_id, :integer
61
+ t.column :pluralization_index, :integer
62
+ t.column :text, :text
63
+ end
64
+
65
+ add_index :globalize_translations, [ :tr_key, :language_id ], :name => 'tr_key'
66
+ add_index :globalize_translations, [ :table_name, :item_id, :language_id ], :name => 'table_name'
67
+
68
+ create_table :globalize_languages, :force => true do |t|
69
+ t.column :iso_639_1, :string, :limit => 2
70
+ t.column :iso_639_2, :string, :limit => 3
71
+ t.column :iso_639_3, :string, :limit => 3
72
+ t.column :rfc_3066, :string
73
+ t.column :english_name, :string
74
+ t.column :english_name_locale, :string
75
+ t.column :english_name_modifier, :string
76
+ t.column :native_name, :string
77
+ t.column :native_name_locale, :string
78
+ t.column :native_name_modifier, :string
79
+ t.column :macro_language, :boolean
80
+ t.column :direction, :string
81
+ t.column :pluralization, :string
82
+ t.column :scope, :string, :limit => 1
83
+ end
84
+
85
+ add_index :globalize_languages, :iso_639_1
86
+ add_index :globalize_languages, :iso_639_2
87
+ add_index :globalize_languages, :iso_639_3
88
+ add_index :globalize_languages, :rfc_3066
89
+
90
+ end
@@ -0,0 +1,374 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class TranslationTest < Test::Unit::TestCase
4
+ self.use_instantiated_fixtures = true
5
+ fixtures :globalize_languages, :globalize_translations, :globalize_countries,
6
+ :globalize_products, :globalize_manufacturers, :globalize_categories,
7
+ :globalize_categories_products, :globalize_simples
8
+
9
+ class Product < ActiveRecord::Base
10
+ set_table_name "globalize_products"
11
+
12
+ has_and_belongs_to_many :categories, :join_table => "globalize_categories_products"
13
+ belongs_to :manufacturer, :foreign_key => 'manufacturer_id'
14
+
15
+ translates :name, :description, :specs, {
16
+ :name => { :bidi_embed => false }, :specs => { :bidi_embed => false } }
17
+ end
18
+
19
+ class Category < ActiveRecord::Base
20
+ set_table_name "globalize_categories"
21
+ has_and_belongs_to_many :products, :join_table => "globalize_categories_products"
22
+
23
+ translates :name
24
+ end
25
+
26
+ class Manufacturer < ActiveRecord::Base
27
+ set_table_name "globalize_manufacturers"
28
+ has_many :products
29
+
30
+ translates :name
31
+ end
32
+
33
+ class Simple < ActiveRecord::Base
34
+ set_table_name "globalize_simples"
35
+
36
+ translates :name, :description
37
+ end
38
+
39
+ def setup
40
+ Globalize::Locale.set_base_language("en-US")
41
+ Globalize::Locale.set("en-US")
42
+ end
43
+
44
+ def test_simple
45
+ simp = Simple.find(1)
46
+ assert_equal "first", simp.name
47
+ assert_equal "This is a description of the first simple", simp.description
48
+
49
+ Globalize::Locale.set 'he-IL'
50
+ simp = Simple.find(1)
51
+ assert_equal "זהו השם הראשון", simp.name
52
+ assert_equal "זהו התיאור הראשון", simp.description
53
+ end
54
+
55
+ def test_simple_save
56
+ simp = Simple.find(1)
57
+ simp.name = '1st'
58
+ simp.save!
59
+
60
+ Globalize::Locale.set 'he-IL'
61
+ simp = Simple.find(1)
62
+ simp.name = 'ה-1'
63
+ simp.save!
64
+ end
65
+
66
+ def test_simple_create
67
+ simp = Simple.new
68
+ simp.name = '1st'
69
+ simp.save!
70
+
71
+ Globalize::Locale.set 'he-IL'
72
+ simp = Simple.new
73
+ simp.name = 'ה-1'
74
+ simp.save!
75
+ end
76
+
77
+ def test_native_language
78
+ heb = Globalize::Language.pick("he")
79
+ assert_equal "עברית", heb.native_name
80
+ end
81
+
82
+ def test_nil
83
+ Globalize::Locale.set(nil)
84
+ prod = Product.find(1)
85
+ assert_equal "first-product", prod.code
86
+ assert_equal "these are the specs for the first product",
87
+ prod.specs
88
+ end
89
+
90
+ def test_nil_include_translated
91
+ Globalize::Locale.set(nil)
92
+
93
+ prods = Product.find(:all, :order => "globalize_products.code", :include_translated => :manufacturer)
94
+ assert_equal "first-product", prods[1].code
95
+ assert_equal "these are the specs for the first product",
96
+ prods[1].specs
97
+ assert_equal "first", prods[1].name
98
+ assert_equal "Reverend", prods.first.manufacturer_name
99
+ assert_equal "Reverend", prods.last.manufacturer_name
100
+ end
101
+
102
+ def test_prod_tr_all
103
+ prods = Product.find(:all, :order => "code" )
104
+ assert_equal 5, prods.length
105
+ assert_equal "first-product", prods[1].code
106
+ assert_equal "second-product", prods[3].code
107
+ assert_equal "these are the specs for the first product",
108
+ prods[1].specs
109
+ assert_equal "This is a description of the first product",
110
+ prods[1].description
111
+ assert_equal "these are the specs for the second product",
112
+ prods[3].specs
113
+ end
114
+
115
+ def test_prod_tr_first
116
+ prod = Product.find(1)
117
+ assert_equal "first-product", prod.code
118
+ assert_equal "these are the specs for the first product",
119
+ prod.specs
120
+ assert_equal "This is a description of the first product",
121
+ prod.description
122
+ end
123
+
124
+ def test_prod_tr_id
125
+ prod = Product.find(1)
126
+ assert_equal "first-product", prod.code
127
+ assert_equal "these are the specs for the first product",
128
+ prod.specs
129
+ assert_equal "This is a description of the first product",
130
+ prod.description
131
+ end
132
+
133
+ # Ordering of records returned is database-dependent although MySQL is explicit about ordering
134
+ # its result sets. This means this test is only guaranteed to pass on MySQL.
135
+ def pending_test_prod_tr_ids
136
+ prods = Product.find(1, 2)
137
+ assert_equal 2, prods.length
138
+ assert_equal "first-product", prods[0].code
139
+ assert_equal "second-product", prods[1].code
140
+ assert_equal "these are the specs for the first product",
141
+ prods[0].specs
142
+ assert_equal "This is a description of the first product",
143
+ prods[0].description
144
+ assert_equal "these are the specs for the second product",
145
+ prods[1].specs
146
+ end
147
+
148
+ def test_base
149
+ Globalize::Locale.set("he-IL")
150
+ prod = Product.find(1)
151
+ assert_equal "first-product", prod.code
152
+ assert_equal "these are the specs for the first product",
153
+ prod.specs
154
+ assert_equal "זהו תיאור המוצר הראשון",
155
+ prod.description
156
+ end
157
+
158
+ def test_habtm_translation
159
+ Globalize::Locale.set("he-IL")
160
+ cat = Category.find(1)
161
+ prods = cat.products
162
+ assert_equal 1, prods.length
163
+ prod = prods.first
164
+ assert_equal "first-product", prod.code
165
+ assert_equal "these are the specs for the first product",
166
+ prod.specs
167
+ assert_equal "זהו תיאור המוצר הראשון",
168
+ prod.description
169
+ end
170
+
171
+ # test has_many translation
172
+ def test_has_many_translation
173
+ Globalize::Locale.set("he-IL")
174
+ mfr = Manufacturer.find(1)
175
+ assert_equal 5, mfr.products.length
176
+ prod = mfr.products.find(1)
177
+ assert_equal "first-product", prod.code
178
+ assert_equal "these are the specs for the first product",
179
+ prod.specs
180
+ assert_equal "זהו תיאור המוצר הראשון",
181
+ prod.description
182
+ end
183
+
184
+ def test_belongs_to_translation
185
+ Globalize::Locale.set("he-IL")
186
+ prod = Product.find(1)
187
+ mfr = prod.manufacturer
188
+ assert_equal "first-mfr", mfr.code
189
+ assert_equal "רברנד",
190
+ mfr.name
191
+ end
192
+
193
+ def test_new
194
+ prod = Product.new(:code => "new-product", :specs => "These are the product specs")
195
+ assert_equal "These are the product specs", prod.specs
196
+ assert_nil prod.description
197
+ end
198
+
199
+ # test creating updating
200
+ def test_create_update
201
+ prod = Product.create(:code => "new-product",
202
+ :specs => "These are the product specs")
203
+ assert prod.errors.empty?, prod.errors.full_messages.first
204
+ prod = nil
205
+ prod = Product.find_by_code("new-product")
206
+ assert_not_nil prod
207
+ assert_equal "These are the product specs", prod.specs
208
+
209
+ prod.specs = "Dummy"
210
+ prod.save
211
+ prod = nil
212
+ prod = Product.find_by_code("new-product")
213
+ assert_not_nil prod
214
+ assert_equal "Dummy", prod.specs
215
+ end
216
+
217
+ def test_include_translated
218
+ Globalize::Locale.set("he-IL")
219
+ prods = Product.find(:all, :include_translated => :manufacturer)
220
+ assert_equal 5, prods.size
221
+ assert_equal "רברנד", prods.first.manufacturer_name
222
+ assert_equal "רברנד", prods.last.manufacturer_name
223
+
224
+ Globalize::Locale.set("en-US")
225
+ prods = Product.find(:all, :include_translated => :manufacturer)
226
+ assert_equal 5, prods.size
227
+ assert_equal "Reverend", prods.first.manufacturer_name
228
+ assert_equal "Reverend", prods.last.manufacturer_name
229
+ end
230
+
231
+ # Doesn't pull in translations
232
+ def test_include
233
+ prods = Product.find(:all, :include => :manufacturer)
234
+ assert_equal 5, prods.size
235
+ assert_equal "first-mfr", prods.first.manufacturer.code
236
+ end
237
+
238
+ def test_order_en
239
+ prods = Product.find(:all, :order => "name").select {|rec| rec.name}
240
+ assert_equal 5, prods[0].id
241
+ assert_equal 3, prods[1].id
242
+ assert_equal 4, prods[2].id
243
+ end
244
+
245
+ def test_order_he
246
+ Globalize::Locale.set("he-IL")
247
+ prods = Product.find(:all, :order => "name").select {|rec| rec.name}
248
+ assert_equal 4, prods[1].id
249
+ assert_equal 5, prods[2].id
250
+ assert_equal 3, prods[3].id
251
+ end
252
+
253
+ def test_base_translation_create
254
+ prod = Product.create!(:code => 'test-base', :name => 'english test')
255
+ prod.reload
256
+ assert_equal 'english test', prod.name
257
+ Globalize::Locale.set("he-IL")
258
+ prod = Product.find_by_code('test-base')
259
+ assert_equal 'english test', prod.name
260
+ prod.name = "hebrew test"
261
+ prod.save!
262
+ prod.reload
263
+ assert_equal 'hebrew test', prod.name
264
+
265
+ # delete hebrew version and test if it reverts to english base
266
+ prod.name = nil
267
+ assert_nil prod.name
268
+ prod.save!
269
+ prod.reload
270
+ assert_equal 'english test', prod.name
271
+
272
+ # change base and see if hebrew gets updated
273
+ Globalize::Locale.set("en-US")
274
+ prod.reload
275
+ prod.name = "english test two"
276
+ prod.save!
277
+ prod.reload
278
+ assert_equal "english test two", prod.name
279
+ Globalize::Locale.set("he-IL")
280
+ prod.reload
281
+ assert_equal "english test two", prod.name
282
+ end
283
+
284
+ def test_wrong_language
285
+ prod = Product.find(1)
286
+
287
+ Globalize::Locale.set("he-IL")
288
+ assert_raise(Globalize::WrongLanguageError) { prod.description }
289
+ assert_raise(Globalize::WrongLanguageError) { prod.description = "זהו תיאור המוצר השני" }
290
+ assert_raise(Globalize::WrongLanguageError) { prod.save! }
291
+ prod = Product.find(1)
292
+ assert_equal "זהו תיאור המוצר הראשון", prod.description
293
+
294
+ Globalize::Locale.set("en-US")
295
+ assert_raise(Globalize::WrongLanguageError) { prod.description }
296
+ assert_raise(Globalize::WrongLanguageError) { prod.save! }
297
+ end
298
+
299
+ def test_destroy
300
+ prod = Product.find(1)
301
+ tr = Globalize::ModelTranslation.find(:first, :conditions => [
302
+ "table_name = ? AND item_id = ? AND facet = ? AND language_id = ?",
303
+ "globalize_products", 1, "description", 2 ])
304
+ assert_not_nil tr
305
+ prod.destroy
306
+ tr = Globalize::ModelTranslation.find(:first, :conditions => [
307
+ "table_name = ? AND item_id = ? AND facet = ? AND language_id = ?",
308
+ "globalize_products", 1, "description", 2 ])
309
+ assert_nil tr
310
+ end
311
+
312
+ def test_destroy_class_method
313
+ tr = Globalize::ModelTranslation.find(:first, :conditions => [
314
+ "table_name = ? AND item_id = ? AND facet = ? AND language_id = ?",
315
+ "globalize_products", 1, "description", 2 ])
316
+ assert_not_nil tr
317
+ Product.destroy(1)
318
+ tr = Globalize::ModelTranslation.find(:first, :conditions => [
319
+ "table_name = ? AND item_id = ? AND facet = ? AND language_id = ?",
320
+ "globalize_products", 1, "description", 2 ])
321
+ assert_nil tr
322
+ end
323
+
324
+ def test_fix_conditions
325
+ assert_equal 'globalize_products.name="test"',
326
+ Product.class_eval { fix_conditions('name="test"') }
327
+ assert_equal '(globalize_products.name="test" OR globalize_products.name = "test2")',
328
+ Product.class_eval { fix_conditions('(name="test" OR name = "test2")') }
329
+ assert_equal 'globalize_products.name = globalize_translations.name',
330
+ Product.class_eval { fix_conditions('globalize_products.name = globalize_translations.name') }
331
+ assert_equal ' globalize_products.name = globalize_translations.name',
332
+ Product.class_eval { fix_conditions(' name = globalize_translations.name') }
333
+ assert_equal ' globalize_products."name" = globalize_translations.name',
334
+ Product.class_eval { fix_conditions(' "name" = globalize_translations.name') }
335
+ assert_equal ' globalize_products.\'name\' = globalize_translations.name',
336
+ Product.class_eval { fix_conditions(' \'name\' = globalize_translations.name') }
337
+ assert_equal ' globalize_products.`name` = globalize_translations.name',
338
+ Product.class_eval { fix_conditions(' `name` = globalize_translations.name') }
339
+ end
340
+
341
+ def test_native_name
342
+ heb = Globalize::Language.pick('he')
343
+ assert_equal 'Hebrew', heb.english_name
344
+ assert_equal 'עברית', heb.native_name
345
+ urdu = Globalize::Language.pick('ur')
346
+ assert_equal 'Urdu', urdu.english_name
347
+ assert_equal 'Urdu', urdu.native_name
348
+ end
349
+
350
+ def test_returned_base
351
+ Globalize::Locale.set("he-IL")
352
+ prod = Product.find(1)
353
+ assert_equal "first-product", prod.code
354
+ assert_equal "these are the specs for the first product",
355
+ prod.specs
356
+ assert_equal "זהו תיאור המוצר הראשון",
357
+ prod.description
358
+
359
+ assert prod.specs_is_base?
360
+ assert !prod.description_is_base?
361
+
362
+ assert_equal 'ltr', prod.specs.direction
363
+ assert_equal 'rtl', prod.description.direction
364
+ end
365
+
366
+ def test_bidi_embed
367
+ Globalize::Locale.set("he-IL")
368
+ prod = Product.find(2)
369
+ assert_equal "\xe2\x80\xaaThis is a description of the second product\xe2\x80\xac",
370
+ prod.description
371
+ end
372
+
373
+ # association building/creating?
374
+ end
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+ first_category:
3
+ id: 1
4
+ code: cat1
5
+ another_category:
6
+ id: 2
7
+ code: cat2
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+ first_mapping:
3
+ category_id: 1
4
+ product_id: 1
5
+ second_mapping:
6
+ category_id: 2
7
+ product_id: 2
@@ -0,0 +1,41 @@
1
+ usa:
2
+ id: 1
3
+ code: US
4
+ english_name: United States
5
+ date_format: '%m-%d-%y'
6
+ currency_format: '$%n'
7
+ thousands_sep: ','
8
+ decimal_sep: '.'
9
+ currency_code: USD
10
+ israel:
11
+ id: 2
12
+ code: IL
13
+ english_name: Israel
14
+ date_format: '%d.%m.%Y'
15
+ currency_format: '%n ₪'
16
+ thousands_sep: ','
17
+ decimal_sep: '.'
18
+ currency_code: ILS
19
+ germany:
20
+ id: 3
21
+ code: DE
22
+ english_name: Germany
23
+ date_format: '%d-%m-%Y'
24
+ thousands_sep: '.'
25
+ decimal_sep: ','
26
+ india:
27
+ id: 4
28
+ code: IN
29
+ english_name: India
30
+ thousands_sep: ','
31
+ decimal_sep: '.'
32
+ number_grouping_scheme: indian
33
+ switzerland:
34
+ id: 5
35
+ code: CH
36
+ english_name: Switzerland
37
+ currency_format: 'SFr. %n'
38
+ currency_code: CHF
39
+ thousands_sep: "'"
40
+ decimal_sep: ','
41
+ currency_decimal_sep: '.'
@@ -0,0 +1,64 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+ english:
3
+ id: 1
4
+ iso_639_1: en
5
+ iso_639_2: eng
6
+ english_name: English
7
+ native_name: English
8
+ direction: ltr
9
+ scope: L
10
+ macro_language: false
11
+ pluralization: 'c == 1 ? 1 : 2'
12
+
13
+ hebrew:
14
+ id: 2
15
+ iso_639_1: he
16
+ iso_639_2: heb
17
+ english_name: Hebrew
18
+ native_name: עברית
19
+ direction: rtl
20
+ scope: L
21
+ macro_language: false
22
+ pluralization: 'c == 1 ? 1 : 2'
23
+
24
+ urdu:
25
+ id: 3
26
+ iso_639_1: ur
27
+ english_name: Urdu
28
+ scope: L
29
+ macro_language: false
30
+
31
+ # intentional bad syntax
32
+ pluralization: 'c==1 ? 1'
33
+ polish:
34
+ id: 4
35
+ iso_639_1: pl
36
+ english_name: Polish
37
+ scope: L
38
+ macro_language: false
39
+ pluralization: 'c==1 ? 1 : c%10>=2 && c%10<=4 && (c%100<10 || c%100>=20) ? 2 : 3'
40
+
41
+ bashkir:
42
+ id: 5
43
+ iso_639_1: ba
44
+ english_name: Bashkir
45
+ scope: L
46
+ macro_language: false
47
+
48
+ # intentional bad syntax
49
+ pluralization: 'bogus syntax'
50
+
51
+ twi:
52
+ id: 6
53
+ iso_639_1: tw
54
+ english_name: Twi
55
+ scope: L
56
+ macro_language: false
57
+
58
+ # intentional bad syntax (too long)
59
+ pluralization: |
60
+ c = c = c = c = c = c = c = c = c = c = c = c = c = c = c = c =
61
+ c = c = c = c = c = c = c = c = c = c = c = c = c = c = c = c =
62
+ c = c = c = c = c = c = c = c = c = c = c = c = c = c = c = c =
63
+ c = c = c = c = c = c = c = c = c = c = c = c = c = c = 1
64
+
@@ -0,0 +1,5 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+ first_manufacturer:
3
+ id: 1
4
+ code: first-mfr
5
+ name: Reverend
@@ -0,0 +1,29 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+ first_product:
3
+ id: 1
4
+ code: first-product
5
+ name: first
6
+ manufacturer_id: 1
7
+ description: This is a description of the first product
8
+ specs: these are the specs for the first product
9
+ second_product:
10
+ id: 2
11
+ code: second-product
12
+ manufacturer_id: 1
13
+ description: This is a description of the second product
14
+ specs: these are the specs for the second product
15
+ third:
16
+ id: 3
17
+ code: third-product
18
+ manufacturer_id: 1
19
+ name: efe
20
+ fourth:
21
+ id: 4
22
+ code: fourth-product
23
+ manufacturer_id: 1
24
+ name: eff
25
+ fifth:
26
+ id: 5
27
+ code: fifth-product
28
+ manufacturer_id: 1
29
+ name: ear
@@ -0,0 +1,5 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+ first_simple:
3
+ id: 1
4
+ name: first
5
+ description: This is a description of the first simple