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.
- data/History.txt +29 -0
- data/Rakefile +2 -0
- data/TODO_ZENA_1_0 +13 -23
- data/app/controllers/columns_controller.rb +1 -1
- data/app/controllers/comments_controller.rb +4 -3
- data/app/controllers/documents_controller.rb +8 -11
- data/app/controllers/nodes_controller.rb +39 -21
- data/app/controllers/users_controller.rb +8 -3
- data/app/controllers/versions_controller.rb +2 -2
- data/app/controllers/virtual_classes_controller.rb +17 -11
- data/app/helpers/documents_helper.rb +0 -3
- data/app/helpers/users_helper.rb +17 -0
- data/app/models/cache.rb +36 -31
- data/app/models/column.rb +48 -5
- data/app/models/comment.rb +14 -5
- data/app/models/data_entry.rb +2 -2
- data/app/models/document.rb +23 -33
- data/app/models/idx_nodes_datetime.rb +4 -0
- data/app/models/idx_nodes_float.rb +4 -0
- data/app/models/idx_project.rb +3 -0
- data/app/models/node.rb +372 -308
- data/app/models/page.rb +1 -31
- data/app/models/relation.rb +4 -4
- data/app/models/relation_proxy.rb +128 -17
- data/app/models/role.rb +27 -2
- data/app/models/site.rb +64 -56
- data/app/models/template.rb +11 -12
- data/app/models/text_document.rb +6 -7
- data/app/models/user.rb +95 -46
- data/app/models/version.rb +2 -2
- data/app/models/virtual_class.rb +418 -73
- data/app/views/columns/_form.html.erb +1 -1
- data/app/views/columns/_li.html.erb +1 -1
- data/app/views/comments/_form.rhtml +1 -1
- data/app/views/comments/_li.rhtml +1 -1
- data/app/views/comments/_li_simple.rhtml +1 -1
- data/app/views/groups/_form.rhtml +1 -1
- data/app/views/links/_li.rhtml +1 -1
- data/app/views/nodes/_groups.rhtml +1 -1
- data/app/views/nodes/_import_results.rhtml +1 -1
- data/app/views/nodes/_parent.rhtml +1 -1
- data/app/views/nodes/_results.rhtml +1 -1
- data/app/views/nodes/create.rjs +4 -2
- data/app/views/relations/_li.erb +2 -2
- data/app/views/templates/document_create_tabs/_file.rhtml +1 -1
- data/app/views/templates/document_create_tabs/_template.rhtml +2 -2
- data/app/views/templates/document_create_tabs/_text_document.rhtml +2 -2
- data/app/views/templates/edit_tabs/_help.rhtml +1 -1
- data/app/views/templates/edit_tabs/_title.rhtml +0 -3
- data/app/views/users/_form.rhtml +2 -6
- data/app/views/users/_li.rhtml +1 -3
- data/app/views/users/create.rjs +4 -4
- data/app/views/users/preferences.html.erb +1 -4
- data/app/views/versions/custom_tab.rhtml +5 -0
- data/app/views/virtual_classes/_form.erb +20 -10
- data/app/views/virtual_classes/_li.erb +21 -8
- data/app/views/zafu/default/Node-+search.zafu +1 -1
- data/app/views/zafu/default/Node.zafu +3 -3
- data/bricks/captcha/lib/bricks/captcha.rb +1 -1
- data/bricks/mongrel/zena/deploy.rb +14 -0
- data/bricks/{data2pdf → pdf}/.document +0 -0
- data/bricks/pdf/README +33 -0
- data/bricks/{data2pdf → pdf}/Rakefile +0 -0
- data/bricks/pdf/VERSION +1 -0
- data/bricks/pdf/lib/bricks/pdf.rb +110 -0
- data/bricks/pdf/lib/bricks/pdf/engine/prince.rb +38 -0
- data/bricks/pdf/lib/bricks/pdf/engine/xhtml2pdf.rb +9 -0
- data/bricks/pdf/lib/bricks/pdf/install.rb +121 -0
- data/bricks/pdf/test/engines/test_prince.rb +15 -0
- data/bricks/pdf/test/engines/test_xhtml2pdf.rb +15 -0
- data/bricks/{data2pdf → pdf}/test/fixtures/application.css +0 -0
- data/bricks/{data2pdf → pdf}/test/fixtures/contact.html +0 -0
- data/bricks/{data2pdf → pdf}/test/fixtures/pisa-default.css +0 -0
- data/bricks/{data2pdf → pdf}/test/fixtures/sheet1.css +0 -0
- data/bricks/{data2pdf → pdf}/test/fixtures/sheet2.css +0 -0
- data/bricks/{data2pdf → pdf}/test/fixtures/simple-html.html +0 -0
- data/bricks/{data2pdf → pdf}/test/fixtures/simple-text.txt +0 -0
- data/bricks/{data2pdf → pdf}/test/helper.rb +4 -5
- data/bricks/pdf/test/shoulda_macros/shoulda_pdf.rb +72 -0
- data/bricks/pdf/zena/init.rb +5 -0
- data/bricks/pdf/zena/tasks.rb +17 -0
- data/bricks/sphinx/lib/{use_sphinx.rb → bricks/sphinx.rb} +1 -1
- data/bricks/tags/zena/init.rb +2 -2
- data/bricks/tags/zena/test/zafu/tags.yml +4 -4
- data/bricks/zena/zena/migrate/01_base.rb +482 -0
- data/config/bricks.yml +22 -6
- data/config/gems.yml +8 -6
- data/db/20100628074512_zena0x_to1x.rb +6 -1
- data/db/fix/024_correct_vclass_kpath.rb +11 -0
- data/db/fix/025_move_tag_into_vclass.rb +13 -0
- data/db/{migrate → fix}/026_rename_templates.rb +0 -0
- data/db/{migrate → fix}/045_avoid_star_in_templates.rb +0 -0
- data/db/{migrate → fix}/046_fix_zazen_image_tag.rb +0 -0
- data/db/{migrate → fix}/047_change_default_link_id_to_zero.rb +1 -3
- data/db/{migrate → fix}/049_fix_publish_from_is_null.rb +0 -0
- data/db/{migrate → fix}/20090924141459_zafu_fix_sept09.rb +0 -0
- data/db/{migrate → fix}/20091013100351_rename_publish_group_to_drive_group.rb +1 -3
- data/db/{migrate → fix}/20091124161608_rebuild_fullpath.rb +0 -1
- data/db/{migrate → fix}/20100115134729_rebuild_fullpath_after_fix.rb +0 -0
- data/db/{migrate → fix}/20100526090140_renamed_contact_model_to_base_contact.rb +2 -4
- data/db/{migrate → fix/old_migrations}/001_create_base.rb +0 -1
- data/db/{migrate → fix/old_migrations}/002_add_time_zone_to_users.rb +0 -0
- data/db/{migrate → fix/old_migrations}/003_add_custom_base_flag.rb +0 -0
- data/db/{migrate → fix/old_migrations}/004_rename_template_skin.rb +0 -0
- data/db/{migrate → fix/old_migrations}/005_create_cached_pages.rb +0 -0
- data/db/{migrate → fix/old_migrations}/006_create_sites.rb +0 -0
- data/db/{migrate → fix/old_migrations}/007_replace_id_by_zip.rb +0 -0
- data/db/{migrate → fix/old_migrations}/008_user_status.rb +0 -0
- data/db/{migrate → fix/old_migrations}/009_fulltext.rb +0 -0
- data/db/fix/old_migrations/010_create_template_content.rb +17 -0
- data/db/{migrate → fix/old_migrations}/011_project_to_section.rb +0 -0
- data/db/{migrate → fix/old_migrations}/012_add_project_id.rb +0 -0
- data/db/{migrate → fix/old_migrations}/013_remove_defaults.rb +0 -0
- data/db/{migrate → fix/old_migrations}/014_add_sort_field.rb +0 -0
- data/db/{migrate → fix/old_migrations}/015_add_dyn_attributes.rb +0 -0
- data/db/{migrate → fix/old_migrations}/016_remove_translations.rb +0 -0
- data/db/{migrate → fix/old_migrations}/017_rename_authorize.rb +0 -0
- data/db/{migrate → fix/old_migrations}/018_add_auth_option.rb +0 -0
- data/db/{migrate → fix/old_migrations}/019_remove_user_status.rb +0 -0
- data/db/{migrate → fix/old_migrations}/020_create_participation.rb +0 -0
- data/db/{migrate → fix/old_migrations}/021_create_relations.rb +0 -0
- data/db/{migrate → fix/old_migrations}/022_create_virtual_classes.rb +0 -0
- data/db/{migrate → fix/old_migrations}/023_ip_on_anonymous_comment.rb +0 -0
- data/db/{migrate → fix/old_migrations}/027_add_country_to_contacts.rb +0 -0
- data/db/{migrate → fix/old_migrations}/028_change_size_of_conten_type_field.rb +0 -0
- data/db/{migrate → fix/old_migrations}/029_create_data_entries.rb +0 -0
- data/db/{migrate → fix/old_migrations}/030_redit_auto_publish_site_settings.rb +0 -0
- data/db/{migrate → fix/old_migrations}/031_create_iformats.rb +0 -0
- data/db/{migrate → fix/old_migrations}/032_caches_context_as_hash.rb +0 -0
- data/db/{migrate → fix/old_migrations}/033_documents_kpath_change.rb +0 -0
- data/db/{migrate → fix/old_migrations}/034_change_file_storage.rb +0 -0
- data/db/{migrate → fix/old_migrations}/035_add_status_to_link.rb +0 -0
- data/db/{migrate → fix/old_migrations}/036_add_flag_fields_on_nodes.rb +0 -0
- data/db/{migrate → fix/old_migrations}/037_add_auto_create_discussion_to_v_class.rb +0 -0
- data/db/{migrate → fix/old_migrations}/038_create_site_attributes.rb +0 -0
- data/db/{migrate → fix/old_migrations}/039_default_position.rb +0 -0
- data/db/{migrate → fix/old_migrations}/040_second_value_for_data_entry.rb +0 -0
- data/db/{migrate → fix/old_migrations}/041_add_attributes_to_v_class.rb +0 -0
- data/db/{migrate → fix/old_migrations}/042_fix_position_should_be_float.rb +0 -0
- data/db/{migrate → fix/old_migrations}/043_move_user_lang_into_participation.rb +0 -0
- data/db/{migrate → fix/old_migrations}/044_remove_monolingual_site_option.rb +0 -0
- data/db/{migrate → fix/old_migrations}/048_link_source_target_can_be_null.rb +0 -0
- data/db/{migrate → fix/old_migrations}/050_date_in_links.rb +0 -0
- data/db/{migrate → fix/old_migrations}/051_add_exif_tags_to_images.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20090825201159_insert_zero_link.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20090825201200_merge_bricks_migrations_with_std_migrations.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20090927125912_allow_null_in_text_fields.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20090928133440_no_more_private_nodes.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20090928143754_version_status_change.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20091001084025_change_status_values_for_comments.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20091009084057_add_vhash_in_node.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20091014130833_fix_template_title.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20091014183726_merge_participation_into_users.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20091018200734_add_popup_info_to_image_format.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20091026161708_add_persistence_token.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20091101184952_add_session_table.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20091123175137_add_single_access_token.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100125062254_add_dynamo_to_version.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100201133242_remove_default_status_on_version.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100208194210_create_attachments.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100210112319_change_dynamo_to_property.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100320145726_transform_template_contents_into_index.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100328125634_change_skin_name_to_id.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100417061257_add_properties_to_sites.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100419163149_rename_name_to_node_name.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100422091606_change_v_class_table_into_roles.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100422094048_node_habtm_roles.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100422115935_create_columns.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100513181529_add_site_id_to_columns.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100519091711_add_index_definition_to_columns.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100519091940_create_idx_nodes_string.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100519232432_create_idx_nodes_ml_string.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100525113858_add_porperties_to_users.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100527130937_change_column_index_to_string.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100531135128_add_fulltext_builder_fields.rb +0 -0
- data/db/{migrate → fix/old_migrations}/20100915062903_add_api_group_id_to_site.rb +0 -0
- data/db/fix/old_migrations/20100923154807_remove_base_contact.rb +84 -0
- data/db/fix/old_migrations/20100926192223_remove_su_user.rb +8 -0
- data/db/fix/old_migrations/20100927141658_add_eval_attributes_to_v_class.rb +12 -0
- data/db/fix/old_migrations/20100928185257_add_obvious_idx.rb +52 -0
- data/db/fix/old_migrations/20100929143111_remove_node_name.rb +11 -0
- data/db/fix/old_migrations/20101006090454_store_properties_in_long_text.rb +9 -0
- data/db/fix/old_migrations/20101014185753_remove_user_prototype_id.rb +9 -0
- data/db/fix/old_migrations/20101101084318_create_scope_index.rb +35 -0
- data/db/fix/old_migrations/20101109074232_create_idx_nodes_tables.rb +65 -0
- data/db/fix/old_migrations/20101110184235_add_role_update_to_site.rb +9 -0
- data/db/fix/old_migrations/20101116103920_change_scope_index.rb +31 -0
- data/db/fix/old_migrations/20101123125822_add_integer_idx.rb +17 -0
- data/db/fix/old_migrations/20101130134522_add_index_field.rb +13 -0
- data/db/fix/old_migrations/20101213133816_add_group_to_relation.rb +9 -0
- data/db/init/base/help.fr.zml +1 -1
- data/db/init/base/skins/default.zml +0 -1
- data/db/init/base/skins/default/Node-+search.zafu +1 -1
- data/db/init/base/skins/default/Node-tree.zafu +3 -3
- data/db/init/base/skins/default/Node.zafu +3 -3
- data/lib/bricks/loader.rb +4 -1
- data/lib/bricks/requirements_validation.rb +11 -6
- data/lib/log_recorder/lib/log_recorder.rb +2 -2
- data/lib/tasks/zena.rake +25 -15
- data/lib/zena.rb +42 -9
- data/lib/zena/acts/enrollable.rb +81 -99
- data/lib/zena/acts/secure.rb +27 -23
- data/lib/zena/acts/secure_node.rb +10 -55
- data/lib/zena/acts/serializable.rb +9 -10
- data/lib/zena/app.rb +0 -2
- data/lib/zena/code_syntax.rb +1 -1
- data/lib/zena/controller/test_case.rb +0 -5
- data/lib/zena/core_ext/string.rb +48 -20
- data/lib/zena/db.rb +10 -442
- data/lib/zena/db_helper/abstract_db.rb +184 -0
- data/lib/zena/db_helper/mysql.rb +150 -0
- data/lib/zena/db_helper/postgresql.rb +79 -0
- data/lib/zena/db_helper/sqlite3.rb +135 -0
- data/lib/zena/deploy.rb +4 -1
- data/lib/zena/deploy/httpd.rhtml +3 -3
- data/lib/zena/deploy/vhost.rhtml +1 -1
- data/lib/zena/foxy_parser.rb +37 -18
- data/lib/zena/info.rb +3 -13
- data/lib/zena/migrator.rb +0 -1
- data/lib/zena/parser/zafu_rules.rb +9 -4
- data/lib/zena/parser/zazen_rules.rb +5 -5
- data/lib/zena/parser/zena_rules.rb +1 -1
- data/lib/zena/remote/interface.rb +1 -1
- data/lib/zena/site_worker.rb +3 -3
- data/lib/zena/test_controller.rb +10 -10
- data/lib/zena/use/action.rb +66 -6
- data/lib/zena/use/ajax.rb +39 -13
- data/lib/zena/use/ancestry.rb +210 -0
- data/lib/zena/use/authlogic.rb +30 -1
- data/lib/zena/use/calendar.rb +158 -0
- data/lib/zena/use/conditional.rb +3 -2
- data/lib/zena/use/context.rb +42 -12
- data/lib/zena/use/dates.rb +15 -14
- data/lib/zena/use/display.rb +54 -7
- data/lib/zena/use/error_rendering.rb +1 -0
- data/lib/zena/use/field_index.rb +20 -0
- data/lib/zena/use/fixtures.rb +12 -9
- data/lib/zena/use/forms.rb +230 -106
- data/lib/zena/use/fulltext.rb +28 -14
- data/lib/zena/use/html_tags.rb +1 -24
- data/lib/zena/use/i18n.rb +69 -14
- data/lib/zena/use/kpath.rb +60 -0
- data/lib/zena/use/ml_index.rb +6 -4
- data/lib/zena/use/node_context.rb +63 -0
- data/lib/zena/use/prop_eval.rb +90 -0
- data/lib/zena/use/query_builder.rb +159 -29
- data/lib/zena/use/query_comment.rb +1 -1
- data/lib/zena/use/query_node.rb +147 -56
- data/lib/zena/use/recursion.rb +2 -2
- data/lib/zena/use/relations.rb +31 -19
- data/lib/zena/use/rendering.rb +111 -121
- data/lib/zena/use/scope_index.rb +230 -0
- data/lib/zena/use/search.rb +7 -7
- data/lib/zena/use/urls.rb +87 -25
- data/lib/zena/use/version_hash.rb +113 -113
- data/lib/zena/use/workflow.rb +5 -1
- data/lib/zena/use/zafu_attributes.rb +11 -14
- data/lib/zena/use/zafu_eval.rb +1 -1
- data/lib/zena/use/zafu_safe_definitions.rb +91 -9
- data/lib/zena/use/zafu_templates.rb +146 -102
- data/lib/zena/use/zazen.rb +5 -4
- data/lib/zena/zafu_compiler.rb +1 -0
- data/locale/en/LC_MESSAGES/zena.mo +0 -0
- data/locale/en/zena.po +0 -1
- data/locale/fr/LC_MESSAGES/zena.mo +0 -0
- data/locale/fr/zena.mo +0 -0
- data/locale/fr/zena.po +4 -4
- data/misc/zena +35 -0
- data/misc/zena_init +41 -0
- data/public/images/ext/{basecontact.png → contact.png} +0 -0
- data/public/javascripts/zena.js +35 -7
- data/public/stylesheets/admin.css +5 -2
- data/public/stylesheets/default.css +2 -1
- data/public/stylesheets/popup.css +1 -1
- data/public/stylesheets/zena.css +2 -2
- data/test/custom_queries/complex.host.yml +12 -5
- data/test/fixtures/files/Node-test.zafu +3 -3
- data/test/fixtures/files/translations_fr.yml +4 -2
- data/test/functional/documents_controller_test.rb +31 -0
- data/test/functional/nodes_controller_commit_test.rb +1 -5
- data/test/functional/nodes_controller_test.rb +92 -12
- data/test/functional/user_sessions_controller_test.rb +2 -2
- data/test/functional/users_controller_test.rb +31 -29
- data/test/functional/versions_controller_test.rb +2 -2
- data/test/functional/virtual_classes_controller_test.rb +2 -2
- data/test/integration/multiple_hosts_test.rb +19 -8
- data/test/integration/navigation_test.rb +91 -12
- data/test/integration/query_node/basic.yml +40 -37
- data/test/integration/query_node/complex.yml +23 -18
- data/test/integration/query_node/dates.yml +3 -3
- data/test/integration/query_node/errors.yml +7 -1
- data/test/integration/query_node/filters.yml +41 -35
- data/test/integration/query_node/idx_fields.yml +11 -0
- data/test/integration/query_node/idx_key_value.yml +77 -0
- data/test/integration/query_node/idx_scope.yml +33 -0
- data/test/integration/query_node/relations.yml +13 -13
- data/test/integration/query_node_test.rb +6 -10
- data/test/integration/zafu_compiler/action.yml +19 -6
- data/test/integration/zafu_compiler/ajax.yml +111 -51
- data/test/integration/zafu_compiler/apphelper.yml +1 -1
- data/test/integration/zafu_compiler/asset.yml +1 -1
- data/test/integration/zafu_compiler/basic.yml +42 -52
- data/test/integration/zafu_compiler/calendar.yml +3 -3
- data/test/integration/zafu_compiler/complex.yml +16 -16
- data/test/integration/zafu_compiler/complex_ok.yml +2 -2
- data/test/integration/zafu_compiler/conditional.yml +42 -33
- data/test/integration/zafu_compiler/data.yml +3 -3
- data/test/integration/zafu_compiler/dates.yml +25 -10
- data/test/integration/zafu_compiler/display.yml +49 -12
- data/test/integration/zafu_compiler/errors.yml +26 -6
- data/test/integration/zafu_compiler/eval.yml +4 -4
- data/test/integration/zafu_compiler/forms.yml +89 -15
- data/test/integration/zafu_compiler/i18n.yml +23 -18
- data/test/integration/zafu_compiler/idx_scope.yml +7 -0
- data/test/integration/zafu_compiler/later.yml +10 -16
- data/test/integration/zafu_compiler/off/off.yml +2 -2
- data/test/integration/zafu_compiler/query.yml +207 -0
- data/test/integration/zafu_compiler/recursion.yml +2 -2
- data/test/integration/zafu_compiler/relations.yml +144 -168
- data/test/integration/zafu_compiler/roles.yml +86 -10
- data/test/integration/zafu_compiler/rubyless.yml +49 -6
- data/test/integration/zafu_compiler/safe_definitions.yml +35 -6
- data/test/integration/zafu_compiler/search.yml +1 -1
- data/test/integration/zafu_compiler/security.yml +37 -0
- data/test/integration/zafu_compiler/urls.yml +50 -40
- data/test/integration/zafu_compiler/user.yml +21 -6
- data/test/integration/zafu_compiler/version.yml +6 -6
- data/test/integration/zafu_compiler/zafu_attributes.yml +43 -34
- data/test/integration/zafu_compiler/zazen.yml +10 -10
- data/test/integration/zafu_compiler_test.rb +19 -13
- data/test/sites/complex/nodes.yml +0 -2
- data/test/sites/complex/roles.yml +9 -1
- data/test/sites/complex/sites.yml +0 -1
- data/test/sites/complex/users.yml +2 -5
- data/test/sites/ocean/nodes.yml +2 -5
- data/test/sites/ocean/roles.yml +8 -0
- data/test/sites/ocean/sites.yml +0 -1
- data/test/sites/ocean/users.yml +0 -13
- data/test/sites/zena/columns.yml +27 -5
- data/test/sites/zena/idx_projects.yml +5 -0
- data/test/sites/zena/nodes.yml +8 -32
- data/test/sites/zena/relations.yml +5 -0
- data/test/sites/zena/roles.yml +25 -3
- data/test/sites/zena/sites.yml +2 -2
- data/test/sites/zena/users.yml +1 -21
- data/test/sites/zena/versions.yml +35 -12
- data/test/test_helper.rb +7 -0
- data/test/unit/after_commit_test.rb +7 -7
- data/test/unit/cache_test.rb +32 -0
- data/test/unit/cached_page_test.rb +1 -1
- data/test/unit/column_test.rb +31 -7
- data/test/unit/comment_test.rb +2 -2
- data/test/unit/core_ext_test.rb +38 -7
- data/test/unit/document_test.rb +14 -42
- data/test/unit/node_test.rb +311 -324
- data/test/unit/note_test.rb +23 -31
- data/test/unit/page_test.rb +16 -58
- data/test/unit/project_test.rb +2 -2
- data/test/unit/relation_proxy_test.rb +148 -21
- data/test/unit/relation_test.rb +23 -3
- data/test/unit/remote_test.rb +15 -9
- data/test/unit/role_test.rb +9 -0
- data/test/unit/site_test.rb +49 -47
- data/test/unit/skin_test.rb +16 -0
- data/test/unit/template_test.rb +60 -69
- data/test/unit/text_document_test.rb +15 -14
- data/test/unit/user_test.rb +101 -41
- data/test/unit/version_test.rb +4 -4
- data/test/unit/virtual_class_test.rb +577 -36
- data/test/unit/workflow_test.rb +58 -21
- data/test/unit/zena/acts/enrollable_test.rb +36 -127
- data/test/unit/zena/acts/secure_test.rb +6 -22
- data/test/unit/zena/acts/serializable_test.rb +18 -0
- data/test/unit/zena/db_test.rb +14 -14
- data/test/unit/zena/parser/zafu.yml +5 -3
- data/test/unit/zena/use/ancestry_test.rb +198 -0
- data/test/unit/zena/use/calendar_test.rb +8 -8
- data/test/unit/zena/use/dates_test.rb +2 -0
- data/test/unit/zena/use/fulltext_test.rb +9 -1
- data/test/unit/zena/use/html_tags_test.rb +2 -16
- data/test/unit/zena/use/i18n_test.rb +2 -2
- data/test/unit/zena/use/kpath_test.rb +13 -0
- data/test/unit/zena/use/ml_index_test.rb +60 -12
- data/test/unit/zena/use/prop_eval_test.rb +170 -0
- data/test/unit/zena/use/query_node_test.rb +9 -2
- data/test/unit/zena/use/rendering_test.rb +98 -1
- data/test/unit/zena/use/scope_index_test.rb +464 -0
- data/test/unit/zena/use/urls_test.rb +23 -13
- data/test/unit/zena/use/version_hash_test.rb +2 -2
- data/test/unit/zena/use/zafu_template_test.rb +21 -8
- data/test/unit/zena/use/zazen_test.rb +47 -47
- data/zena.gemspec +177 -143
- metadata +222 -141
- data/app/models/base_contact.rb +0 -79
- data/app/models/book.rb +0 -242
- data/app/models/contact_content.rb +0 -70
- data/app/models/contact_version.rb +0 -40
- data/app/models/reference.rb +0 -18
- data/app/views/templates/edit_tabs/_basecontact.rhtml +0 -8
- data/bricks/data2pdf/README +0 -19
- data/bricks/data2pdf/VERSION +0 -1
- data/bricks/data2pdf/lib/data2pdf.rb +0 -60
- data/bricks/data2pdf/lib/engines/prince.rb +0 -39
- data/bricks/data2pdf/lib/engines/xhtml2pdf.rb +0 -41
- data/bricks/data2pdf/lib/install.rb +0 -111
- data/bricks/data2pdf/test/engines/test_prince.rb +0 -14
- data/bricks/data2pdf/test/engines/test_xhtml2pdf.rb +0 -14
- data/bricks/data2pdf/test/shoulda_macros/shoulda_data2pdf.rb +0 -91
- data/bricks/data2pdf/test/unit/test_rendering.rb +0 -37
- data/config/routes.rb +0 -3
- data/db/migrate/010_create_template_content.rb +0 -17
- data/db/migrate/024_correct_vclass_kpath.rb +0 -13
- data/db/migrate/025_move_tag_into_vclass.rb +0 -15
- data/lib/version_off.rb +0 -323
- data/lib/zena/use/node_name.rb +0 -94
- data/test/integration/query_node/properties.yml +0 -41
- data/test/unit/base_contact_test.rb +0 -242
- data/test/unit/node_name_test.rb +0 -137
data/test/test_helper.rb
CHANGED
@@ -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 :
|
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[:
|
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(:
|
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(:
|
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(:
|
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(:
|
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(:
|
72
|
+
page = Page.create(:custom_a => 1)
|
73
73
|
assert_equal [], page.after_commit_actions
|
74
74
|
raise ActiveRecord::Rollback
|
75
75
|
end
|
data/test/unit/cache_test.rb
CHANGED
@@ -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(:
|
68
|
+
assert node.update_attributes(:title => 'hey'), "Can save"
|
69
69
|
assert !File.exists?(path), "Cache file removed"
|
70
70
|
end
|
71
71
|
end
|
data/test/unit/column_test.rb
CHANGED
@@ -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 => '
|
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
|
59
|
+
assert_equal 'has already been taken in Node', subject.errors[:name]
|
60
60
|
end
|
61
61
|
end
|
62
|
-
end # with
|
62
|
+
end # with the name of a hardwire property
|
63
63
|
|
64
|
-
context 'with the name of a
|
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 => '
|
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 '
|
71
|
+
assert_equal 'invalid (method defined in Node)', subject.errors[:name]
|
72
72
|
end
|
73
73
|
end
|
74
|
-
end # with
|
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
|
data/test/unit/comment_test.rb
CHANGED
@@ -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 '
|
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 '
|
117
|
+
assert_equal 'Panthera Tigris Sumatran', comment.author_name
|
118
118
|
end
|
119
119
|
|
120
120
|
|
data/test/unit/core_ext_test.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
|
2
|
-
require '
|
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
|
data/test/unit/document_test.rb
CHANGED
@@ -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.
|
51
|
+
assert_equal 'life', subject.title
|
56
52
|
end
|
57
53
|
|
58
|
-
context 'with same
|
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
|
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
|
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
|
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
|
-
:
|
100
|
+
:title => 'stupid.jpg',
|
106
101
|
:file => uploaded_pdf('water.pdf'))
|
107
102
|
}
|
108
103
|
end
|
109
104
|
|
110
|
-
should 'fix extension but use
|
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.
|
115
|
-
assert_equal 'stupid', subject.
|
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
|
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
|
226
|
-
should 'save
|
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
|
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
|
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
|
data/test/unit/node_test.rb
CHANGED
@@ -4,7 +4,7 @@ require 'test_helper'
|
|
4
4
|
class NodeTest < Zena::Unit::TestCase
|
5
5
|
|
6
6
|
NEW_DEFAULT = {
|
7
|
-
:
|
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
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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.
|
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
|
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[:
|
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), :
|
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
|
236
|
+
def test_page_update_without_title
|
267
237
|
login(:tiger)
|
268
238
|
node = secure!(Node) { nodes(:status) }
|
269
|
-
node
|
270
|
-
assert node.save
|
271
|
-
assert_equal '
|
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(:
|
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.
|
361
|
-
assert_equal '
|
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.
|
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(:
|
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 "
|
582
|
-
assert_equal "
|
583
|
-
|
584
|
-
|
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 '
|
597
|
-
assert_equal '
|
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 '
|
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
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
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]
|
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), :
|
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), :
|
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), :
|
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), :
|
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), :
|
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), '
|
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
|
750
|
+
assert_equal 'funny', node.title
|
819
751
|
assert !node.new_record?
|
820
752
|
end
|
821
753
|
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
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
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
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), '
|
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
|
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(:
|
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(:
|
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
|
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, '
|
845
|
+
children = parent.find(:all, 'nodes order by title asc')
|
899
846
|
assert_equal 2, children.size
|
900
|
-
assert_equal 'Photos', children[0].
|
847
|
+
assert_equal 'Photos !', children[0].title
|
901
848
|
assert_equal groups_id(:managers), children[0].rgroup_id
|
902
|
-
assert_equal 'simple', children[1].
|
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, '
|
856
|
+
children = children[1].find(:all, 'nodes order by title ASC')
|
910
857
|
assert_equal 2, children.size
|
911
|
-
assert_equal 'Photos', children[0].
|
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
|
927
|
-
photos = secure!(Section) { Section.
|
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.
|
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.
|
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.
|
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
|
-
|
949
|
-
|
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
|
-
|
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(:
|
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
|
1006
|
-
assert_equal
|
1007
|
-
assert_equal
|
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(:
|
1010
|
-
Node.connection.execute "UPDATE nodes SET position = -0.5 WHERE id = #{nodes_id(:
|
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
|
1013
|
-
assert_equal
|
1014
|
-
assert_equal
|
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 '
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
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,
|
1128
|
-
assert_equal Page,
|
1129
|
-
assert_equal Image,
|
1130
|
-
assert_equal roles(:Post),
|
1131
|
-
assert_equal roles(:Letter),
|
1132
|
-
assert_equal TextDocument,
|
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(:
|
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(:
|
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['
|
1207
|
-
'm_title'
|
1208
|
-
'm_text'
|
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(:
|
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', '
|
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(:
|
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', '
|
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
|
-
|
1274
|
-
|
1275
|
-
cleanWater
|
1276
|
-
|
1277
|
-
|
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/
|
1280
|
-
['(/projects/
|
1281
|
-
['(status)',
|
1282
|
-
['(status)', cleanWater]
|
1283
|
-
}.each do |k,v|
|
1284
|
-
assert_equal v, secure(Node) { Node.translate_pseudo_id(k[0],:id,k[1]) }, "'#{k
|
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\":(../../../
|
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\":(../../../
|
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,
|
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
|
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'],
|
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},
|
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'
|
1336
|
-
assert_equal "prop['#{k}']",
|
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 '
|
1425
|
-
assert_transforms Hash['
|
1426
|
-
Hash['parent_id'
|
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 '
|
1430
|
-
assert_transforms Hash['
|
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
|
-
|
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' => {'
|
1447
|
-
Hash['link' => {'hot' => {'other_id'
|
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
|