zena 1.0.0.beta3 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (418) hide show
  1. data/History.txt +29 -0
  2. data/Rakefile +2 -0
  3. data/TODO_ZENA_1_0 +13 -23
  4. data/app/controllers/columns_controller.rb +1 -1
  5. data/app/controllers/comments_controller.rb +4 -3
  6. data/app/controllers/documents_controller.rb +8 -11
  7. data/app/controllers/nodes_controller.rb +39 -21
  8. data/app/controllers/users_controller.rb +8 -3
  9. data/app/controllers/versions_controller.rb +2 -2
  10. data/app/controllers/virtual_classes_controller.rb +17 -11
  11. data/app/helpers/documents_helper.rb +0 -3
  12. data/app/helpers/users_helper.rb +17 -0
  13. data/app/models/cache.rb +36 -31
  14. data/app/models/column.rb +48 -5
  15. data/app/models/comment.rb +14 -5
  16. data/app/models/data_entry.rb +2 -2
  17. data/app/models/document.rb +23 -33
  18. data/app/models/idx_nodes_datetime.rb +4 -0
  19. data/app/models/idx_nodes_float.rb +4 -0
  20. data/app/models/idx_project.rb +3 -0
  21. data/app/models/node.rb +372 -308
  22. data/app/models/page.rb +1 -31
  23. data/app/models/relation.rb +4 -4
  24. data/app/models/relation_proxy.rb +128 -17
  25. data/app/models/role.rb +27 -2
  26. data/app/models/site.rb +64 -56
  27. data/app/models/template.rb +11 -12
  28. data/app/models/text_document.rb +6 -7
  29. data/app/models/user.rb +95 -46
  30. data/app/models/version.rb +2 -2
  31. data/app/models/virtual_class.rb +418 -73
  32. data/app/views/columns/_form.html.erb +1 -1
  33. data/app/views/columns/_li.html.erb +1 -1
  34. data/app/views/comments/_form.rhtml +1 -1
  35. data/app/views/comments/_li.rhtml +1 -1
  36. data/app/views/comments/_li_simple.rhtml +1 -1
  37. data/app/views/groups/_form.rhtml +1 -1
  38. data/app/views/links/_li.rhtml +1 -1
  39. data/app/views/nodes/_groups.rhtml +1 -1
  40. data/app/views/nodes/_import_results.rhtml +1 -1
  41. data/app/views/nodes/_parent.rhtml +1 -1
  42. data/app/views/nodes/_results.rhtml +1 -1
  43. data/app/views/nodes/create.rjs +4 -2
  44. data/app/views/relations/_li.erb +2 -2
  45. data/app/views/templates/document_create_tabs/_file.rhtml +1 -1
  46. data/app/views/templates/document_create_tabs/_template.rhtml +2 -2
  47. data/app/views/templates/document_create_tabs/_text_document.rhtml +2 -2
  48. data/app/views/templates/edit_tabs/_help.rhtml +1 -1
  49. data/app/views/templates/edit_tabs/_title.rhtml +0 -3
  50. data/app/views/users/_form.rhtml +2 -6
  51. data/app/views/users/_li.rhtml +1 -3
  52. data/app/views/users/create.rjs +4 -4
  53. data/app/views/users/preferences.html.erb +1 -4
  54. data/app/views/versions/custom_tab.rhtml +5 -0
  55. data/app/views/virtual_classes/_form.erb +20 -10
  56. data/app/views/virtual_classes/_li.erb +21 -8
  57. data/app/views/zafu/default/Node-+search.zafu +1 -1
  58. data/app/views/zafu/default/Node.zafu +3 -3
  59. data/bricks/captcha/lib/bricks/captcha.rb +1 -1
  60. data/bricks/mongrel/zena/deploy.rb +14 -0
  61. data/bricks/{data2pdf → pdf}/.document +0 -0
  62. data/bricks/pdf/README +33 -0
  63. data/bricks/{data2pdf → pdf}/Rakefile +0 -0
  64. data/bricks/pdf/VERSION +1 -0
  65. data/bricks/pdf/lib/bricks/pdf.rb +110 -0
  66. data/bricks/pdf/lib/bricks/pdf/engine/prince.rb +38 -0
  67. data/bricks/pdf/lib/bricks/pdf/engine/xhtml2pdf.rb +9 -0
  68. data/bricks/pdf/lib/bricks/pdf/install.rb +121 -0
  69. data/bricks/pdf/test/engines/test_prince.rb +15 -0
  70. data/bricks/pdf/test/engines/test_xhtml2pdf.rb +15 -0
  71. data/bricks/{data2pdf → pdf}/test/fixtures/application.css +0 -0
  72. data/bricks/{data2pdf → pdf}/test/fixtures/contact.html +0 -0
  73. data/bricks/{data2pdf → pdf}/test/fixtures/pisa-default.css +0 -0
  74. data/bricks/{data2pdf → pdf}/test/fixtures/sheet1.css +0 -0
  75. data/bricks/{data2pdf → pdf}/test/fixtures/sheet2.css +0 -0
  76. data/bricks/{data2pdf → pdf}/test/fixtures/simple-html.html +0 -0
  77. data/bricks/{data2pdf → pdf}/test/fixtures/simple-text.txt +0 -0
  78. data/bricks/{data2pdf → pdf}/test/helper.rb +4 -5
  79. data/bricks/pdf/test/shoulda_macros/shoulda_pdf.rb +72 -0
  80. data/bricks/pdf/zena/init.rb +5 -0
  81. data/bricks/pdf/zena/tasks.rb +17 -0
  82. data/bricks/sphinx/lib/{use_sphinx.rb → bricks/sphinx.rb} +1 -1
  83. data/bricks/tags/zena/init.rb +2 -2
  84. data/bricks/tags/zena/test/zafu/tags.yml +4 -4
  85. data/bricks/zena/zena/migrate/01_base.rb +482 -0
  86. data/config/bricks.yml +22 -6
  87. data/config/gems.yml +8 -6
  88. data/db/20100628074512_zena0x_to1x.rb +6 -1
  89. data/db/fix/024_correct_vclass_kpath.rb +11 -0
  90. data/db/fix/025_move_tag_into_vclass.rb +13 -0
  91. data/db/{migrate → fix}/026_rename_templates.rb +0 -0
  92. data/db/{migrate → fix}/045_avoid_star_in_templates.rb +0 -0
  93. data/db/{migrate → fix}/046_fix_zazen_image_tag.rb +0 -0
  94. data/db/{migrate → fix}/047_change_default_link_id_to_zero.rb +1 -3
  95. data/db/{migrate → fix}/049_fix_publish_from_is_null.rb +0 -0
  96. data/db/{migrate → fix}/20090924141459_zafu_fix_sept09.rb +0 -0
  97. data/db/{migrate → fix}/20091013100351_rename_publish_group_to_drive_group.rb +1 -3
  98. data/db/{migrate → fix}/20091124161608_rebuild_fullpath.rb +0 -1
  99. data/db/{migrate → fix}/20100115134729_rebuild_fullpath_after_fix.rb +0 -0
  100. data/db/{migrate → fix}/20100526090140_renamed_contact_model_to_base_contact.rb +2 -4
  101. data/db/{migrate → fix/old_migrations}/001_create_base.rb +0 -1
  102. data/db/{migrate → fix/old_migrations}/002_add_time_zone_to_users.rb +0 -0
  103. data/db/{migrate → fix/old_migrations}/003_add_custom_base_flag.rb +0 -0
  104. data/db/{migrate → fix/old_migrations}/004_rename_template_skin.rb +0 -0
  105. data/db/{migrate → fix/old_migrations}/005_create_cached_pages.rb +0 -0
  106. data/db/{migrate → fix/old_migrations}/006_create_sites.rb +0 -0
  107. data/db/{migrate → fix/old_migrations}/007_replace_id_by_zip.rb +0 -0
  108. data/db/{migrate → fix/old_migrations}/008_user_status.rb +0 -0
  109. data/db/{migrate → fix/old_migrations}/009_fulltext.rb +0 -0
  110. data/db/fix/old_migrations/010_create_template_content.rb +17 -0
  111. data/db/{migrate → fix/old_migrations}/011_project_to_section.rb +0 -0
  112. data/db/{migrate → fix/old_migrations}/012_add_project_id.rb +0 -0
  113. data/db/{migrate → fix/old_migrations}/013_remove_defaults.rb +0 -0
  114. data/db/{migrate → fix/old_migrations}/014_add_sort_field.rb +0 -0
  115. data/db/{migrate → fix/old_migrations}/015_add_dyn_attributes.rb +0 -0
  116. data/db/{migrate → fix/old_migrations}/016_remove_translations.rb +0 -0
  117. data/db/{migrate → fix/old_migrations}/017_rename_authorize.rb +0 -0
  118. data/db/{migrate → fix/old_migrations}/018_add_auth_option.rb +0 -0
  119. data/db/{migrate → fix/old_migrations}/019_remove_user_status.rb +0 -0
  120. data/db/{migrate → fix/old_migrations}/020_create_participation.rb +0 -0
  121. data/db/{migrate → fix/old_migrations}/021_create_relations.rb +0 -0
  122. data/db/{migrate → fix/old_migrations}/022_create_virtual_classes.rb +0 -0
  123. data/db/{migrate → fix/old_migrations}/023_ip_on_anonymous_comment.rb +0 -0
  124. data/db/{migrate → fix/old_migrations}/027_add_country_to_contacts.rb +0 -0
  125. data/db/{migrate → fix/old_migrations}/028_change_size_of_conten_type_field.rb +0 -0
  126. data/db/{migrate → fix/old_migrations}/029_create_data_entries.rb +0 -0
  127. data/db/{migrate → fix/old_migrations}/030_redit_auto_publish_site_settings.rb +0 -0
  128. data/db/{migrate → fix/old_migrations}/031_create_iformats.rb +0 -0
  129. data/db/{migrate → fix/old_migrations}/032_caches_context_as_hash.rb +0 -0
  130. data/db/{migrate → fix/old_migrations}/033_documents_kpath_change.rb +0 -0
  131. data/db/{migrate → fix/old_migrations}/034_change_file_storage.rb +0 -0
  132. data/db/{migrate → fix/old_migrations}/035_add_status_to_link.rb +0 -0
  133. data/db/{migrate → fix/old_migrations}/036_add_flag_fields_on_nodes.rb +0 -0
  134. data/db/{migrate → fix/old_migrations}/037_add_auto_create_discussion_to_v_class.rb +0 -0
  135. data/db/{migrate → fix/old_migrations}/038_create_site_attributes.rb +0 -0
  136. data/db/{migrate → fix/old_migrations}/039_default_position.rb +0 -0
  137. data/db/{migrate → fix/old_migrations}/040_second_value_for_data_entry.rb +0 -0
  138. data/db/{migrate → fix/old_migrations}/041_add_attributes_to_v_class.rb +0 -0
  139. data/db/{migrate → fix/old_migrations}/042_fix_position_should_be_float.rb +0 -0
  140. data/db/{migrate → fix/old_migrations}/043_move_user_lang_into_participation.rb +0 -0
  141. data/db/{migrate → fix/old_migrations}/044_remove_monolingual_site_option.rb +0 -0
  142. data/db/{migrate → fix/old_migrations}/048_link_source_target_can_be_null.rb +0 -0
  143. data/db/{migrate → fix/old_migrations}/050_date_in_links.rb +0 -0
  144. data/db/{migrate → fix/old_migrations}/051_add_exif_tags_to_images.rb +0 -0
  145. data/db/{migrate → fix/old_migrations}/20090825201159_insert_zero_link.rb +0 -0
  146. data/db/{migrate → fix/old_migrations}/20090825201200_merge_bricks_migrations_with_std_migrations.rb +0 -0
  147. data/db/{migrate → fix/old_migrations}/20090927125912_allow_null_in_text_fields.rb +0 -0
  148. data/db/{migrate → fix/old_migrations}/20090928133440_no_more_private_nodes.rb +0 -0
  149. data/db/{migrate → fix/old_migrations}/20090928143754_version_status_change.rb +0 -0
  150. data/db/{migrate → fix/old_migrations}/20091001084025_change_status_values_for_comments.rb +0 -0
  151. data/db/{migrate → fix/old_migrations}/20091009084057_add_vhash_in_node.rb +0 -0
  152. data/db/{migrate → fix/old_migrations}/20091014130833_fix_template_title.rb +0 -0
  153. data/db/{migrate → fix/old_migrations}/20091014183726_merge_participation_into_users.rb +0 -0
  154. data/db/{migrate → fix/old_migrations}/20091018200734_add_popup_info_to_image_format.rb +0 -0
  155. data/db/{migrate → fix/old_migrations}/20091026161708_add_persistence_token.rb +0 -0
  156. data/db/{migrate → fix/old_migrations}/20091101184952_add_session_table.rb +0 -0
  157. data/db/{migrate → fix/old_migrations}/20091123175137_add_single_access_token.rb +0 -0
  158. data/db/{migrate → fix/old_migrations}/20100125062254_add_dynamo_to_version.rb +0 -0
  159. data/db/{migrate → fix/old_migrations}/20100201133242_remove_default_status_on_version.rb +0 -0
  160. data/db/{migrate → fix/old_migrations}/20100208194210_create_attachments.rb +0 -0
  161. data/db/{migrate → fix/old_migrations}/20100210112319_change_dynamo_to_property.rb +0 -0
  162. data/db/{migrate → fix/old_migrations}/20100320145726_transform_template_contents_into_index.rb +0 -0
  163. data/db/{migrate → fix/old_migrations}/20100328125634_change_skin_name_to_id.rb +0 -0
  164. data/db/{migrate → fix/old_migrations}/20100417061257_add_properties_to_sites.rb +0 -0
  165. data/db/{migrate → fix/old_migrations}/20100419163149_rename_name_to_node_name.rb +0 -0
  166. data/db/{migrate → fix/old_migrations}/20100422091606_change_v_class_table_into_roles.rb +0 -0
  167. data/db/{migrate → fix/old_migrations}/20100422094048_node_habtm_roles.rb +0 -0
  168. data/db/{migrate → fix/old_migrations}/20100422115935_create_columns.rb +0 -0
  169. data/db/{migrate → fix/old_migrations}/20100513181529_add_site_id_to_columns.rb +0 -0
  170. data/db/{migrate → fix/old_migrations}/20100519091711_add_index_definition_to_columns.rb +0 -0
  171. data/db/{migrate → fix/old_migrations}/20100519091940_create_idx_nodes_string.rb +0 -0
  172. data/db/{migrate → fix/old_migrations}/20100519232432_create_idx_nodes_ml_string.rb +0 -0
  173. data/db/{migrate → fix/old_migrations}/20100525113858_add_porperties_to_users.rb +0 -0
  174. data/db/{migrate → fix/old_migrations}/20100527130937_change_column_index_to_string.rb +0 -0
  175. data/db/{migrate → fix/old_migrations}/20100531135128_add_fulltext_builder_fields.rb +0 -0
  176. data/db/{migrate → fix/old_migrations}/20100915062903_add_api_group_id_to_site.rb +0 -0
  177. data/db/fix/old_migrations/20100923154807_remove_base_contact.rb +84 -0
  178. data/db/fix/old_migrations/20100926192223_remove_su_user.rb +8 -0
  179. data/db/fix/old_migrations/20100927141658_add_eval_attributes_to_v_class.rb +12 -0
  180. data/db/fix/old_migrations/20100928185257_add_obvious_idx.rb +52 -0
  181. data/db/fix/old_migrations/20100929143111_remove_node_name.rb +11 -0
  182. data/db/fix/old_migrations/20101006090454_store_properties_in_long_text.rb +9 -0
  183. data/db/fix/old_migrations/20101014185753_remove_user_prototype_id.rb +9 -0
  184. data/db/fix/old_migrations/20101101084318_create_scope_index.rb +35 -0
  185. data/db/fix/old_migrations/20101109074232_create_idx_nodes_tables.rb +65 -0
  186. data/db/fix/old_migrations/20101110184235_add_role_update_to_site.rb +9 -0
  187. data/db/fix/old_migrations/20101116103920_change_scope_index.rb +31 -0
  188. data/db/fix/old_migrations/20101123125822_add_integer_idx.rb +17 -0
  189. data/db/fix/old_migrations/20101130134522_add_index_field.rb +13 -0
  190. data/db/fix/old_migrations/20101213133816_add_group_to_relation.rb +9 -0
  191. data/db/init/base/help.fr.zml +1 -1
  192. data/db/init/base/skins/default.zml +0 -1
  193. data/db/init/base/skins/default/Node-+search.zafu +1 -1
  194. data/db/init/base/skins/default/Node-tree.zafu +3 -3
  195. data/db/init/base/skins/default/Node.zafu +3 -3
  196. data/lib/bricks/loader.rb +4 -1
  197. data/lib/bricks/requirements_validation.rb +11 -6
  198. data/lib/log_recorder/lib/log_recorder.rb +2 -2
  199. data/lib/tasks/zena.rake +25 -15
  200. data/lib/zena.rb +42 -9
  201. data/lib/zena/acts/enrollable.rb +81 -99
  202. data/lib/zena/acts/secure.rb +27 -23
  203. data/lib/zena/acts/secure_node.rb +10 -55
  204. data/lib/zena/acts/serializable.rb +9 -10
  205. data/lib/zena/app.rb +0 -2
  206. data/lib/zena/code_syntax.rb +1 -1
  207. data/lib/zena/controller/test_case.rb +0 -5
  208. data/lib/zena/core_ext/string.rb +48 -20
  209. data/lib/zena/db.rb +10 -442
  210. data/lib/zena/db_helper/abstract_db.rb +184 -0
  211. data/lib/zena/db_helper/mysql.rb +150 -0
  212. data/lib/zena/db_helper/postgresql.rb +79 -0
  213. data/lib/zena/db_helper/sqlite3.rb +135 -0
  214. data/lib/zena/deploy.rb +4 -1
  215. data/lib/zena/deploy/httpd.rhtml +3 -3
  216. data/lib/zena/deploy/vhost.rhtml +1 -1
  217. data/lib/zena/foxy_parser.rb +37 -18
  218. data/lib/zena/info.rb +3 -13
  219. data/lib/zena/migrator.rb +0 -1
  220. data/lib/zena/parser/zafu_rules.rb +9 -4
  221. data/lib/zena/parser/zazen_rules.rb +5 -5
  222. data/lib/zena/parser/zena_rules.rb +1 -1
  223. data/lib/zena/remote/interface.rb +1 -1
  224. data/lib/zena/site_worker.rb +3 -3
  225. data/lib/zena/test_controller.rb +10 -10
  226. data/lib/zena/use/action.rb +66 -6
  227. data/lib/zena/use/ajax.rb +39 -13
  228. data/lib/zena/use/ancestry.rb +210 -0
  229. data/lib/zena/use/authlogic.rb +30 -1
  230. data/lib/zena/use/calendar.rb +158 -0
  231. data/lib/zena/use/conditional.rb +3 -2
  232. data/lib/zena/use/context.rb +42 -12
  233. data/lib/zena/use/dates.rb +15 -14
  234. data/lib/zena/use/display.rb +54 -7
  235. data/lib/zena/use/error_rendering.rb +1 -0
  236. data/lib/zena/use/field_index.rb +20 -0
  237. data/lib/zena/use/fixtures.rb +12 -9
  238. data/lib/zena/use/forms.rb +230 -106
  239. data/lib/zena/use/fulltext.rb +28 -14
  240. data/lib/zena/use/html_tags.rb +1 -24
  241. data/lib/zena/use/i18n.rb +69 -14
  242. data/lib/zena/use/kpath.rb +60 -0
  243. data/lib/zena/use/ml_index.rb +6 -4
  244. data/lib/zena/use/node_context.rb +63 -0
  245. data/lib/zena/use/prop_eval.rb +90 -0
  246. data/lib/zena/use/query_builder.rb +159 -29
  247. data/lib/zena/use/query_comment.rb +1 -1
  248. data/lib/zena/use/query_node.rb +147 -56
  249. data/lib/zena/use/recursion.rb +2 -2
  250. data/lib/zena/use/relations.rb +31 -19
  251. data/lib/zena/use/rendering.rb +111 -121
  252. data/lib/zena/use/scope_index.rb +230 -0
  253. data/lib/zena/use/search.rb +7 -7
  254. data/lib/zena/use/urls.rb +87 -25
  255. data/lib/zena/use/version_hash.rb +113 -113
  256. data/lib/zena/use/workflow.rb +5 -1
  257. data/lib/zena/use/zafu_attributes.rb +11 -14
  258. data/lib/zena/use/zafu_eval.rb +1 -1
  259. data/lib/zena/use/zafu_safe_definitions.rb +91 -9
  260. data/lib/zena/use/zafu_templates.rb +146 -102
  261. data/lib/zena/use/zazen.rb +5 -4
  262. data/lib/zena/zafu_compiler.rb +1 -0
  263. data/locale/en/LC_MESSAGES/zena.mo +0 -0
  264. data/locale/en/zena.po +0 -1
  265. data/locale/fr/LC_MESSAGES/zena.mo +0 -0
  266. data/locale/fr/zena.mo +0 -0
  267. data/locale/fr/zena.po +4 -4
  268. data/misc/zena +35 -0
  269. data/misc/zena_init +41 -0
  270. data/public/images/ext/{basecontact.png → contact.png} +0 -0
  271. data/public/javascripts/zena.js +35 -7
  272. data/public/stylesheets/admin.css +5 -2
  273. data/public/stylesheets/default.css +2 -1
  274. data/public/stylesheets/popup.css +1 -1
  275. data/public/stylesheets/zena.css +2 -2
  276. data/test/custom_queries/complex.host.yml +12 -5
  277. data/test/fixtures/files/Node-test.zafu +3 -3
  278. data/test/fixtures/files/translations_fr.yml +4 -2
  279. data/test/functional/documents_controller_test.rb +31 -0
  280. data/test/functional/nodes_controller_commit_test.rb +1 -5
  281. data/test/functional/nodes_controller_test.rb +92 -12
  282. data/test/functional/user_sessions_controller_test.rb +2 -2
  283. data/test/functional/users_controller_test.rb +31 -29
  284. data/test/functional/versions_controller_test.rb +2 -2
  285. data/test/functional/virtual_classes_controller_test.rb +2 -2
  286. data/test/integration/multiple_hosts_test.rb +19 -8
  287. data/test/integration/navigation_test.rb +91 -12
  288. data/test/integration/query_node/basic.yml +40 -37
  289. data/test/integration/query_node/complex.yml +23 -18
  290. data/test/integration/query_node/dates.yml +3 -3
  291. data/test/integration/query_node/errors.yml +7 -1
  292. data/test/integration/query_node/filters.yml +41 -35
  293. data/test/integration/query_node/idx_fields.yml +11 -0
  294. data/test/integration/query_node/idx_key_value.yml +77 -0
  295. data/test/integration/query_node/idx_scope.yml +33 -0
  296. data/test/integration/query_node/relations.yml +13 -13
  297. data/test/integration/query_node_test.rb +6 -10
  298. data/test/integration/zafu_compiler/action.yml +19 -6
  299. data/test/integration/zafu_compiler/ajax.yml +111 -51
  300. data/test/integration/zafu_compiler/apphelper.yml +1 -1
  301. data/test/integration/zafu_compiler/asset.yml +1 -1
  302. data/test/integration/zafu_compiler/basic.yml +42 -52
  303. data/test/integration/zafu_compiler/calendar.yml +3 -3
  304. data/test/integration/zafu_compiler/complex.yml +16 -16
  305. data/test/integration/zafu_compiler/complex_ok.yml +2 -2
  306. data/test/integration/zafu_compiler/conditional.yml +42 -33
  307. data/test/integration/zafu_compiler/data.yml +3 -3
  308. data/test/integration/zafu_compiler/dates.yml +25 -10
  309. data/test/integration/zafu_compiler/display.yml +49 -12
  310. data/test/integration/zafu_compiler/errors.yml +26 -6
  311. data/test/integration/zafu_compiler/eval.yml +4 -4
  312. data/test/integration/zafu_compiler/forms.yml +89 -15
  313. data/test/integration/zafu_compiler/i18n.yml +23 -18
  314. data/test/integration/zafu_compiler/idx_scope.yml +7 -0
  315. data/test/integration/zafu_compiler/later.yml +10 -16
  316. data/test/integration/zafu_compiler/off/off.yml +2 -2
  317. data/test/integration/zafu_compiler/query.yml +207 -0
  318. data/test/integration/zafu_compiler/recursion.yml +2 -2
  319. data/test/integration/zafu_compiler/relations.yml +144 -168
  320. data/test/integration/zafu_compiler/roles.yml +86 -10
  321. data/test/integration/zafu_compiler/rubyless.yml +49 -6
  322. data/test/integration/zafu_compiler/safe_definitions.yml +35 -6
  323. data/test/integration/zafu_compiler/search.yml +1 -1
  324. data/test/integration/zafu_compiler/security.yml +37 -0
  325. data/test/integration/zafu_compiler/urls.yml +50 -40
  326. data/test/integration/zafu_compiler/user.yml +21 -6
  327. data/test/integration/zafu_compiler/version.yml +6 -6
  328. data/test/integration/zafu_compiler/zafu_attributes.yml +43 -34
  329. data/test/integration/zafu_compiler/zazen.yml +10 -10
  330. data/test/integration/zafu_compiler_test.rb +19 -13
  331. data/test/sites/complex/nodes.yml +0 -2
  332. data/test/sites/complex/roles.yml +9 -1
  333. data/test/sites/complex/sites.yml +0 -1
  334. data/test/sites/complex/users.yml +2 -5
  335. data/test/sites/ocean/nodes.yml +2 -5
  336. data/test/sites/ocean/roles.yml +8 -0
  337. data/test/sites/ocean/sites.yml +0 -1
  338. data/test/sites/ocean/users.yml +0 -13
  339. data/test/sites/zena/columns.yml +27 -5
  340. data/test/sites/zena/idx_projects.yml +5 -0
  341. data/test/sites/zena/nodes.yml +8 -32
  342. data/test/sites/zena/relations.yml +5 -0
  343. data/test/sites/zena/roles.yml +25 -3
  344. data/test/sites/zena/sites.yml +2 -2
  345. data/test/sites/zena/users.yml +1 -21
  346. data/test/sites/zena/versions.yml +35 -12
  347. data/test/test_helper.rb +7 -0
  348. data/test/unit/after_commit_test.rb +7 -7
  349. data/test/unit/cache_test.rb +32 -0
  350. data/test/unit/cached_page_test.rb +1 -1
  351. data/test/unit/column_test.rb +31 -7
  352. data/test/unit/comment_test.rb +2 -2
  353. data/test/unit/core_ext_test.rb +38 -7
  354. data/test/unit/document_test.rb +14 -42
  355. data/test/unit/node_test.rb +311 -324
  356. data/test/unit/note_test.rb +23 -31
  357. data/test/unit/page_test.rb +16 -58
  358. data/test/unit/project_test.rb +2 -2
  359. data/test/unit/relation_proxy_test.rb +148 -21
  360. data/test/unit/relation_test.rb +23 -3
  361. data/test/unit/remote_test.rb +15 -9
  362. data/test/unit/role_test.rb +9 -0
  363. data/test/unit/site_test.rb +49 -47
  364. data/test/unit/skin_test.rb +16 -0
  365. data/test/unit/template_test.rb +60 -69
  366. data/test/unit/text_document_test.rb +15 -14
  367. data/test/unit/user_test.rb +101 -41
  368. data/test/unit/version_test.rb +4 -4
  369. data/test/unit/virtual_class_test.rb +577 -36
  370. data/test/unit/workflow_test.rb +58 -21
  371. data/test/unit/zena/acts/enrollable_test.rb +36 -127
  372. data/test/unit/zena/acts/secure_test.rb +6 -22
  373. data/test/unit/zena/acts/serializable_test.rb +18 -0
  374. data/test/unit/zena/db_test.rb +14 -14
  375. data/test/unit/zena/parser/zafu.yml +5 -3
  376. data/test/unit/zena/use/ancestry_test.rb +198 -0
  377. data/test/unit/zena/use/calendar_test.rb +8 -8
  378. data/test/unit/zena/use/dates_test.rb +2 -0
  379. data/test/unit/zena/use/fulltext_test.rb +9 -1
  380. data/test/unit/zena/use/html_tags_test.rb +2 -16
  381. data/test/unit/zena/use/i18n_test.rb +2 -2
  382. data/test/unit/zena/use/kpath_test.rb +13 -0
  383. data/test/unit/zena/use/ml_index_test.rb +60 -12
  384. data/test/unit/zena/use/prop_eval_test.rb +170 -0
  385. data/test/unit/zena/use/query_node_test.rb +9 -2
  386. data/test/unit/zena/use/rendering_test.rb +98 -1
  387. data/test/unit/zena/use/scope_index_test.rb +464 -0
  388. data/test/unit/zena/use/urls_test.rb +23 -13
  389. data/test/unit/zena/use/version_hash_test.rb +2 -2
  390. data/test/unit/zena/use/zafu_template_test.rb +21 -8
  391. data/test/unit/zena/use/zazen_test.rb +47 -47
  392. data/zena.gemspec +177 -143
  393. metadata +222 -141
  394. data/app/models/base_contact.rb +0 -79
  395. data/app/models/book.rb +0 -242
  396. data/app/models/contact_content.rb +0 -70
  397. data/app/models/contact_version.rb +0 -40
  398. data/app/models/reference.rb +0 -18
  399. data/app/views/templates/edit_tabs/_basecontact.rhtml +0 -8
  400. data/bricks/data2pdf/README +0 -19
  401. data/bricks/data2pdf/VERSION +0 -1
  402. data/bricks/data2pdf/lib/data2pdf.rb +0 -60
  403. data/bricks/data2pdf/lib/engines/prince.rb +0 -39
  404. data/bricks/data2pdf/lib/engines/xhtml2pdf.rb +0 -41
  405. data/bricks/data2pdf/lib/install.rb +0 -111
  406. data/bricks/data2pdf/test/engines/test_prince.rb +0 -14
  407. data/bricks/data2pdf/test/engines/test_xhtml2pdf.rb +0 -14
  408. data/bricks/data2pdf/test/shoulda_macros/shoulda_data2pdf.rb +0 -91
  409. data/bricks/data2pdf/test/unit/test_rendering.rb +0 -37
  410. data/config/routes.rb +0 -3
  411. data/db/migrate/010_create_template_content.rb +0 -17
  412. data/db/migrate/024_correct_vclass_kpath.rb +0 -13
  413. data/db/migrate/025_move_tag_into_vclass.rb +0 -15
  414. data/lib/version_off.rb +0 -323
  415. data/lib/zena/use/node_name.rb +0 -94
  416. data/test/integration/query_node/properties.yml +0 -41
  417. data/test/unit/base_contact_test.rb +0 -242
  418. data/test/unit/node_name_test.rb +0 -137
data/test/test_helper.rb CHANGED
@@ -14,6 +14,13 @@ rescue Exception => err
14
14
  end
15
15
  end
16
16
 
17
+ def err(obj)
18
+ obj.errors.each_error do |er,msg|
19
+ puts "[#{er}] #{msg}"
20
+ end
21
+ end
22
+
23
+
17
24
  class PagerDummy < Node
18
25
  def self.ksel
19
26
  self == PagerDummy ? 'U' : super
@@ -9,7 +9,7 @@ class AfterCommitTest < ActiveSupport::TestCase
9
9
  attr_accessor :actions
10
10
  before_save :do_action
11
11
  after_save :raise_to_rollback
12
- validates_presence_of :node_name
12
+ validates_presence_of :custom_a
13
13
 
14
14
  def after_commit_actions
15
15
  @after_commit_actions ||= []
@@ -24,19 +24,19 @@ class AfterCommitTest < ActiveSupport::TestCase
24
24
  end
25
25
 
26
26
  def raise_to_rollback
27
- raise ActiveRecord::Rollback if self[:node_name] == 'raise'
27
+ raise ActiveRecord::Rollback if self[:custom_a] == 666
28
28
  end
29
29
  end
30
30
 
31
31
  def test_after_commit_actions_should_be_executed_after_commit
32
- page = Page.create(:node_name => 'hello')
32
+ page = Page.create(:custom_a => 1)
33
33
  assert_equal ['executed'], page.after_commit_actions
34
34
  end
35
35
 
36
36
  def test_after_commit_actions_should_be_executed_after_last_transaction
37
37
  page = nil
38
38
  Page.transaction do
39
- page = Page.create(:node_name => 'hello')
39
+ page = Page.create(:custom_a => 1)
40
40
  assert_equal [], page.after_commit_actions
41
41
  end
42
42
  assert_equal ['executed'], page.after_commit_actions
@@ -49,7 +49,7 @@ class AfterCommitTest < ActiveSupport::TestCase
49
49
  end
50
50
 
51
51
  def test_after_commit_actions_should_not_be_executed_on_raise
52
- page = Page.create(:node_name => 'raise')
52
+ page = Page.create(:custom_a => 666)
53
53
  assert_equal [], page.after_commit_actions
54
54
  end
55
55
 
@@ -57,7 +57,7 @@ class AfterCommitTest < ActiveSupport::TestCase
57
57
  page = nil
58
58
  begin
59
59
  Page.transaction do
60
- page = Page.create(:node_name => 'hello')
60
+ page = Page.create(:custom_a => 1)
61
61
  assert_equal [], page.after_commit_actions
62
62
  raise 'Something went bad'
63
63
  end
@@ -69,7 +69,7 @@ class AfterCommitTest < ActiveSupport::TestCase
69
69
  def test_after_commit_actions_should_not_be_executed_when_a_rollback_is_raised
70
70
  page = nil
71
71
  Page.transaction do
72
- page = Page.create(:node_name => 'hello')
72
+ page = Page.create(:custom_a => 1)
73
73
  assert_equal [], page.after_commit_actions
74
74
  raise ActiveRecord::Rollback
75
75
  end
@@ -1,5 +1,8 @@
1
1
  require 'test_helper'
2
2
 
3
+ # Cache has been thrown to hell.
4
+
5
+ =begin
3
6
  class CacheTest < Zena::Unit::TestCase
4
7
 
5
8
  def setup
@@ -42,6 +45,34 @@ class CacheTest < Zena::Unit::TestCase
42
45
  assert_equal "content 6", Cache.with(2,[3,8] , 'NP', 'first' , 'test') { "content #{i}" }
43
46
  end
44
47
 
48
+ def test_after_all_cache_sweep
49
+ login(:lion)
50
+ i = 1
51
+ assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NP', 'pages') { "content #{i}" }
52
+ assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NN', 'notes') { "content #{i}" }
53
+ i = 2
54
+ assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NP', 'pages') { "content #{i}" }
55
+ assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NN', 'notes') { "content #{i}" }
56
+
57
+ # do something on a project
58
+ node = secure!(Node) { nodes(:wiki) }
59
+ assert_equal 'NPP', node.class.kpath
60
+ assert node.update_attributes(:title=>'new title'), "Can change attributes"
61
+ # sweep only kpath NPP
62
+ i = 3
63
+ assert_equal "content 3", Cache.with(visitor.id, visitor.group_ids, 'NP', 'pages') { "content #{i}" }
64
+ assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NN', 'notes') { "content #{i}" }
65
+
66
+ # do something on a note
67
+ node = secure!(Node) { nodes(:proposition) }
68
+ assert_equal 'NNP', node.vclass.kpath
69
+ assert node.update_attributes(:log_at => Time.now), "Can change attributes"
70
+ # sweep only kpath NN
71
+ i = 4
72
+ assert_equal "content 3", Cache.with(visitor.id, visitor.group_ids, 'NP', 'pages') { "content #{i}" }
73
+ assert_equal "content 4", Cache.with(visitor.id, visitor.group_ids, 'NN', 'notes') { "content #{i}" }
74
+ end
75
+
45
76
  def test_kpath
46
77
  i = 1
47
78
  assert_equal "content 1", Cache.with(1,[2,3,4], 'NP', 'pages') { "content #{i}" }
@@ -60,3 +91,4 @@ class CacheTest < Zena::Unit::TestCase
60
91
  assert_equal "content 2", Cache.with(1,[2,3,4], 'NN', 'notes') { "content #{i}" }
61
92
  end
62
93
  end
94
+ =end
@@ -65,7 +65,7 @@ class CachedPageTest < Zena::Unit::TestCase
65
65
  login(:tiger)
66
66
  # edit node only
67
67
  node = secure!(Node) { nodes(:bird_jpg) }
68
- assert node.update_attributes(:node_name => 'hey'), "Can save"
68
+ assert node.update_attributes(:title => 'hey'), "Can save"
69
69
  assert !File.exists?(path), "Cache file removed"
70
70
  end
71
71
  end
@@ -51,27 +51,51 @@ class ColumnTest < Zena::Unit::TestCase
51
51
 
52
52
  context 'with the name of a hardwire property' do
53
53
  subject do
54
- Column.create(:role_id => roles_id(:Task), :ptype => 'string', :name => 'first_name')
54
+ Column.create(:role_id => roles_id(:Task), :ptype => 'string', :name => 'title')
55
55
  end
56
56
 
57
57
  should 'fail with an error' do
58
58
  assert_difference('Column.count', 0) do
59
- assert_equal 'has already been taken in BaseContact', subject.errors[:name]
59
+ assert_equal 'has already been taken in Node', subject.errors[:name]
60
60
  end
61
61
  end
62
- end # with an existing name
62
+ end # with the name of a hardwire property
63
63
 
64
- context 'with the name of a hardwire property' do
64
+ context 'with the name of a method in a model' do
65
65
  subject do
66
- Column.create(:role_id => roles_id(:Task), :ptype => 'string', :name => 'title')
66
+ Column.create(:role_id => roles_id(:Task), :ptype => 'string', :name => 'secure_on_destroy')
67
67
  end
68
68
 
69
69
  should 'fail with an error and return class' do
70
70
  assert_difference('Column.count', 0) do
71
- assert_equal 'has already been taken in Node', subject.errors[:name]
71
+ assert_equal 'invalid (method defined in Node)', subject.errors[:name]
72
72
  end
73
73
  end
74
- end # with an existing name
74
+ end # with the name of a hardwire property
75
+
76
+ context 'ending with _ids' do
77
+ subject do
78
+ Column.create(:role_id => roles_id(:Task), :ptype => 'string', :name => 'secure_on_destroy_ids')
79
+ end
80
+
81
+ should 'fail with an error and return class' do
82
+ assert_difference('Column.count', 0) do
83
+ assert_equal 'invalid (cannot end with _id or _ids)', subject.errors[:name]
84
+ end
85
+ end
86
+ end # with the name of a hardwire property
87
+
88
+ context 'ending with _id' do
89
+ subject do
90
+ Column.create(:role_id => roles_id(:Task), :ptype => 'string', :name => 'secure_on_destroy_id')
91
+ end
92
+
93
+ should 'fail with an error and return class' do
94
+ assert_difference('Column.count', 0) do
95
+ assert_equal 'invalid (cannot end with _id or _ids)', subject.errors[:name]
96
+ end
97
+ end
98
+ end # with the name of a hardwire property
75
99
  end # Creating a column
76
100
 
77
101
  end
@@ -45,7 +45,7 @@ class CommentTest < Zena::Unit::TestCase
45
45
  def test_author
46
46
  login(:anon)
47
47
  comment = secure!(Comment) { comments(:lion_says_inside) }
48
- assert_equal 'PLV', comment.author.initials
48
+ assert_equal 'Panthera Leo Verneyi', comment.author.title
49
49
  end
50
50
 
51
51
  def test_node
@@ -114,7 +114,7 @@ class CommentTest < Zena::Unit::TestCase
114
114
  comment = secure!(Comment) { Comment.create( :title=>'boo', :text=>'blah', :discussion_id => discussions_id(:outside_discussion_on_status_en) ) }
115
115
  assert ! comment.new_record?, "Not a new record"
116
116
  assert_nil comment[:author_name], "Author name is nil"
117
- assert_equal 'Panther Tigris Sumatran', comment.author_name
117
+ assert_equal 'Panthera Tigris Sumatran', comment.author_name
118
118
  end
119
119
 
120
120
 
@@ -1,10 +1,5 @@
1
- require 'rubygems'
2
- require 'tzinfo'
3
- require 'test/unit'
4
- require 'fileutils'
5
- require File.join(File.dirname(__FILE__), '../../lib/zena/core_ext/string')
6
- require File.join(File.dirname(__FILE__), '../../lib/zena/core_ext/fixnum')
7
- require File.join(File.dirname(__FILE__), '../../lib/zena/core_ext/dir')
1
+ # encoding: utf-8
2
+ require 'test_helper'
8
3
 
9
4
  class StringExtTest < Test::Unit::TestCase
10
5
  def test_abs_rel_path
@@ -33,6 +28,42 @@ class StringExtTest < Test::Unit::TestCase
33
28
 
34
29
  assert_equal "/a/b/c", ''.abs_path('/a/b/c')
35
30
  end
31
+
32
+ context 'A string with accents' do
33
+ subject do
34
+ "aïl en août"
35
+ end
36
+
37
+ should 'remove accents on to_filename' do
38
+ assert_equal 'a%C3%AFl en ao%C3%BBt', subject.to_filename
39
+ end
40
+
41
+ should 'recover original name on from_filename' do
42
+ assert_equal subject, String.from_filename(subject.to_filename)
43
+ end
44
+ end # A string with accents
45
+
46
+ context 'A long string' do
47
+ subject do
48
+ "12345678901234567890"
49
+ end
50
+
51
+ should 'limit size on limit' do
52
+ assert_equal '123456789012345…', subject.limit(15)
53
+ end
54
+
55
+ should 'append readmore argument on limit' do
56
+ assert_equal '123456789012345 <a href="">read more</a>', subject.limit(15, ' <a href="">read more</a>')
57
+ end
58
+
59
+ should 'not append readmore argument if limit is not reached' do
60
+ assert_equal '12345678901234567890', subject.limit(25, ' <a href="">read more</a>')
61
+ end
62
+
63
+ should 'not raise on negative limit' do
64
+ assert_equal ' <a href="">read more</a>', subject.limit(-35, ' <a href="">read more</a>')
65
+ end
66
+ end # A string with accents
36
67
  end
37
68
 
38
69
  class DirExtTest < Test::Unit::TestCase
@@ -47,15 +47,11 @@ class DocumentTest < Zena::Unit::TestCase
47
47
  assert_equal 'pdf', subject.ext
48
48
  end
49
49
 
50
- should 'set node_name from original_filename' do
51
- assert_equal 'life', subject.node_name
52
- end
53
-
54
50
  should 'set title from original_filename' do
55
- assert_equal 'life', subject.node_name
51
+ assert_equal 'life', subject.title
56
52
  end
57
53
 
58
- context 'with same node_name' do
54
+ context 'with same title' do
59
55
  subject do
60
56
  secure!(Document) { Document.create(
61
57
  :parent_id => nodes_id(:cleanWater),
@@ -63,11 +59,10 @@ class DocumentTest < Zena::Unit::TestCase
63
59
  }
64
60
  end
65
61
 
66
- should 'save node_name and title with increment' do
67
- assert_equal 'water-1', subject.node_name
62
+ should 'save title with increment' do
68
63
  assert_equal 'water-1', subject.title
69
64
  end
70
- end # with same node_name
65
+ end # with same title
71
66
 
72
67
  context 'without a file' do
73
68
  subject do
@@ -98,24 +93,23 @@ class DocumentTest < Zena::Unit::TestCase
98
93
  end
99
94
  end # with content_type
100
95
 
101
- context 'with a wrong extension in node_name' do
96
+ context 'with a wrong extension in title' do
102
97
  subject do
103
98
  secure!(Document) { Document.create(
104
99
  :parent_id => nodes_id(:cleanWater),
105
- :node_name => 'stupid.jpg',
100
+ :title => 'stupid.jpg',
106
101
  :file => uploaded_pdf('water.pdf'))
107
102
  }
108
103
  end
109
104
 
110
- should 'fix extension but use node_name' do
105
+ should 'fix extension but use title' do
111
106
  err subject
112
107
  assert !subject.new_record?
113
108
  assert_equal 'pdf', subject.ext
114
- assert_equal 'stupid', subject.node_name
115
- assert_equal 'stupid', subject.title
116
- assert_equal 'stupid.pdf', subject.filename
109
+ assert_equal 'stupid.jpg', subject.title
110
+ assert_equal 'stupid.jpg.pdf', subject.filename
117
111
  end
118
- end # with wrong extension in node_name
112
+ end # with wrong extension in title
119
113
 
120
114
  context 'with title ending with dots' do
121
115
  subject do
@@ -130,10 +124,6 @@ class DocumentTest < Zena::Unit::TestCase
130
124
  assert_equal 'report...', subject.title
131
125
  end
132
126
 
133
- should 'keep dots in node_name' do
134
- assert_equal 'report...', subject.node_name
135
- end
136
-
137
127
  should 'append extension afert dots' do
138
128
  assert_equal 'report....pdf', subject.filename
139
129
  end
@@ -222,13 +212,12 @@ class DocumentTest < Zena::Unit::TestCase
222
212
  end
223
213
  end # with a wrong file type
224
214
 
225
- context 'with existing node_name' do
226
- should 'save node_name and title with increment' do
215
+ context 'with existing title' do
216
+ should 'save title with increment' do
227
217
  assert subject.update_attributes(:title => 'flower', :v_status => Zena::Status[:pub])
228
- assert_equal 'flower-1', subject.node_name
229
218
  assert_equal 'flower-1', subject.title
230
219
  end
231
- end # with existing node_name
220
+ end # with existing title
232
221
 
233
222
  context 'with a new file' do
234
223
  # All tests relying on commit (filename, size, attachment) have been
@@ -270,11 +259,6 @@ class DocumentTest < Zena::Unit::TestCase
270
259
  assert_match /bird\.jpg$/, subject.filepath
271
260
  end
272
261
 
273
- should 'change document node_name on publish' do
274
- subject.update_attributes(:title => 'hopla', :v_status => Zena::Status[:pub])
275
- assert_equal 'hopla', subject.node_name
276
- end
277
-
278
262
  should 'not alter content_type' do
279
263
  subject.update_attributes(:title => 'New title')
280
264
  assert_equal 'image/jpeg', subject.content_type
@@ -299,10 +283,6 @@ class DocumentTest < Zena::Unit::TestCase
299
283
  assert subject.valid?
300
284
  end
301
285
 
302
- should 'get node_name' do
303
- assert_equal 'water', subject.node_name
304
- end
305
-
306
286
  should 'get title' do
307
287
  assert_equal 'water', subject.title
308
288
  end
@@ -311,18 +291,10 @@ class DocumentTest < Zena::Unit::TestCase
311
291
  assert_equal 'water.pdf', subject.filename
312
292
  end
313
293
 
314
- should 'get fullpath' do
315
- assert_equal 'projects/cleanWater/water', subject.fullpath
316
- end
317
-
318
294
  should 'get filepath' do
319
295
  assert_match /water.pdf$/, subject.filepath
320
296
  end
321
297
 
322
- should 'get rootpath' do
323
- assert_equal 'zena/projects/cleanWater/water.pdf', subject.rootpath
324
- end
325
-
326
298
  should 'get the file size' do
327
299
  assert_equal 29279, subject.size
328
300
  end
@@ -359,7 +331,7 @@ class DocumentTest < Zena::Unit::TestCase
359
331
  end
360
332
 
361
333
  should 'find document by path' do
362
- subject = secure!(Document) { Document.find_by_path("projects/cleanWater/water") }
334
+ subject = secure(Document) { Document.find_by_path("projects list/Clean Water project/water") }
363
335
  assert_kind_of Document, subject
364
336
  assert_equal nodes_id(:water_pdf), subject.id
365
337
  end
@@ -4,7 +4,7 @@ require 'test_helper'
4
4
  class NodeTest < Zena::Unit::TestCase
5
5
 
6
6
  NEW_DEFAULT = {
7
- :node_name => 'hello',
7
+ :title => 'hello',
8
8
  :rgroup_id => Zena::FoxyParser::id('zena', 'public'),
9
9
  :wgroup_id => Zena::FoxyParser::id('zena', 'workers'),
10
10
  :dgroup_id => Zena::FoxyParser::id('zena', 'managers'),
@@ -109,79 +109,49 @@ class NodeTest < Zena::Unit::TestCase
109
109
  assert_equal nodes_id(:art), node.id
110
110
  end
111
111
  end # setting an indexed field
112
- end # on a node with write access
113
- end # A logged in user
114
112
 
115
- def test_rebuild_fullpath
116
- Node.connection.execute "UPDATE nodes SET fullpath = NULL, basepath = NULL WHERE id = #{nodes_id(:wiki)}"
117
- login(:ant)
118
- node = nodes(:wiki)
119
- assert_nil node[:fullpath]
120
- node.send(:rebuild_fullpath)
121
- assert_equal 'projects/wiki', node.fullpath
122
- end
113
+ context 'setting with transformations' do
114
+ subject do
115
+ secure(Node) { nodes(:letter) }
116
+ end
123
117
 
124
- def test_rebuild_fullpath_in_custom_base
125
- Node.connection.execute "UPDATE nodes SET fullpath = NULL, basepath = NULL WHERE id = #{nodes_id(:status)}"
126
- login(:ant)
127
- node = nodes(:status)
128
- assert_nil node[:fullpath]
129
- node.send(:rebuild_fullpath)
130
- assert_equal 'projects/cleanWater/status', node.fullpath
131
- end
118
+ should 'transform zip in parent_id' do
119
+ assert subject.update_attributes_with_transformation('parent_id' => 'lake+')
120
+ assert_equal nodes_id(:lake_jpg), subject.parent_id
121
+ end
132
122
 
133
- def test_find_by_path
134
- login(:ant)
135
- node = secure!(Node) { Node.find_by_path('projects/wiki') }
136
- assert_equal nodes_id(:wiki), node.id
137
- end
123
+ should 'add error on bad zip in parent_id' do
124
+ assert !subject.update_attributes_with_transformation('parent_id' => '999')
125
+ assert_equal 'could not be found', subject.errors['parent_id']
126
+ end
127
+
128
+ should 'create links from pseudo ids' do
129
+ assert_difference('Link.count', 2) do
130
+ assert subject.update_attributes_with_transformation('set_tag_ids' => '33,news')
131
+ assert_equal [nodes_id(:art), nodes_id(:news)], subject.rel['set_tag'].other_ids
132
+ end
133
+ end
138
134
 
135
+ should 'add errors for bad ids' do
136
+ assert_difference('Link.count', 0) do
137
+ assert !subject.update_attributes_with_transformation('set_tag_ids' => '33,news,999,11')
138
+ assert_match %r'11 => invalid target', subject.errors['set_tag']
139
+ assert_match %r'999 => could not be found', subject.errors['set_tag']
140
+ end
141
+ end
142
+ end # setting with transformations
143
+
144
+ end # on a node with write access
145
+ end # A logged in user
146
+
147
+ # This is a stupid test because the result is not the same in production...
139
148
  def test_match_query
140
149
  query = Node.match_query('smala')
141
- assert_equal "nodes.node_name LIKE 'smala%'", query[:conditions]
150
+ assert_equal "nodes._id LIKE 'smala%'", query[:conditions]
142
151
  query = Node.match_query('.', :node => nodes(:wiki))
143
152
  assert_equal ["parent_id = ?", nodes_id(:wiki)], query[:conditions]
144
153
  end
145
154
 
146
- def test_ancestors
147
- Node.connection.execute "UPDATE nodes SET parent_id = #{nodes_id(:proposition)} WHERE id = #{nodes_id(:bird_jpg)}"
148
- login(:tiger)
149
- node = secure!(Node) { nodes(:status) }
150
- assert_equal ['zena', 'projects', 'cleanWater'], node.ancestors.map { |a| a[:node_name] }
151
- node = secure!(Node) { nodes(:zena) }
152
- assert_equal [], node.ancestors
153
- node = secure!(Node) { nodes(:bird_jpg) }
154
- prop = secure!(Node) { nodes(:proposition)}
155
- assert_kind_of Node, prop
156
- assert prop.can_read?
157
- assert_equal ['zena', 'projects', 'secret', 'proposition'], node.ancestors.map { |a| a[:node_name] }
158
- end
159
-
160
- def test_ancestors_infinit_loop
161
- Node.connection.execute "UPDATE nodes SET parent_id = #{nodes_id(:status)} WHERE id = #{nodes_id(:cleanWater)}"
162
- login(:ant)
163
- node = secure!(Node) { nodes(:lake_jpg) }
164
- assert_raise(Zena::InvalidRecord) { node.ancestors }
165
- end
166
-
167
- def test_ancestor_in_hidden_project
168
- login(:tiger)
169
- node = secure!(Node) { nodes(:proposition) }
170
- assert_kind_of Node, node
171
- assert_equal ['zena', 'projects', 'secret'], node.ancestors.map { |a| a[:node_name] } # ant can view 'proposition' but not the project proposition is in
172
- end
173
-
174
- def test_create_simplest
175
- login(:ant)
176
- test_page = secure!(Node) { Node.create(:node_name => 'yoba', :parent_id => nodes_id(:cleanWater), :inherit=>1 ) }
177
- assert ! test_page.new_record? , "Not a new record"
178
- assert_equal nodes_id(:cleanWater), test_page.parent[:id]
179
- assert_equal 'projects/cleanWater/yoba', test_page.fullpath
180
- assert_equal 'projects/cleanWater', test_page.basepath
181
- parent = secure!(Node) { nodes(:cleanWater) }
182
- assert_equal 'projects/cleanWater', parent.fullpath
183
- end
184
-
185
155
  def test_new_bad_parent
186
156
  login(:tiger)
187
157
  attrs = NEW_DEFAULT.dup
@@ -215,16 +185,16 @@ class NodeTest < Zena::Unit::TestCase
215
185
  assert node.save , "Save succeeds"
216
186
  end
217
187
 
218
- def test_page_new_without_node_name
188
+ def test_page_new_without_title
219
189
  login(:tiger)
220
190
  node = secure!(Node) { Node.new(:parent_id => nodes_id(:cleanWater)) }
221
191
  assert ! node.save, 'Save fails'
222
- assert_equal 'can\'t be blank', node.errors[:node_name]
192
+ assert_equal 'can\'t be blank', node.errors[:title]
223
193
  end
224
194
 
225
195
  def test_new_set_section_id
226
196
  login(:tiger)
227
- node = secure!(Page) { Page.create(:parent_id => nodes_id(:people), :node_name => 'SuperPage')}
197
+ node = secure!(Page) { Page.create(:parent_id => nodes_id(:people), :title => 'SuperPage')}
228
198
  assert ! node.new_record?, 'Not a new record'
229
199
  assert_equal nodes_id(:people), node[:section_id]
230
200
  end
@@ -263,17 +233,12 @@ class NodeTest < Zena::Unit::TestCase
263
233
  assert node.save , "Save succeeds"
264
234
  end
265
235
 
266
- def test_page_update_without_node_name
236
+ def test_page_update_without_title
267
237
  login(:tiger)
268
238
  node = secure!(Node) { nodes(:status) }
269
- node[:node_name] = nil
270
- assert node.save, 'Save succeeds'
271
- assert_equal 'statusTitle', node[:node_name]
272
- node = secure!(Node) { nodes(:status) }
273
- node[:node_name] = nil
274
- node.title = ""
275
- assert !node.save, 'Save fails'
276
- assert_equal 'can\'t be blank', node.errors[:node_name]
239
+ node.title = nil
240
+ assert !node.save
241
+ assert_equal 'can\'t be blank', node.errors[:title]
277
242
  end
278
243
 
279
244
  def test_update_set_section_id
@@ -329,11 +294,8 @@ class NodeTest < Zena::Unit::TestCase
329
294
  def test_new_child
330
295
  login(:ant)
331
296
  node = secure!(Node) { nodes(:cleanWater) }
332
- child = node.new_child(:node_name => 'status', :class => Page )
333
- assert !child.save, "Save fails"
334
- assert child.errors[:node_name].any?
335
297
 
336
- child = node.new_child(:node_name => 'new_name', :class => Page )
298
+ child = node.new_child(:title => 'new_name', :class => Page )
337
299
  assert child.save , "Save succeeds"
338
300
  assert_equal Zena::Status[:red], child.v_status
339
301
  assert_equal child[:user_id], users_id(:ant)
@@ -345,39 +307,14 @@ class NodeTest < Zena::Unit::TestCase
345
307
  assert_equal node[:id], child[:parent_id]
346
308
  end
347
309
 
348
- def test_secure_find_by_path
349
- login(:tiger)
350
- node = secure!(Node) { Node.find_by_path('projects/secret') }
351
- assert_kind_of Node, node
352
- assert_kind_of User, node.instance_variable_get(:@visitor)
353
- login(:ant)
354
- assert_raise(ActiveRecord::RecordNotFound) { node = secure!(Node) { Node.find_by_path('projects/secret') }}
355
- end
356
-
357
310
  def test_author
358
311
  login(:tiger)
359
312
  node = secure!(Node) { nodes(:cleanWater) }
360
- assert_equal node.user.contact_id, node.author[:id]
361
- assert_equal 'Panther Tigris Sumatran', node.author.fullname
313
+ assert_equal node.user.node_id, node.author[:id]
314
+ assert_equal 'Panthera Tigris Sumatran', node.author.title
362
315
  login(:anon)
363
316
  node = secure!(Node) { nodes(:status) }
364
- assert_equal 'Solenopsis Invicta', node.author.fullname
365
- end
366
-
367
- def test_set_node_name_with_title
368
- login(:tiger)
369
- node = secure!(Node) { Node.create(NEW_DEFAULT.stringify_keys.merge('node_name' => '', 'title' => 'small bed')) }
370
- assert_kind_of Node, node
371
- assert !node.new_record?
372
- assert_equal 'smallBed', node.node_name
373
- end
374
-
375
- def test_set_node_name
376
- node = nodes(:wiki)
377
- node.node_name = " J'aime l'aïl en août ! "
378
- assert_equal 'JAimeLAilEnAout', node.node_name
379
- node.node_name = "LIEUX"
380
- assert_equal 'LIEUX', node.node_name
317
+ assert_equal 'Solenopsis Invicta', node.author.title
381
318
  end
382
319
 
383
320
  def test_change_project_to_page
@@ -415,7 +352,7 @@ class NodeTest < Zena::Unit::TestCase
415
352
  end
416
353
 
417
354
  should 'be allowed to change attributes' do
418
- assert @node.update_attributes(:node_name => 'vodou', :event_at => Time.now)
355
+ assert @node.update_attributes(:event_at => Time.now)
419
356
  end
420
357
 
421
358
  should 'not be allowed to set parent' do
@@ -578,10 +515,11 @@ class NodeTest < Zena::Unit::TestCase
578
515
  end
579
516
 
580
517
  def test_url_name
581
- assert_equal "salutJEcrisAujourdHui", "salut j'écris: Aujourd'hui ".url_name!
582
- assert_equal "a--BabMol", " à,--/ bab* mol".url_name!
583
- assert_equal "07.11.2006-mardiProchain", "07.11.2006-mardi_prochain".url_name!
584
- assert_equal "Node-+login", "Node-+login".url_name!
518
+ assert_equal "salut-j%27%C3%A9cris%3A-Aujourd%27hui-", "salut j'écris: Aujourd'hui ".url_name
519
+ assert_equal "07.11.2006%2Dmardi_prochain", "07.11.2006-mardi_prochain".url_name
520
+ ['avant-hier', 'un ami ', 'èààèüï a', '" à,--/ bab* mol'].each do |l|
521
+ assert_equal l, String.from_url_name(l.url_name)
522
+ end
585
523
  end
586
524
 
587
525
  def test_tags
@@ -593,13 +531,13 @@ class NodeTest < Zena::Unit::TestCase
593
531
  assert @node.save
594
532
  tags = @node.find(:all, 'set_tags')
595
533
  assert_equal 2, tags.size
596
- assert_equal 'art', tags[0].node_name
597
- assert_equal 'news', tags[1].node_name
534
+ assert_equal 'Art', tags[0].title
535
+ assert_equal 'News list', tags[1].title
598
536
  @node.rel['set_tag'].other_ids = [nodes_id(:art)]
599
537
  @node.save
600
538
  tags = @node.find(:all, 'set_tags')
601
539
  assert_equal 1, tags.size
602
- assert_equal 'art', tags[0].node_name
540
+ assert_equal 'Art', tags[0].title
603
541
  end
604
542
 
605
543
  def test_tag_update
@@ -613,36 +551,6 @@ class NodeTest < Zena::Unit::TestCase
613
551
  assert_equal node[:id], peop.find(:first, 'set_tags')[:id]
614
552
  end
615
553
 
616
- def test_after_all_cache_sweep
617
- with_caching do
618
- login(:lion)
619
- i = 1
620
- assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NP', 'pages') { "content #{i}" }
621
- assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NN', 'notes') { "content #{i}" }
622
- i = 2
623
- assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NP', 'pages') { "content #{i}" }
624
- assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NN', 'notes') { "content #{i}" }
625
-
626
- # do something on a project
627
- node = secure!(Node) { nodes(:wiki) }
628
- assert_equal 'NPP', node.class.kpath
629
- assert node.update_attributes(:title=>'new title'), "Can change attributes"
630
- # sweep only kpath NPP
631
- i = 3
632
- assert_equal "content 3", Cache.with(visitor.id, visitor.group_ids, 'NP', 'pages') { "content #{i}" }
633
- assert_equal "content 1", Cache.with(visitor.id, visitor.group_ids, 'NN', 'notes') { "content #{i}" }
634
-
635
- # do something on a note
636
- node = secure!(Node) { nodes(:proposition) }
637
- assert_equal 'NNP', node.vclass.kpath
638
- assert node.update_attributes(:node_name => 'popo' ), "Can change attributes"
639
- # sweep only kpath NN
640
- i = 4
641
- assert_equal "content 3", Cache.with(visitor.id, visitor.group_ids, 'NP', 'pages') { "content #{i}" }
642
- assert_equal "content 4", Cache.with(visitor.id, visitor.group_ids, 'NN', 'notes') { "content #{i}" }
643
- end
644
- end
645
-
646
554
  def test_empty_comments
647
555
  login(:tiger)
648
556
  node = secure!(Node) { nodes(:lake) }
@@ -666,21 +574,47 @@ class NodeTest < Zena::Unit::TestCase
666
574
  assert !discussion.inside?
667
575
  end
668
576
 
669
- def test_closed_discussion
670
- login(:tiger)
671
- node = secure!(Node) { nodes(:status) }
672
- discussion = node.discussion
673
- discussion.update_attributes(:open=>false)
674
- node = secure!(Node) { nodes(:status) }
675
- assert_equal discussions_id(:outside_discussion_on_status_en), node.discussion[:id]
676
- login(:ant)
677
- node = secure!(Node) { nodes(:status) }
678
- assert_nil node.discussion
679
- node.update_attributes( :title=>'test' )
680
- discussion = node.discussion
681
- assert_kind_of Discussion, discussion
682
- assert discussion.inside?
683
- end
577
+ context 'A node with a discussion' do
578
+ setup do
579
+ login(:tiger)
580
+ visitor.lang = 'fr'
581
+ subject.update_attributes('title' => 'new publication', :v_status => Zena::Status[:pub])
582
+ subject.reload
583
+ end
584
+
585
+ subject do
586
+ # has an open discussion in 'en'
587
+ secure(Node) { nodes(:status) }
588
+ end
589
+
590
+ context 'visited in another language without discussion' do
591
+ setup do
592
+ login(:ant)
593
+ end
594
+
595
+ should 'create an outside discussion' do
596
+ assert_kind_of Discussion, subject.discussion
597
+ assert !subject.discussion.inside?
598
+ end
599
+ end # visited in another language
600
+
601
+ context 'that is closed' do
602
+ setup do
603
+ discussions(:outside_discussion_on_status_en).update_attributes(:open => false)
604
+ end
605
+
606
+ context 'visited in another language without discussion without drive access' do
607
+ setup do
608
+ login(:ant)
609
+ end
610
+
611
+ should 'not create a discussion' do
612
+ assert_nil subject.discussion
613
+ end
614
+ end # visited in another language
615
+ end # that is closed
616
+
617
+ end # A node with a closed discussion
684
618
 
685
619
  def test_inside_discussion
686
620
  login(:tiger)
@@ -727,7 +661,7 @@ class NodeTest < Zena::Unit::TestCase
727
661
  node = secure!(Node) { nodes(:status) }
728
662
  comments = node.comments
729
663
  assert_kind_of Comment, comments[0]
730
- assert_equal 'Nice site', comments[0][:title]
664
+ assert_equal 'Nice site', comments[0].title
731
665
  end
732
666
 
733
667
  def test_comments_on_nil
@@ -747,14 +681,14 @@ class NodeTest < Zena::Unit::TestCase
747
681
 
748
682
  def test_other_site_id
749
683
  login(:whale)
750
- node = secure!(Node) { Node.create(:parent_id => nodes_id(:ocean), :rgroup_id => groups_id(:aqua), :wgroup_id => groups_id(:masters), :dgroup_id => groups_id(:masters), :node_name => "fish") }
684
+ node = secure!(Node) { Node.create(:parent_id => nodes_id(:ocean), :rgroup_id => groups_id(:aqua), :wgroup_id => groups_id(:masters), :dgroup_id => groups_id(:masters), :title => "fish") }
751
685
  assert !node.new_record?, "Not a new record"
752
686
  assert_equal sites_id(:ocean), node[:site_id]
753
687
  end
754
688
 
755
689
  def test_other_site_id_fool_id
756
690
  login(:whale)
757
- node = secure!(Node) { Node.create(:parent_id => nodes_id(:ocean), :rgroup_id => groups_id(:aqua), :wgroup_id => groups_id(:masters), :dgroup_id => groups_id(:masters), :node_name => "fish", :site_id => sites_id(:zena)) }
691
+ node = secure!(Node) { Node.create(:parent_id => nodes_id(:ocean), :rgroup_id => groups_id(:aqua), :wgroup_id => groups_id(:masters), :dgroup_id => groups_id(:masters), :title => "fish", :site_id => sites_id(:zena)) }
758
692
  assert !node.new_record?, "Not a new record"
759
693
  assert_equal sites_id(:ocean), node[:site_id]
760
694
  end
@@ -776,7 +710,7 @@ class NodeTest < Zena::Unit::TestCase
776
710
  def test_zip
777
711
  next_zip = Zena::Db.fetch_attribute("SELECT zip FROM zips WHERE site_id = #{sites_id(:zena)}").to_i
778
712
  login(:tiger)
779
- node = secure!(Node) { Node.create(:parent_id=>nodes_id(:zena), :node_name => "fly")}
713
+ node = secure!(Node) { Node.create(:parent_id=>nodes_id(:zena), :title => "fly")}
780
714
  assert !node.new_record?, "Not a new record"
781
715
  assert_equal (next_zip + 1), node.zip
782
716
  end
@@ -797,61 +731,74 @@ class NodeTest < Zena::Unit::TestCase
797
731
 
798
732
  def test_create_node
799
733
  login(:ant)
800
- node = secure!(Node) { Node.create_node(:parent_id => nodes_zip(:secret), :node_name => 'funny') }
801
- assert_equal nodes_id(:secret), node[:parent_id]
734
+ node = secure!(Node) { Node.create_node(:parent_id => nodes_zip(:secret), :title => 'funny') }
802
735
  assert node.new_record?, "Not saved"
803
736
  assert_equal 'invalid reference', node.errors[:parent_id]
804
737
  end
805
738
 
806
739
  def test_create_node_with__parent_id
807
740
  login(:ant)
808
- node = secure!(Node) { Node.create_node(:_parent_id => nodes_id(:secret), :node_name => 'funny') }
809
- assert_equal nodes_id(:secret), node[:parent_id]
741
+ node = secure!(Node) { Node.create_node(:_parent_id => nodes_id(:secret), :title => 'funny') }
810
742
  assert node.new_record?, "Not saved"
811
743
  assert_equal 'invalid reference', node.errors[:parent_id]
812
744
  end
813
745
 
814
746
  def test_create_node_ok
815
747
  login(:tiger)
816
- node = secure!(Node) { Node.create_node('parent_id' => nodes_zip(:cleanWater), 'node_name' => 'funny') }
748
+ node = secure!(Node) { Node.create_node('parent_id' => nodes_zip(:cleanWater), 'title' => 'funny') }
817
749
  assert_equal nodes_id(:cleanWater), node[:parent_id]
818
- assert_equal 'funny', node[:node_name]
750
+ assert_equal 'funny', node.title
819
751
  assert !node.new_record?
820
752
  end
821
753
 
822
- def test_create_or_update_node_create
823
- login(:tiger)
824
- node = secure!(Node) { Node.create_or_update_node('parent_id' => nodes_zip(:cleanWater), 'node_name' => 'funny') }
825
- assert_equal nodes_id(:cleanWater), node[:parent_id]
826
- assert_equal 'funny', node[:node_name]
827
- assert !node.new_record?, "Saved"
828
- end
754
+ context 'Create or update from parent and title' do
755
+ setup do
756
+ login(:tiger)
757
+ end
829
758
 
830
- def test_create_or_update_node_update
831
- login(:tiger)
832
- node = secure!(Node) { Node.create_or_update_node('parent_id' => nodes_zip(:cleanWater), 'node_name' => 'status', 'title'=>"It's all broken") }
833
- assert_equal nodes_id(:cleanWater), node[:parent_id]
834
- assert_equal nodes_id(:status), node[:id]
835
- node = secure!(Node) { nodes(:status) }
836
- assert_equal 'status', node[:node_name]
837
- assert_equal "It's all broken", node.title
838
- end
759
+ context 'with matching node' do
760
+ subject do
761
+ secure(Node) { Node.create_or_update_node('parent_id' => nodes_zip(:cleanWater), 'title' => 'crocodiles', 'text' => 'Philippine crocodile') }
762
+ end
763
+
764
+ should 'update found node' do
765
+ assert_difference('Node.count', 0) do
766
+ assert subject.errors.blank?
767
+ assert_equal nodes_id(:crocodiles), subject.id
768
+ assert_equal 'Philippine crocodile', subject.prop['text']
769
+ end
770
+ end
771
+ end # with matching node
772
+
773
+ context 'without a matching node' do
774
+ subject do
775
+ secure(Node) { Node.create_or_update_node('parent_id' => nodes_zip(:cleanWater), 'title' => 'scorpion', 'text' => 'Compsobuthus werneri') }
776
+ end
777
+
778
+ should 'create a new node' do
779
+ assert_difference('Node.count', 1) do
780
+ err subject
781
+ end
782
+ end
783
+ end # without a matching node
784
+
785
+ end # Create or update from parent and title
839
786
 
840
787
  def test_create_with_klass
841
788
  login(:tiger)
842
- node = secure!(Node) { Node.create_node('parent_id' => nodes_zip(:projects), 'node_name' => 'funny', 'klass' => 'TextDocument', 'content_type' => 'application/x-javascript') }
789
+ node = secure!(Node) { Node.create_node('parent_id' => nodes_zip(:projects), 'title' => 'funny', 'klass' => 'TextDocument', 'content_type' => 'application/x-javascript') }
843
790
  assert_kind_of TextDocument, node
844
791
  assert_equal nodes_id(:projects), node[:parent_id]
845
- assert_equal 'funny', node[:node_name]
792
+ assert_equal 'funny', node.title
846
793
  assert !node.new_record?, "Saved"
847
794
  end
848
795
 
849
796
  def test_get_class
850
- assert_equal Node, Node.get_class('node')
851
- assert_equal Node, Node.get_class('nodes')
852
- assert_equal Node, Node.get_class('Node')
797
+ assert_equal Node, Node.get_class('node').real_class
798
+ assert_equal Node, Node.get_class('nodes').real_class
799
+ assert_equal Node, Node.get_class('Node').real_class
853
800
  assert_equal roles(:Letter), Node.get_class('Letter')
854
- assert_equal TextDocument, Node.get_class('TextDocument')
801
+ assert_equal TextDocument, Node.get_class('TextDocument').real_class
855
802
  end
856
803
 
857
804
  def test_get_class_without_plural
@@ -878,7 +825,7 @@ done: \"I am done\""
878
825
 
879
826
  def test_create_nodes_from_gzip_file
880
827
  login(:tiger)
881
- parent = secure!(Project) { Project.create(:node_name => 'import', :parent_id => nodes_id(:zena)) }
828
+ parent = secure!(Project) { Project.create(:title => 'import', :parent_id => nodes_id(:zena)) }
882
829
  assert !parent.new_record?, "Not a new record"
883
830
  nodes = secure!(Node) { Node.create_nodes_from_folder(:archive => uploaded_archive('simple.zml.gz'), :parent_id => parent[:id] )}.values
884
831
  assert_equal 1, nodes.size
@@ -890,25 +837,25 @@ done: \"I am done\""
890
837
 
891
838
  def test_create_nodes_from_folder_with_defaults
892
839
  login(:tiger)
893
- parent = secure!(Project) { Project.create(:node_name => 'import', :parent_id => nodes_id(:zena), :rgroup_id => groups_id(:managers), :wgroup_id => groups_id(:managers)) }
840
+ parent = secure!(Project) { Project.create(:title => 'import', :parent_id => nodes_id(:zena), :rgroup_id => groups_id(:managers), :wgroup_id => groups_id(:managers)) }
894
841
  assert !parent.new_record?, "Not a new record"
895
- result = secure!(Node) { Node.create_nodes_from_folder(:folder => File.join(Zena::ROOT, 'test', 'fixtures', 'import'), :parent_id => parent[:id] )}.values
842
+ result = secure!(Node) { Node.create_nodes_from_folder(:folder => File.join(Zena::ROOT, 'test', 'fixtures', 'import'), :parent_id => parent.id )}.values
896
843
  assert_equal 4, result.size
897
844
 
898
- children = parent.find(:all, 'children order by node_name asc')
845
+ children = parent.find(:all, 'nodes order by title asc')
899
846
  assert_equal 2, children.size
900
- assert_equal 'Photos', children[0].node_name
847
+ assert_equal 'Photos !', children[0].title
901
848
  assert_equal groups_id(:managers), children[0].rgroup_id
902
- assert_equal 'simple', children[1].node_name
849
+ assert_equal 'simple', children[1].title
903
850
  assert_equal groups_id(:managers), children[1].rgroup_id
904
851
 
905
852
  # we use children[1] as parent just to use any empty node
906
853
  result = secure!(Node) { Node.create_nodes_from_folder(:folder => File.join(Zena::ROOT, 'test', 'fixtures', 'import'), :parent_id => children[1][:id], :defaults => { :rgroup_id => groups_id(:public) } )}.values
907
854
  assert_equal 4, result.size
908
855
 
909
- children = children[1].find(:all, 'children order by node_name ASC')
856
+ children = children[1].find(:all, 'nodes order by title ASC')
910
857
  assert_equal 2, children.size
911
- assert_equal 'Photos', children[0].node_name
858
+ assert_equal 'Photos !', children[0].title
912
859
  assert_equal groups_id(:public), children[0].rgroup_id
913
860
  end
914
861
 
@@ -923,55 +870,85 @@ done: \"I am done\""
923
870
 
924
871
  def test_create_nodes_from_archive
925
872
  login(:tiger)
926
- res = secure!(Node) { Node.create_nodes_from_folder(:archive => uploaded_archive('import.tgz'), :parent_id => nodes_id(:zena)) }.values
927
- photos = secure!(Section) { Section.find_by_node_name('Photos') }
873
+ res = secure(Node) { Node.create_nodes_from_folder(:archive => uploaded_archive('import.tgz'), :parent_id => nodes_id(:zena)) }.values
874
+ photos = secure!(Section) { Section.first(:conditions => {:_id => 'Photos !'}) }
928
875
  assert_kind_of Section, photos
929
- bird = secure!(Node) { Node.find_by_parent_id_and_node_name(photos[:id], 'bird') }
876
+ bird = secure!(Node) { Node.find_by_parent_id_and__id(photos[:id], 'bird') }
930
877
  assert_kind_of Image, bird
931
878
  assert_equal 56183, bird.size
932
879
  assert_equal 'Lucy in the sky', bird.text
933
880
  visitor.lang = 'fr'
934
- bird = secure!(Node) { Node.find_by_parent_id_and_node_name(photos[:id], 'bird') }
881
+ bird = secure!(Node) { Node.find_by_parent_id_and__id(photos[:id], 'bird') }
935
882
  assert_equal 'Le septième ciel', bird.text
936
883
  assert_equal 1, bird[:inherit]
937
884
  assert_equal groups_id(:public), bird[:rgroup_id]
938
885
  assert_equal groups_id(:workers), bird[:wgroup_id]
939
886
  assert_equal groups_id(:managers), bird[:dgroup_id]
940
887
 
941
- simple = secure!(Node) { Node.find_by_parent_id_and_node_name(nodes_id(:zena), 'simple') }
888
+ simple = secure!(Node) { Node.find_by_parent_id_and__id(nodes_id(:zena), 'simple') }
942
889
  assert_equal 0, simple[:inherit]
943
890
  assert_equal groups_id(:managers), simple[:rgroup_id]
944
891
  assert_equal groups_id(:managers), simple[:wgroup_id]
945
892
  assert_equal groups_id(:managers), simple[:dgroup_id]
946
893
  end
947
894
 
948
- def test_create_nodes_from_zip_archive
949
- login(:tiger)
950
- res = secure!(Node) { Node.create_nodes_from_folder(:archive => uploaded_zip('letter.zip'), :parent_id => nodes_id(:zena), :class => 'Letter') }.values
951
- res.sort!{|a,b| a.node_name <=> b.node_name}
952
- letter, bird = res[1], res[0]
953
- assert_kind_of Note, letter
954
- assert_equal 'Letter', letter.klass
955
- end
956
-
957
- def test_update_nodes_from_archive
958
- preserving_files('test.host/data') do
959
- bird = node = nil
895
+ context 'With an archive' do
896
+ setup do
960
897
  login(:tiger)
961
- node = secure!(Page) { Page.create(:parent_id => nodes_id(:status), :title => 'Photos', :text => '![]!') }
962
- assert !node.new_record?
963
- assert_nothing_raised { node = secure!(Node) { Node.find_by_path('projects/cleanWater/status/Photos') } }
964
- assert_raise(ActiveRecord::RecordNotFound) { node = secure!(Node) { Node.find_by_path( 'projects/cleanWater/status/Photos/bird') } }
965
- assert_no_match %r{I took during my last vacations}, node.text
966
- v1_id = node.version.id
967
- secure!(Node) { Node.create_nodes_from_folder(:archive => uploaded_archive('import.tgz'), :parent_id => nodes_id(:status)) }
968
- assert_nothing_raised { node = secure!(Node) { Node.find_by_path('projects/cleanWater/status/Photos') } }
969
- assert_nothing_raised { bird = secure!(Node) { Node.find_by_path('projects/cleanWater/status/Photos/bird') } }
970
- assert_match %r{I took during my last vacations}, node.text
971
- assert_equal v1_id, node.version.id
972
- assert_kind_of Image, bird
973
898
  end
974
- end
899
+
900
+ subject do
901
+ secure(Node) { Node.create_nodes_from_folder(
902
+ :archive => uploaded_archive('import.tgz'),
903
+ :parent_id => nodes_id(:status)).values
904
+ }
905
+ end
906
+
907
+ should 'create new entries' do
908
+ assert_difference('Node.count', 4) do
909
+ subject
910
+ end
911
+ end
912
+
913
+ context 'updating existing pages' do
914
+ setup do
915
+ @photos = secure!(Page) { Page.create(:parent_id => nodes_id(:status), :title => 'Photos !', :text => '![]!') }
916
+ end
917
+
918
+ should 'create missing entries' do
919
+ assert_difference('Node.count', 3) do
920
+ subject
921
+ end
922
+ end
923
+
924
+ should 'create entries of correct type' do
925
+ subject
926
+ assert_kind_of Image, secure(Node) { Node.find_by_parent_title_and_kpath(@photos.id, 'bird')}
927
+ end
928
+
929
+ should 'update existing entries' do
930
+ subject
931
+ assert_match %r{I took during my last vacations}, @photos.reload.text
932
+ end
933
+ end # updating existing pages
934
+
935
+ context 'with specified class' do
936
+ subject do
937
+ secure(Node) { Node.create_nodes_from_folder(
938
+ :archive => uploaded_zip('letter.zip'),
939
+ :parent_id => nodes_id(:zena),
940
+ :class => 'Letter').values
941
+ }
942
+ end
943
+
944
+ should 'create with correct vclass' do
945
+ letter = subject.detect {|n| n.title == 'letter'}
946
+ assert_kind_of Note, letter
947
+ assert_equal 'Letter', letter.klass
948
+ end
949
+ end # with instances of vclass
950
+
951
+ end # With an archive
975
952
 
976
953
  def test_to_yaml
977
954
  #test_site('zena')
@@ -982,7 +959,7 @@ done: \"I am done\""
982
959
  assert status.update_attributes_with_transformation(:v_status => Zena::Status[:pub], :text => "This is a \"link\":#{nodes_zip(:projects)}.", :origin => "A picture: !#{nodes_zip(:bird_jpg)}!")
983
960
  yaml = status.to_yaml
984
961
  assert_match %r{text:\s+\"?This is a "link":\(\.\./\.\.\)\.}, yaml
985
- assert_match %r{origin:\s+\"?A picture: !\(\.\./\.\./wiki/bird\)!}, yaml
962
+ assert_match %r{origin:\s+\"?A picture: !\(\.\./\.\./a wiki with Zena/bird\)!}, yaml
986
963
  assert_no_match %r{log_at}, yaml
987
964
  end
988
965
 
@@ -994,24 +971,26 @@ done: \"I am done\""
994
971
  assert_equal Time.gm(2008,10,20,7,53), prop.log_at
995
972
  yaml = prop.to_yaml
996
973
  assert_match %r{text:\s+\"?This is a "link":\(\.\./\.\.\)\.}, yaml
997
- assert_match %r{origin:\s+\"?A picture: !\(\.\./\.\./wiki/bird\)!}, yaml
974
+ assert_match %r{origin:\s+\"?A picture: !\(\.\./\.\./a wiki with Zena/bird\)!}, yaml
998
975
  assert_match %r{log_at:\s+\"?2008-10-20 14:53:00\"?$}, yaml
999
976
  end
1000
977
 
1001
978
  def test_order_position
1002
979
  login(:tiger)
1003
- parent = secure!(Node) { nodes(:cleanWater) }
980
+ parent = secure!(Node) { nodes(:collections) }
981
+ # default sort is position/title
982
+ # ["Art", "News list", "Stranger in the night", "Top menu", "wiki skin"]
1004
983
  children = parent.find(:all, 'children')
1005
- assert_equal 8, children.size
1006
- assert_equal 'bananas', children[0].node_name
1007
- assert_equal 'crocodiles', children[1].node_name
984
+ assert_equal 5, children.size
985
+ assert_equal nodes_id(:art), children[0].id
986
+ assert_equal nodes_id(:news), children[1].id
1008
987
 
1009
- Node.connection.execute "UPDATE nodes SET position = -1.0 WHERE id = #{nodes_id(:water_pdf)}"
1010
- Node.connection.execute "UPDATE nodes SET position = -0.5 WHERE id = #{nodes_id(:lake)}"
988
+ Node.connection.execute "UPDATE nodes SET position = -1.0 WHERE id = #{nodes_id(:menu)}"
989
+ Node.connection.execute "UPDATE nodes SET position = -0.5 WHERE id = #{nodes_id(:strange)}"
1011
990
  children = parent.find(:all, 'children')
1012
- assert_equal 8, children.size
1013
- assert_equal 'water', children[0].node_name
1014
- assert_equal 'lakeAddress', children[1].node_name
991
+ assert_equal 5, children.size
992
+ assert_equal nodes_id(:menu), children[0].id
993
+ assert_equal nodes_id(:strange), children[1].id
1015
994
  end
1016
995
 
1017
996
  def test_plural_relation
@@ -1031,6 +1010,7 @@ done: \"I am done\""
1031
1010
  assert_equal [
1032
1011
  ["Page", "Page"],
1033
1012
  ["  Project", "Project"],
1013
+ ["    Blog", "Blog"],
1034
1014
  ["  Section", "Section"],
1035
1015
  ["    Skin", "Skin"],
1036
1016
  ["  Tag", "Tag"],
@@ -1042,6 +1022,7 @@ done: \"I am done\""
1042
1022
  assert_equal [
1043
1023
  ["Page", "Page"],
1044
1024
  ["  Project", "Project"],
1025
+ ["    Blog", "Blog"],
1045
1026
  ["  Section", "Section"],
1046
1027
  ["    Skin", "Skin"],
1047
1028
  ["  Tag", "Tag"],
@@ -1051,18 +1032,15 @@ done: \"I am done\""
1051
1032
  def test_allowed_change_to_classes
1052
1033
  Node.get_class('Tag')
1053
1034
  node_changes = Node.allowed_change_to_classes.reject{|k| k[/Dummy/]} # In case we are testing after Secure
1054
- assert_equal %w{Node Note Letter Post Page Project Section Skin Tag Reference}, node_changes
1035
+ assert_equal %w{Node Note Letter Post Page Project Blog Section Skin Tag Reference Contact}, node_changes
1055
1036
 
1056
1037
  assert_equal node_changes, Page.allowed_change_to_classes.reject{|k| k[/Dummy/]}
1057
1038
  assert_equal node_changes, Project.allowed_change_to_classes.reject{|k| k[/Dummy/]}
1058
1039
  assert_equal node_changes, Note.allowed_change_to_classes.reject{|k| k[/Dummy/]}
1059
- assert_equal node_changes, Reference.allowed_change_to_classes.reject{|k| k[/Dummy/]}
1060
1040
 
1061
1041
  assert_equal %w{Document TextDocument Template}, Document.allowed_change_to_classes.reject{|k| k[/Dummy/]}
1062
1042
 
1063
1043
  assert_equal ["Image"], Image.allowed_change_to_classes.reject{|k| k[/Dummy/]}
1064
-
1065
- assert_equal ["BaseContact"], BaseContact.allowed_change_to_classes.reject{|k| k[/Dummy/]}
1066
1044
  end
1067
1045
 
1068
1046
  def test_match_one_node_only
@@ -1091,17 +1069,30 @@ done: \"I am done\""
1091
1069
  assert_equal BigDecimal.new("56"), entries[0].value
1092
1070
  end
1093
1071
 
1094
- context 'A class\' native classes hash' do
1095
- should 'be indexed by kpath' do
1096
- assert_equal [], %w{N ND NDI NDT NDTT NN NP NPP NPS NPSS NR NRC NU NUS} - Node.native_classes.keys
1097
- assert_equal [], %w{ND NDI NDT NDTT} - Document.native_classes.keys
1098
- end
1099
-
1100
- should 'should point to real (ruby) sub-classes and self' do
1101
- assert Page.native_classes.values.include?(Page)
1102
- assert Page.native_classes.values.include?(Project)
1103
- assert !Project.native_classes.values.include?(Page)
1104
- end
1072
+ context 'Finding real classes' do
1073
+ context 'by kpath' do
1074
+ should 'find class' do
1075
+ assert_equal Page, Node.native_classes['NP']
1076
+ assert_equal Document, Node.native_classes['ND']
1077
+ assert_equal Image, Node.native_classes['NDI']
1078
+ end
1079
+
1080
+ should 'return nil for vclass kpath' do
1081
+ assert_nil Node.native_classes['NNP']
1082
+ end
1083
+ end # by kpath
1084
+
1085
+ context 'by name' do
1086
+ should 'find class' do
1087
+ assert_equal Page, Node.native_classes_by_name['Page']
1088
+ assert_equal Document, Node.native_classes_by_name['Document']
1089
+ assert_equal Image, Node.native_classes_by_name['Image']
1090
+ end
1091
+
1092
+ should 'return nil for vclass kpath' do
1093
+ assert_nil Node.native_classes['Post']
1094
+ end
1095
+ end # by name
1105
1096
  end
1106
1097
 
1107
1098
  context 'A node' do
@@ -1124,26 +1115,26 @@ done: \"I am done\""
1124
1115
 
1125
1116
  context 'A class (real or virtual)' do
1126
1117
  should 'be found from its kpath' do
1127
- assert_equal Node, Node.get_class_from_kpath('N')
1128
- assert_equal Page, Node.get_class_from_kpath('NP')
1129
- assert_equal Image, Node.get_class_from_kpath('NDI')
1130
- assert_equal roles(:Post), Node.get_class_from_kpath('NNP')
1131
- assert_equal roles(:Letter), Node.get_class_from_kpath('NNL')
1132
- assert_equal TextDocument, Node.get_class_from_kpath('NDT')
1118
+ assert_equal VirtualClass['Node'], VirtualClass.find_by_kpath('N')
1119
+ assert_equal VirtualClass['Page'], VirtualClass.find_by_kpath('NP')
1120
+ assert_equal VirtualClass['Image'], VirtualClass.find_by_kpath('NDI')
1121
+ assert_equal roles(:Post), VirtualClass.find_by_kpath('NNP')
1122
+ assert_equal roles(:Letter), VirtualClass.find_by_kpath('NNL')
1123
+ assert_equal VirtualClass['TextDocument'], VirtualClass.find_by_kpath('NDT')
1133
1124
  end
1134
1125
  end
1135
1126
 
1136
1127
 
1137
1128
  def test_position_on_create
1138
1129
  login(:lion)
1139
- node = secure!(Page) { Page.create(:node_name => "yoba", :parent_id => nodes_id(:cleanWater), :inherit=>1 ) }
1130
+ node = secure!(Page) { Page.create(:title => "yoba", :parent_id => nodes_id(:cleanWater), :inherit=>1 ) }
1140
1131
  assert !node.new_record?
1141
1132
  assert_equal 0.0, node.position
1142
1133
  assert node.update_attributes(:position => 5.0)
1143
1134
  assert_equal 5.0, node.position
1144
1135
  node = secure!(Page) { Page.find_by_id(node.id) } # reload
1145
1136
  assert_equal 5.0, node.position
1146
- node = secure!(Page) { Page.create(:node_name => "babo", :parent_id => nodes_id(:cleanWater), :inherit=>1 ) }
1137
+ node = secure!(Page) { Page.create(:title => "babo", :parent_id => nodes_id(:cleanWater), :inherit=>1 ) }
1147
1138
  assert !node.new_record?
1148
1139
  assert_equal 6.0, node.position
1149
1140
 
@@ -1203,9 +1194,9 @@ done: \"I am done\""
1203
1194
  }
1204
1195
 
1205
1196
  new_attributes = secure(Node) { Node.transform_attributes(attributes) }
1206
- assert_equal Hash['icon_id' => nodes_id(:bird_jpg),
1207
- 'm_title' => 'Changed icon to "bird"',
1208
- 'm_text' => 'By lion'], new_attributes
1197
+ assert_equal Hash['icon_zip' => nodes_zip(:bird_jpg).to_s,
1198
+ 'm_title' => 'Changed icon to "bird"',
1199
+ 'm_text' => 'By lion'], new_attributes
1209
1200
 
1210
1201
  assert node.update_attributes_with_transformation(attributes)
1211
1202
  assert_equal nodes_id(:bird_jpg), node.find(:first, 'icon')[:id]
@@ -1218,19 +1209,19 @@ done: \"I am done\""
1218
1209
  FileUtils::mkpath(export_folder)
1219
1210
  # Add a page and a text document into 'wiki'
1220
1211
  assert secure!(Node) { Node.create(:title=>"Hello World!", :text => "Bonjour", :parent_id => nodes_id(:wiki), :inherit=>1 ) }
1221
- assert secure!(TextDocument) { TextDocument.create(:node_name => "yoba", :parent_id => nodes_id(:wiki), :text => "#header { color:red; }\n#footer { color:blue; }", :content_type => 'text/css') }
1212
+ assert secure!(TextDocument) { TextDocument.create(:title => "yoba", :parent_id => nodes_id(:wiki), :text => "#header { color:red; }\n#footer { color:blue; }", :content_type => 'text/css') }
1222
1213
  wiki = secure!(Node) { nodes(:wiki) }
1223
1214
  assert_equal 4, wiki.find(:all, "children").size
1224
1215
  wiki.export_to_folder(export_folder)
1225
- assert File.exist?(File.join(export_folder, 'wiki.zml'))
1226
- assert File.exist?(File.join(export_folder, 'wiki'))
1227
- assert File.exist?(File.join(export_folder, 'wiki', 'bird.jpg'))
1228
- assert !File.exist?(File.join(export_folder, 'wiki', 'bird.zml'))
1229
- assert File.exist?(File.join(export_folder, 'wiki', 'flower.jpg'))
1230
- assert !File.exist?(File.join(export_folder, 'wiki', 'flower.zml'))
1231
- assert File.exist?(File.join(export_folder, 'wiki', 'yoba.css'))
1232
- assert !File.exist?(File.join(export_folder, 'wiki', 'yoba.zml'))
1233
- assert File.exist?(File.join(export_folder, 'wiki', 'HelloWorld.zml'))
1216
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena.zml'))
1217
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena'))
1218
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena', 'bird.jpg'))
1219
+ assert !File.exist?(File.join(export_folder, 'a wiki with Zena', 'bird.zml'))
1220
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena', 'flower.jpg'))
1221
+ assert !File.exist?(File.join(export_folder, 'a wiki with Zena', 'flower.zml'))
1222
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena', 'yoba.css'))
1223
+ assert !File.exist?(File.join(export_folder, 'a wiki with Zena', 'yoba.zml'))
1224
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena', 'Hello World!.zml'.to_filename))
1234
1225
  end
1235
1226
  end
1236
1227
 
@@ -1241,20 +1232,20 @@ done: \"I am done\""
1241
1232
  FileUtils::mkpath(export_folder)
1242
1233
  # Add a page and a text document into 'wiki'
1243
1234
  assert secure!(Node) { Node.create(:title=>"Hello World!", :text => "Bonjour", :parent_id => nodes_id(:wiki), :inherit=>1 ) }
1244
- assert secure!(TextDocument) { TextDocument.create(:node_name => "yoba", :parent_id => nodes_id(:wiki), :text => "#header { color:red; }\n#footer { color:blue; }", :content_type => 'text/css') }
1235
+ assert secure!(TextDocument) { TextDocument.create(:title => "yoba", :parent_id => nodes_id(:wiki), :text => "#header { color:red; }\n#footer { color:blue; }", :content_type => 'text/css') }
1245
1236
  wiki = secure!(Node) { nodes(:wiki) }
1246
1237
  assert_equal 4, wiki.find(:all, "children").size
1247
1238
  archive = wiki.archive
1248
1239
  `tar -C '#{export_folder}' -xz < '#{archive.path}'`
1249
- assert File.exist?(File.join(export_folder, 'wiki.zml'))
1250
- assert File.exist?(File.join(export_folder, 'wiki'))
1251
- assert File.exist?(File.join(export_folder, 'wiki', 'bird.jpg'))
1252
- assert !File.exist?(File.join(export_folder, 'wiki', 'bird.zml'))
1253
- assert File.exist?(File.join(export_folder, 'wiki', 'flower.jpg'))
1254
- assert !File.exist?(File.join(export_folder, 'wiki', 'flower.zml'))
1255
- assert File.exist?(File.join(export_folder, 'wiki', 'yoba.css'))
1256
- assert !File.exist?(File.join(export_folder, 'wiki', 'yoba.zml'))
1257
- assert File.exist?(File.join(export_folder, 'wiki', 'HelloWorld.zml'))
1240
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena.zml'))
1241
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena'))
1242
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena', 'bird.jpg'))
1243
+ assert !File.exist?(File.join(export_folder, 'a wiki with Zena', 'bird.zml'))
1244
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena', 'flower.jpg'))
1245
+ assert !File.exist?(File.join(export_folder, 'a wiki with Zena', 'flower.zml'))
1246
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena', 'yoba.css'))
1247
+ assert !File.exist?(File.join(export_folder, 'a wiki with Zena', 'yoba.zml'))
1248
+ assert File.exist?(File.join(export_folder, 'a wiki with Zena', 'Hello World!.zml'.to_filename))
1258
1249
  end
1259
1250
  end
1260
1251
 
@@ -1270,18 +1261,22 @@ done: \"I am done\""
1270
1261
 
1271
1262
  def test_translate_pseudo_id_path
1272
1263
  login(:lion)
1273
- lion = secure!(Node) { nodes(:lion) }
1274
- people = secure!(Node) { nodes(:people) }
1275
- cleanWater = secure!(Node) { nodes(:cleanWater) }
1276
- assert lion.update_attributes(:title => 'status', :v_status => Zena::Status[:pub])
1277
- assert_equal 'people/status', lion.fullpath
1264
+ art = secure(Node) { nodes(:art) }
1265
+ collections = secure(Node) { nodes(:collections) }
1266
+ cleanWater = secure(Node) { nodes(:cleanWater) }
1267
+
1268
+ assert art.update_attributes(:title => 'status title', :v_status => Zena::Status[:pub])
1269
+
1270
+ assert_equal 'Collections/status title', art.fullpath_as_title.join('/')
1271
+
1278
1272
  # path base_node
1279
- { ['(/projects/cleanWater/status)', nil] => nodes_id(:status),
1280
- ['(/projects/cleanWater/status)', people] => nodes_id(:status),
1281
- ['(status)', people] => nodes_id(:lion),
1282
- ['(status)', cleanWater] => nodes_id(:status),
1283
- }.each do |k,v|
1284
- assert_equal v, secure(Node) { Node.translate_pseudo_id(k[0],:id,k[1]) }, "'#{k.inspect}' should translate to '#{v}'"
1273
+ { ['(/projects list/Clean Water project/status title)', nil] => nodes_id(:status),
1274
+ ['(/projects list/Clean Water project/status title)', collections] => nodes_id(:status),
1275
+ ['(status title)', collections] => nodes_id(:art),
1276
+ ['(status title)', cleanWater] => nodes_id(:status),
1277
+ }.each do |k, v|
1278
+ assert_equal v, secure(Node) { Node.translate_pseudo_id(k[0],:id,k[1]) }, "'#{k[0]}' in '#{k[1] ? k[1].title : 'nil
1279
+ '}' should translate to '#{v}'"
1285
1280
  end
1286
1281
  end
1287
1282
 
@@ -1289,13 +1284,13 @@ done: \"I am done\""
1289
1284
  login(:lion)
1290
1285
  @node = secure!(Node) { nodes(:status) }
1291
1286
  assert @node.update_attributes(:text => "Hello this is \"art\":#{nodes_zip(:art)}. !#{nodes_zip(:bird_jpg)}!")
1292
- assert_equal "Hello this is \"art\":(../../../collections/art). !(../../wiki/bird)!", @node.unparse_assets(@node.text, self, 'text')
1287
+ assert_equal "Hello this is \"art\":(../../../Collections/Art). !(../../a wiki with Zena/bird)!", @node.unparse_assets(@node.text, self, 'text')
1293
1288
  end
1294
1289
 
1295
1290
  def test_parse_assets
1296
1291
  login(:lion)
1297
1292
  @node = secure!(Node) { nodes(:status) }
1298
- assert @node.update_attributes(:text => "Hello this is \"art\":(../../../collections/art).")
1293
+ assert @node.update_attributes(:text => "Hello this is \"art\":(../../../Collections/Art).")
1299
1294
  assert_equal "Hello this is \"art\":#{nodes_zip(:art)}.", @node.parse_assets(@node.text, self, 'text')
1300
1295
  end
1301
1296
 
@@ -1303,7 +1298,7 @@ done: \"I am done\""
1303
1298
  context 'for safe methods in class' do
1304
1299
  should 'return method name' do
1305
1300
  ['m_text', 'inherit', 'l_status', 'l_comment', 'm_text', 'inherit', 'v_status'].each do |k|
1306
- assert_equal k, BaseContact.safe_method_type([k])[:method]
1301
+ assert_equal k, Page.safe_method_type([k])[:method]
1307
1302
  end
1308
1303
  end
1309
1304
  end
@@ -1311,29 +1306,29 @@ done: \"I am done\""
1311
1306
  context 'for methods not declared as safe in the class' do
1312
1307
  should 'return nil' do
1313
1308
  ['puts', 'raise', 'blah', 'system'].each do |k|
1314
- assert_nil BaseContact.safe_method_type([k])
1309
+ assert_nil Page.safe_method_type([k])
1315
1310
  end
1316
1311
  end
1317
1312
  end
1318
1313
 
1319
1314
  context 'for id' do
1320
1315
  should 'return zip' do
1321
- assert_equal Hash[:class=>Number, :method=>'zip'], BaseContact.safe_method_type(['id'])
1316
+ assert_equal Hash[:class=>Number, :method=>'zip'], Page.safe_method_type(['id'])
1322
1317
  end
1323
1318
  end
1324
1319
 
1325
1320
  context 'for relation pseudo-methods' do
1326
1321
  should 'use rel and try' do
1327
1322
  ['hot_status', 'blah_comment', 'blah_zips', 'blah_id', 'blah_ids'].each do |k|
1328
- assert_match %r{rel\[.#{k.gsub(/_.+/,'')}.\]\.try}, BaseContact.safe_method_type([k])[:method]
1323
+ assert_match %r{rel\[.#{k.gsub(/_.+/,'')}.\]\.try}, Page.safe_method_type([k])[:method]
1329
1324
  end
1330
1325
  end
1331
1326
  end
1332
1327
 
1333
1328
  context 'for safe properties' do
1334
1329
  should 'return version and method name when safe' do
1335
- ['text', 'title', 'first_name', 'name'].each do |k|
1336
- assert_equal "prop['#{k}']", BaseContact.safe_method_type([k])[:method]
1330
+ ['text', 'title'].each do |k|
1331
+ assert_equal "prop['#{k}']", Page.safe_method_type([k])[:method]
1337
1332
  end
1338
1333
  end
1339
1334
 
@@ -1421,30 +1416,22 @@ done: \"I am done\""
1421
1416
  login(:tiger)
1422
1417
  end
1423
1418
 
1424
- should 'parse pseudo_ids in parent_id' do
1425
- assert_transforms Hash['parent_id' => nodes_id(:lake_jpg)],
1426
- Hash['parent_id' => 'lake+']
1419
+ should 'transform parent_id to parent_zip' do
1420
+ assert_transforms Hash['parent_zip' => 'lake+'],
1421
+ Hash['parent_id' => 'lake+']
1422
+ # nodes_id(:lake_jpg)
1427
1423
  end
1428
1424
 
1429
- should 'parse pseudo_ids in links' do
1430
- assert_transforms Hash['tag_ids' => [nodes_id(:art), nodes_id(:news)]],
1425
+ should 'transform link ids to zip' do
1426
+ assert_transforms Hash['tag_zips' => %w{33 news}],
1431
1427
  Hash['tag_ids' => '33,news']
1432
- end
1433
-
1434
- should 'leave single bad ids' do
1435
- assert_transforms Hash['parent_id' => '999', 'hot_id' => '999'],
1436
- Hash['parent_id' => '999', 'hot_id' => '999']
1437
- end
1438
-
1439
- should 'remove bad values from id lists' do
1440
- assert_transforms Hash['tag_ids' => [nodes_id(:news),nodes_id(:art)]],
1441
- Hash['tag_ids' => '999,34,art']
1428
+ # [nodes_id(:art), nodes_id(:news)]
1442
1429
  end
1443
1430
 
1444
1431
  should 'parse dates and ids in rel' do
1445
1432
  # this should be 14:58 when #255 is fixed (tz support).
1446
- assert_transforms Hash['link' => {'hot' => {'other_id' => nodes_id(:status), 'date' => Time.gm(2009,7,15,16,58)}}],
1447
- Hash['link' => {'hot' => {'other_id' => '22', 'date' => '2009-7-15 16:58' }}]
1433
+ assert_transforms Hash['link' => {'hot' => {'other_zip' => '22', 'date' => Time.gm(2009,7,15,16,58)}}],
1434
+ Hash['link' => {'hot' => {'other_id' => '22', 'date' => '2009-7-15 16:58' }}]
1448
1435
  end
1449
1436
  end # with ids
1450
1437
  end # Transforming attributes