adva_cms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/NOTES +132 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/adva_cms.gemspec +22 -0
- data/app/assets/images/adva_cms/admin/header_bg.png +0 -0
- data/app/assets/images/adva_cms/admin/section_menu_bg.png +0 -0
- data/app/assets/images/adva_cms/admin/tab_action_active.png +0 -0
- data/app/assets/images/adva_cms/admin/tab_main_active.png +0 -0
- data/app/assets/images/adva_cms/admin/tab_sidebar_active.png +0 -0
- data/app/assets/images/adva_cms/admin/tab_top_active.png +0 -0
- data/app/assets/images/adva_cms/asset_selected.png +0 -0
- data/app/assets/images/adva_cms/avatar.gif +0 -0
- data/app/assets/images/adva_cms/filter-bg.png +0 -0
- data/app/assets/images/adva_cms/icons/accept.png +0 -0
- data/app/assets/images/adva_cms/icons/add.png +0 -0
- data/app/assets/images/adva_cms/icons/arrow_cross.png +0 -0
- data/app/assets/images/adva_cms/icons/arrow_cross_2.png +0 -0
- data/app/assets/images/adva_cms/icons/arrow_cross_3.png +0 -0
- data/app/assets/images/adva_cms/icons/arrow_up_down.png +0 -0
- data/app/assets/images/adva_cms/icons/assets/audio.png +0 -0
- data/app/assets/images/adva_cms/icons/assets/doc.png +0 -0
- data/app/assets/images/adva_cms/icons/assets/pdf.png +0 -0
- data/app/assets/images/adva_cms/icons/assets/video.png +0 -0
- data/app/assets/images/adva_cms/icons/attach.png +0 -0
- data/app/assets/images/adva_cms/icons/bin.png +0 -0
- data/app/assets/images/adva_cms/icons/bin_closed.png +0 -0
- data/app/assets/images/adva_cms/icons/bin_empty.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_black.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_delete.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_error.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_go.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_red.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_white.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_yellow.png +0 -0
- data/app/assets/images/adva_cms/icons/cancel.png +0 -0
- data/app/assets/images/adva_cms/icons/comment.gif +0 -0
- data/app/assets/images/adva_cms/icons/comment.png +0 -0
- data/app/assets/images/adva_cms/icons/comment_add.png +0 -0
- data/app/assets/images/adva_cms/icons/comment_blue.gif +0 -0
- data/app/assets/images/adva_cms/icons/comment_delete.png +0 -0
- data/app/assets/images/adva_cms/icons/comment_edit.png +0 -0
- data/app/assets/images/adva_cms/icons/comment_yellow.gif +0 -0
- data/app/assets/images/adva_cms/icons/cross.png +0 -0
- data/app/assets/images/adva_cms/icons/delete.png +0 -0
- data/app/assets/images/adva_cms/icons/eye.png +0 -0
- data/app/assets/images/adva_cms/icons/favorites.png +0 -0
- data/app/assets/images/adva_cms/icons/help.png +0 -0
- data/app/assets/images/adva_cms/icons/hourglass.png +0 -0
- data/app/assets/images/adva_cms/icons/icon_attachment.gif +0 -0
- data/app/assets/images/adva_cms/icons/icon_padlock.gif +0 -0
- data/app/assets/images/adva_cms/icons/link.png +0 -0
- data/app/assets/images/adva_cms/icons/lock.png +0 -0
- data/app/assets/images/adva_cms/icons/magnifier.png +0 -0
- data/app/assets/images/adva_cms/icons/minus.gif +0 -0
- data/app/assets/images/adva_cms/icons/page_add.png +0 -0
- data/app/assets/images/adva_cms/icons/page_delete.png +0 -0
- data/app/assets/images/adva_cms/icons/page_edit.png +0 -0
- data/app/assets/images/adva_cms/icons/page_favorites.png +0 -0
- data/app/assets/images/adva_cms/icons/page_go.png +0 -0
- data/app/assets/images/adva_cms/icons/page_green.png +0 -0
- data/app/assets/images/adva_cms/icons/page_red.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_add.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_delete.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_edit.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_go.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_link.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_magnify.png +0 -0
- data/app/assets/images/adva_cms/icons/pencil.png +0 -0
- data/app/assets/images/adva_cms/icons/star.png +0 -0
- data/app/assets/images/adva_cms/icons/stop.png +0 -0
- data/app/assets/images/adva_cms/icons/tag_green.png +0 -0
- data/app/assets/images/adva_cms/icons/tick.png +0 -0
- data/app/assets/images/adva_cms/icons/zoom.png +0 -0
- data/app/assets/images/adva_cms/indicator.gif +0 -0
- data/app/assets/images/adva_cms/preview.png +0 -0
- data/app/assets/images/adva_cms/rails.png +0 -0
- data/app/assets/images/adva_cms/sortable_tree/drag.png +0 -0
- data/app/assets/images/adva_cms/theme_selected.png +0 -0
- data/app/assets/javascripts/admin.js +1 -0
- data/app/assets/javascripts/adva_cms/admin/jquery.admin.js +23 -0
- data/app/assets/javascripts/adva_cms/admin/jquery.article.js +22 -0
- data/app/assets/javascripts/adva_cms/admin/jquery.cached_pages.js +14 -0
- data/app/assets/javascripts/adva_cms/admin/jquery.table_tree.js +7 -0
- data/app/assets/javascripts/adva_cms/application.js +14 -0
- data/app/assets/javascripts/adva_cms/base.js +4 -0
- data/app/assets/javascripts/adva_cms/cookie.js +49 -0
- data/app/assets/javascripts/adva_cms/jquery.common.js +41 -0
- data/app/assets/javascripts/adva_cms/jquery.dates.js +51 -0
- data/app/assets/javascripts/adva_cms/jquery.flash.js +57 -0
- data/app/assets/javascripts/adva_cms/jquery.roles.js +25 -0
- data/app/assets/javascripts/adva_cms/jquery/jquery-lowpro.js +224 -0
- data/app/assets/javascripts/adva_cms/jquery/jquery.qtip.js +2085 -0
- data/app/assets/javascripts/adva_cms/jquery/jquery.table_tree.js +307 -0
- data/app/assets/javascripts/adva_cms/jquery/jquery.tablednd_0_5.js +386 -0
- data/app/assets/javascripts/adva_cms/json.js +139 -0
- data/app/assets/stylesheets/admin.css +1 -0
- data/app/assets/stylesheets/adva_cms/admin.css +16 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/common.css +76 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/forms.css +121 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/header.css +125 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/layout.css +103 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/lists.css +153 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/sidebar.css +65 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/top.css +123 -0
- data/app/assets/stylesheets/adva_cms/admin/common.css +76 -0
- data/app/assets/stylesheets/adva_cms/admin/content.css +11 -0
- data/app/assets/stylesheets/adva_cms/admin/forms.css +116 -0
- data/app/assets/stylesheets/adva_cms/admin/header.css +114 -0
- data/app/assets/stylesheets/adva_cms/admin/helptip.css +35 -0
- data/app/assets/stylesheets/adva_cms/admin/layout.css +56 -0
- data/app/assets/stylesheets/adva_cms/admin/lists.css +152 -0
- data/app/assets/stylesheets/adva_cms/admin/projection.css +118 -0
- data/app/assets/stylesheets/adva_cms/admin/reset.css +25 -0
- data/app/assets/stylesheets/adva_cms/admin/screen/top.css +8 -0
- data/app/assets/stylesheets/adva_cms/admin/sidebar.css +67 -0
- data/app/assets/stylesheets/adva_cms/admin/themes.css +49 -0
- data/app/assets/stylesheets/adva_cms/admin/top.css +83 -0
- data/app/assets/stylesheets/adva_cms/admin/users.css +40 -0
- data/app/assets/stylesheets/adva_cms/common.css +49 -0
- data/app/assets/stylesheets/adva_cms/default.css +201 -0
- data/app/assets/stylesheets/adva_cms/forms.css +60 -0
- data/app/assets/stylesheets/adva_cms/jquery/alternate/jquery.tooltip.css +13 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/jquery-ui.css +406 -0
- data/app/assets/stylesheets/adva_cms/jquery/jquery.tooltip.css +10 -0
- data/app/assets/stylesheets/adva_cms/layout/login.css +8 -0
- data/app/assets/stylesheets/adva_cms/layout/simple.css +8 -0
- data/app/assets/stylesheets/adva_cms/menu.css +129 -0
- data/app/assets/stylesheets/adva_cms/reset.css +25 -0
- data/app/controllers/admin/base_controller.rb +101 -0
- data/app/controllers/admin/categories_controller.rb +3 -0
- data/app/controllers/admin/install_controller.rb +61 -0
- data/app/controllers/admin/page/articles_controller.rb +150 -0
- data/app/controllers/admin/page/categories_controller.rb +62 -0
- data/app/controllers/admin/page/contents_controller.rb +52 -0
- data/app/controllers/admin/page/links_controller.rb +69 -0
- data/app/controllers/admin/pages_controller.rb +2 -0
- data/app/controllers/admin/plugins_controller.rb +40 -0
- data/app/controllers/admin/sections_controller.rb +91 -0
- data/app/controllers/admin/sites_controller.rb +99 -0
- data/app/controllers/articles_controller.rb +81 -0
- data/app/controllers/base_controller.rb +82 -0
- data/app/helpers/admin/base_helper.rb +106 -0
- data/app/helpers/base_helper.rb +56 -0
- data/app/helpers/content_helper.rb +90 -0
- data/app/helpers/resource_helper.rb +127 -0
- data/app/models/article.rb +40 -0
- data/app/models/categorization.rb +4 -0
- data/app/models/category.rb +60 -0
- data/app/models/content.rb +155 -0
- data/app/models/event.rb +34 -0
- data/app/models/link.rb +4 -0
- data/app/models/page.rb +36 -0
- data/app/models/section.rb +126 -0
- data/app/models/site.rb +104 -0
- data/app/views/admin/cached_pages/_filter.html.erb +8 -0
- data/app/views/admin/cached_pages/destroy.js.erb +18 -0
- data/app/views/admin/cached_pages/index.html.erb +26 -0
- data/app/views/admin/install/confirmation.html.erb +10 -0
- data/app/views/admin/install/index.html.erb +38 -0
- data/app/views/admin/page/articles/_form.html.erb +40 -0
- data/app/views/admin/page/articles/_options.html.erb +20 -0
- data/app/views/admin/page/articles/edit.html.erb +15 -0
- data/app/views/admin/page/articles/new.html.erb +12 -0
- data/app/views/admin/page/categories/edit.html.erb +22 -0
- data/app/views/admin/page/categories/index.html.erb +23 -0
- data/app/views/admin/page/categories/new.html.erb +19 -0
- data/app/views/admin/page/contents/index.html.erb +40 -0
- data/app/views/admin/page/links/_form.html.erb +26 -0
- data/app/views/admin/page/links/_options.html.erb +23 -0
- data/app/views/admin/page/links/edit.html.erb +12 -0
- data/app/views/admin/page/links/new.html.erb +12 -0
- data/app/views/admin/plugins/_form.html.erb +11 -0
- data/app/views/admin/plugins/index.html.erb +16 -0
- data/app/views/admin/plugins/show.html.erb +43 -0
- data/app/views/admin/sections/_form.html.haml +20 -0
- data/app/views/admin/sections/edit.html.haml +6 -0
- data/app/views/admin/sections/index.html.erb +27 -0
- data/app/views/admin/sections/new.html.erb +29 -0
- data/app/views/admin/sections/settings/_page.html.haml +10 -0
- data/app/views/admin/shared/_header.html.erb +18 -0
- data/app/views/admin/shared/_language_select.html.erb +6 -0
- data/app/views/admin/shared/_section.html.erb +8 -0
- data/app/views/admin/shared/_section_summary.html.erb +23 -0
- data/app/views/admin/shared/_section_tree.html.erb +23 -0
- data/app/views/admin/sites/_email_notifications.html.erb +9 -0
- data/app/views/admin/sites/_form.html.erb +15 -0
- data/app/views/admin/sites/_recent_users.html.erb +11 -0
- data/app/views/admin/sites/_sections.html.erb +10 -0
- data/app/views/admin/sites/_unapproved_comments.html.erb +10 -0
- data/app/views/admin/sites/edit.html.erb +4 -0
- data/app/views/admin/sites/index.html.erb +21 -0
- data/app/views/admin/sites/multi_sites_disabled.html.erb +11 -0
- data/app/views/admin/sites/new.html.erb +21 -0
- data/app/views/admin/sites/show.html.erb +16 -0
- data/app/views/categories/_checkboxes.html.erb +12 -0
- data/app/views/layouts/admin.html.haml +50 -0
- data/app/views/layouts/default.html.erb +38 -0
- data/app/views/layouts/simple.html.erb +22 -0
- data/app/views/pages/articles/index.html.erb +10 -0
- data/app/views/pages/articles/show.html.erb +17 -0
- data/app/views/shared/_flash.html.erb +3 -0
- data/app/views/shared/_footer.html.erb +4 -0
- data/app/views/shared/_menu.html.erb +10 -0
- data/app/views/shared/_sidebar.html.erb +19 -0
- data/app/views/shared/messages/insufficient_permissions.html.erb +4 -0
- data/config/environment.rb +21 -0
- data/config/initializers/has_options.rb +2 -0
- data/config/initializers/has_permalink.rb +27 -0
- data/config/initializers/mailer.rb +12 -0
- data/config/initializers/menus.rb +184 -0
- data/config/initializers/roles.rb +91 -0
- data/config/initializers/settings.rb +26 -0
- data/config/initializers/site.rb +5 -0
- data/config/initializers/translations_are_a_pain.rb +9 -0
- data/config/locales/en.yml +1295 -0
- data/config/routes.rb +47 -0
- data/db/migrate/20080401000001_create_sites_table.rb +28 -0
- data/db/migrate/20080401000002_create_sections_table.rb +25 -0
- data/db/migrate/20080401000003_create_contents_table.rb +35 -0
- data/db/migrate/20080401000004_create_categories_table.rb +17 -0
- data/db/migrate/20080401000005_create_category_assignments.rb +12 -0
- data/db/migrate/20080401000006_create_taggable_tables.rb +26 -0
- data/db/migrate/20080710000000_create_plugin_configs.rb +13 -0
- data/db/migrate/20080715131051_plugin_owner_column.rb +13 -0
- data/db/migrate/20081208161500_add_content_type_to_join_tables.rb +10 -0
- data/db/migrate/20090216114034_rename_category_assignment_to_categorization.rb +13 -0
- data/db/migrate/20090305123429_move_sections_to_pages.rb +9 -0
- data/db/migrate/20090519132700_add_published_at_to_sections.rb +10 -0
- data/db/migrate/20090702085459_create_section_translations.rb +9 -0
- data/db/migrate/20090702200226_create_category_translations.rb +9 -0
- data/db/migrate/20090707171100_upgrade_paperclip_paths.rb +31 -0
- data/db/migrate/20090709111934_add_email_notification_to_site.rb +12 -0
- data/db/migrate/20091026000906_add_nesting_to_articles.rb +26 -0
- data/db/migrate/20140721000000_add_title_to_contents.rb +7 -0
- data/lib/adva_cms.rb +50 -0
- data/lib/adva_cms/version.rb +3 -0
- data/lib/core_ext.rb +7 -0
- data/lib/extensible_forms.rb +283 -0
- data/lib/has_options.rb +46 -0
- data/lib/html_diff.rb +48 -0
- data/lib/rails_ext.rb +15 -0
- data/lib/rails_ext/action_controller/cacheable_flash.rb +30 -0
- data/lib/rails_ext/action_controller/content_for_assignments.rb +105 -0
- data/lib/rails_ext/action_controller/default_params.rb +19 -0
- data/lib/rails_ext/action_controller/event_helper.rb +18 -0
- data/lib/rails_ext/action_controller/page_caching.rb +23 -0
- data/lib/rails_ext/action_controller/render_with_error_proc.rb +46 -0
- data/lib/rails_ext/action_controller/responds_to_parent.rb +46 -0
- data/lib/rails_ext/action_controller/url_for_returning.rb +12 -0
- data/lib/rails_ext/active_record/exists.rb +5 -0
- data/lib/rails_ext/active_record/sti_instantiation.rb +35 -0
- data/lib/rails_ext/active_record/sticky_changes.rb +30 -0
- data/lib/rails_ext/railties/plugin.rb +58 -0
- data/lib/rails_ext/railties/plugin_configuration.rb +72 -0
- data/lib/rails_ext/railties/plugin_initializers.rb +25 -0
- data/lib/registry.rb +49 -0
- data/lib/tasks/adva_cms.rake +178 -0
- data/lib/tasks/translation.rake +69 -0
- data/lib/time_hacks.rb +57 -0
- data/lib/webrat_patch.rb +11 -0
- data/locale/rails/fr.yml +123 -0
- data/test/NOTES +56 -0
- data/test/contexts.rb +365 -0
- data/test/fixtures.rb +190 -0
- data/test/fixtures/templates/alternative_templates/index.html.erb +1 -0
- data/test/fixtures/templates/context_templates_test/index.html.erb +1 -0
- data/test/fixtures/templates/context_templates_test/show.html.erb +0 -0
- data/test/fixtures/templates/layouts/alternative.html.erb +0 -0
- data/test/fixtures/templates/layouts/default.html.erb +0 -0
- data/test/fixtures/templates/menu/shared/_menu.html.erb +8 -0
- data/test/functional/admin/articles_controller_test.rb +329 -0
- data/test/functional/admin/base_controller_test.rb +68 -0
- data/test/functional/admin/cached_pages_controller_test.rb +66 -0
- data/test/functional/admin/categories_controller_test.rb +164 -0
- data/test/functional/admin/cells_controller_spec.rb +32 -0
- data/test/functional/admin/install_controller_test.rb +89 -0
- data/test/functional/admin/plugins_controller_test.rb +93 -0
- data/test/functional/admin/sections_controller_test.rb +201 -0
- data/test/functional/admin/sites_controller_test.rb +240 -0
- data/test/functional/asset_tag_expansions_test.rb +82 -0
- data/test/functional/base_controller_test.rb +73 -0
- data/test/functional/page_articles_controller_test.rb +168 -0
- data/test/functional/page_articles_routes_test.rb +73 -0
- data/test/integration/admin/cached_pages_test.rb +43 -0
- data/test/integration/admin/categories_test.rb +66 -0
- data/test/integration/admin/custom_templates_test.rb +42 -0
- data/test/integration/admin/filtering_articles_test.rb +32 -0
- data/test/integration/admin/plugins.rb +32 -0
- data/test/integration/admin/section_article_test.rb +150 -0
- data/test/integration/admin/section_test.rb +88 -0
- data/test/integration/admin/sites_test.rb +48 -0
- data/test/integration/installation_test.rb +109 -0
- data/test/integration/page_article_comment_test.rb +51 -0
- data/test/integration/page_article_test.rb +87 -0
- data/test/integration/section_index_test.rb +37 -0
- data/test/javascript/assets/jquery-lowpro.js +224 -0
- data/test/javascript/assets/jquery-ui.js +298 -0
- data/test/javascript/assets/jquery.js +4376 -0
- data/test/javascript/assets/testrunner.js +815 -0
- data/test/javascript/assets/testsuite.css +120 -0
- data/test/javascript/lib/jstest.rb +588 -0
- data/test/javascript/templates/test_case.erb +33 -0
- data/test/plugins/adva_context_templates/context_templates_test.rb +138 -0
- data/test/plugins/adva_post_ping/controller/integration_test.rb +78 -0
- data/test/plugins/adva_post_ping/post_ping_test.rb +94 -0
- data/test/plugins/adva_url_history/article_test.rb +94 -0
- data/test/plugins/adva_url_history/init_url_history.rb +18 -0
- data/test/plugins/adva_url_history/section_test.rb +49 -0
- data/test/test_helper.rb +75 -0
- data/test/test_helper/clear_directories.rb +16 -0
- data/test/test_helper/ensure_single_site_mode.rb +10 -0
- data/test/test_helper/extensions/cacheable_flash.rb +14 -0
- data/test/test_helper/extensions/cronjob.rb +11 -0
- data/test/test_helper/extensions/even_test_log.rb +21 -0
- data/test/test_helper/extensions/integration_test.rb +78 -0
- data/test/test_helper/extensions/matchy.rb +365 -0
- data/test/test_helper/extensions/matchy_adva_cms.rb +441 -0
- data/test/test_helper/extensions/rails_patch.rb +40 -0
- data/test/test_helper/extensions/rr.rb +7 -0
- data/test/test_helper/extensions/test_unit.rb +35 -0
- data/test/test_helper/extensions/with_sugar.rb +166 -0
- data/test/test_helper/parse_options.rb +18 -0
- data/test/test_helper/setup_db_transaction.rb +15 -0
- data/test/test_helper/setup_webrat.rb +9 -0
- data/test/test_helper/test_server/init.rb +15 -0
- data/test/unit/helpers/admin/base_helper_test.rb +139 -0
- data/test/unit/helpers/base_helper_spec.rb +54 -0
- data/test/unit/helpers/base_helper_test.rb +165 -0
- data/test/unit/helpers/content_helper_test.rb +127 -0
- data/test/unit/helpers/resource_helper_test.rb +180 -0
- data/test/unit/i18n_test.rb +22 -0
- data/test/unit/lib/cells_ext_spec.rb +96 -0
- data/test/unit/lib/extensible_forms_test.rb +362 -0
- data/test/unit/lib/menu_test.rb +119 -0
- data/test/unit/lib/rails_ext/content_for_assignments_test.rb +75 -0
- data/test/unit/lib/rails_ext/plugin_configuration_test.rb +40 -0
- data/test/unit/lib/rails_ext/sticky_changes_test.rb +33 -0
- data/test/unit/lib/registry_test.rb +91 -0
- data/test/unit/lib/routing_filter/routing_filter_categories_spec.rb +63 -0
- data/test/unit/lib/routing_filter/routing_filter_categories_test.rb +159 -0
- data/test/unit/lib/routing_filter/routing_filter_locale_spec.rb +73 -0
- data/test/unit/lib/routing_filter/routing_filter_root_blog_archive_spec.rb +40 -0
- data/test/unit/lib/routing_filter/routing_filter_root_section_articles_spec.rb +48 -0
- data/test/unit/lib/routing_filter/routing_filter_root_wikipages_spec.rb +40 -0
- data/test/unit/lib/routing_filter/routing_filter_sections_spec.rb +143 -0
- data/test/unit/lib/routing_filter/routing_filter_sections_test.rb +32 -0
- data/test/unit/lib/routing_filter/routing_filter_sets_test.rb +86 -0
- data/test/unit/models/article_test.rb +191 -0
- data/test/unit/models/category_test.rb +68 -0
- data/test/unit/models/content_test.rb +409 -0
- data/test/unit/models/counter_test.rb +43 -0
- data/test/unit/models/event_test.rb +41 -0
- data/test/unit/models/nested_categories_test.rb +34 -0
- data/test/unit/models/page_test.rb +63 -0
- data/test/unit/models/section_test.rb +315 -0
- data/test/unit/models/site_test.rb +199 -0
- data/test/unit/observers/activities_article_observer_test.rb +42 -0
- data/vendor/gems/belongs_to_cacheable/.gitignore +17 -0
- data/vendor/gems/belongs_to_cacheable/Gemfile +4 -0
- data/vendor/gems/belongs_to_cacheable/LICENSE +22 -0
- data/vendor/gems/belongs_to_cacheable/README.md +29 -0
- data/vendor/gems/belongs_to_cacheable/Rakefile +2 -0
- data/vendor/gems/belongs_to_cacheable/belongs_to_cacheable.gemspec +22 -0
- data/vendor/gems/belongs_to_cacheable/init.rb +1 -0
- data/vendor/gems/belongs_to_cacheable/lib/active_record/belongs_to_cacheable.rb +77 -0
- data/vendor/gems/belongs_to_cacheable/lib/belongs_to_cacheable.rb +3 -0
- data/vendor/gems/belongs_to_cacheable/lib/belongs_to_cacheable/version.rb +3 -0
- data/vendor/gems/belongs_to_cacheable/spec/belongs_to_cacheable_spec.rb +52 -0
- data/vendor/gems/belongs_to_cacheable/spec/spec_helper.rb +50 -0
- data/vendor/gems/filtered_column/.gitignore +17 -0
- data/vendor/gems/filtered_column/Gemfile +4 -0
- data/vendor/gems/filtered_column/LICENSE +22 -0
- data/vendor/gems/filtered_column/README +4 -0
- data/vendor/gems/filtered_column/README.md +29 -0
- data/vendor/gems/filtered_column/Rakefile +23 -0
- data/vendor/gems/filtered_column/filtered_column.gemspec +17 -0
- data/vendor/gems/filtered_column/lib/filtered_column.rb +17 -0
- data/vendor/gems/filtered_column/lib/filtered_column/filters/base.rb +28 -0
- data/vendor/gems/filtered_column/lib/filtered_column/filters/smartypants_filter.rb +14 -0
- data/vendor/gems/filtered_column/lib/filtered_column/filters/textile_filter.rb +13 -0
- data/vendor/gems/filtered_column/lib/filtered_column/macros/base.rb +25 -0
- data/vendor/gems/filtered_column/lib/filtered_column/mixin.rb +46 -0
- data/vendor/gems/filtered_column/lib/filtered_column/processor.rb +52 -0
- data/vendor/gems/filtered_column/lib/filtered_column/version.rb +3 -0
- data/vendor/gems/filtered_column/tasks/filtered_column_tasks.rake +4 -0
- data/vendor/gems/filtered_column/test/abstract_unit.rb +73 -0
- data/vendor/gems/filtered_column/test/filtered_column_test.rb +53 -0
- data/vendor/gems/filtered_column/test/macro_filter_test.rb +23 -0
- data/vendor/gems/has_counter/.gitignore +17 -0
- data/vendor/gems/has_counter/Gemfile +4 -0
- data/vendor/gems/has_counter/LICENSE +22 -0
- data/vendor/gems/has_counter/MIT-LICENSE +20 -0
- data/vendor/gems/has_counter/README.markdown +64 -0
- data/vendor/gems/has_counter/README.md +29 -0
- data/vendor/gems/has_counter/Rakefile +2 -0
- data/vendor/gems/has_counter/db/migrate/20080601194338_create_counters_table.rb.rb +13 -0
- data/vendor/gems/has_counter/has_counter.gemspec +17 -0
- data/vendor/gems/has_counter/lib/active_record/has_counter.rb +64 -0
- data/vendor/gems/has_counter/lib/counter.rb +23 -0
- data/vendor/gems/has_counter/lib/has_counter.rb +4 -0
- data/vendor/gems/has_counter/lib/has_counter/version.rb +3 -0
- data/vendor/gems/has_counter/spec/has_counter.spec.log +0 -0
- data/vendor/gems/has_counter/spec/has_counter.sqlite3.db +0 -0
- data/vendor/gems/has_counter/spec/has_counter_spec.rb +55 -0
- data/vendor/gems/has_counter/spec/spec_helper.rb +117 -0
- data/vendor/gems/has_filter/.gitignore +17 -0
- data/vendor/gems/has_filter/Gemfile +4 -0
- data/vendor/gems/has_filter/LICENSE +22 -0
- data/vendor/gems/has_filter/README.md +29 -0
- data/vendor/gems/has_filter/Rakefile +2 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_add.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_left.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_right.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_remove.png +0 -0
- data/vendor/gems/has_filter/app/assets/javascripts/has_filter/filter.js +35 -0
- data/vendor/gems/has_filter/app/assets/javascripts/has_filter/jquery.filter.js +23 -0
- data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/alternate/filter.css +102 -0
- data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/filter.css +100 -0
- data/vendor/gems/has_filter/app/helpers/filter_helper.rb +3 -0
- data/vendor/gems/has_filter/has_filter.gemspec +17 -0
- data/vendor/gems/has_filter/init.rb +3 -0
- data/vendor/gems/has_filter/lib/has_filter.rb +22 -0
- data/vendor/gems/has_filter/lib/has_filter/active_record/act_macro.rb +102 -0
- data/vendor/gems/has_filter/lib/has_filter/filter.rb +17 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/base.rb +67 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/categorized.rb +24 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/chain.rb +45 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/set.rb +80 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/state.rb +25 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/tagged.rb +22 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/text.rb +55 -0
- data/vendor/gems/has_filter/lib/has_filter/version.rb +3 -0
- data/vendor/gems/has_filter/test/db/setup.rb +45 -0
- data/vendor/gems/has_filter/test/db/test.sqlite3.db +0 -0
- data/vendor/gems/has_filter/test/fixtures.rb +15 -0
- data/vendor/gems/has_filter/test/has_filter/filter_chain_test.rb +41 -0
- data/vendor/gems/has_filter/test/has_filter/filter_scopes_test.rb +102 -0
- data/vendor/gems/has_filter/test/has_filter/filter_tags_test.rb +113 -0
- data/vendor/gems/has_filter/test/has_filter/integration.rb +15 -0
- data/vendor/gems/has_filter/test/has_filter/scopes_test.rb +48 -0
- data/vendor/gems/has_filter/test/log/test.log +34346 -0
- data/vendor/gems/has_filter/test/models.rb +23 -0
- data/vendor/gems/has_filter/test/templates/has_filter/test/index.html.erb +5 -0
- data/vendor/gems/has_filter/test/test_helper.rb +66 -0
- data/vendor/gems/simple_taggable/.gitignore +17 -0
- data/vendor/gems/simple_taggable/Gemfile +4 -0
- data/vendor/gems/simple_taggable/LICENSE +22 -0
- data/vendor/gems/simple_taggable/README +24 -0
- data/vendor/gems/simple_taggable/README.md +29 -0
- data/vendor/gems/simple_taggable/Rakefile +2 -0
- data/vendor/gems/simple_taggable/lib/simple_taggable.rb +153 -0
- data/vendor/gems/simple_taggable/lib/simple_taggable/version.rb +3 -0
- data/vendor/gems/simple_taggable/lib/tag.rb +31 -0
- data/vendor/gems/simple_taggable/lib/tag_list.rb +90 -0
- data/vendor/gems/simple_taggable/lib/tagging.rb +8 -0
- data/vendor/gems/simple_taggable/simple_taggable.gemspec +17 -0
- data/vendor/gems/simple_taggable/test/db/schema.rb +41 -0
- data/vendor/gems/simple_taggable/test/db/simple_taggable.sqlite3.db +0 -0
- data/vendor/gems/simple_taggable/test/fixtures/magazine.rb +3 -0
- data/vendor/gems/simple_taggable/test/fixtures/magazines.yml +2 -0
- data/vendor/gems/simple_taggable/test/fixtures/photo.rb +8 -0
- data/vendor/gems/simple_taggable/test/fixtures/photos.yml +19 -0
- data/vendor/gems/simple_taggable/test/fixtures/post.rb +5 -0
- data/vendor/gems/simple_taggable/test/fixtures/posts.yml +27 -0
- data/vendor/gems/simple_taggable/test/fixtures/subscription.rb +4 -0
- data/vendor/gems/simple_taggable/test/fixtures/subscriptions.yml +3 -0
- data/vendor/gems/simple_taggable/test/fixtures/taggings.yml +112 -0
- data/vendor/gems/simple_taggable/test/fixtures/tags.yml +14 -0
- data/vendor/gems/simple_taggable/test/fixtures/user.rb +6 -0
- data/vendor/gems/simple_taggable/test/fixtures/users.yml +5 -0
- data/vendor/gems/simple_taggable/test/log/simple_taggable.log +1614 -0
- data/vendor/gems/simple_taggable/test/simple_taggable_test.rb +226 -0
- data/vendor/gems/simple_taggable/test/tag_list_test.rb +105 -0
- data/vendor/gems/simple_taggable/test/test_helper.rb +80 -0
- data/vendor/gems/table_builder/.gitignore +17 -0
- data/vendor/gems/table_builder/Gemfile +4 -0
- data/vendor/gems/table_builder/LICENSE +22 -0
- data/vendor/gems/table_builder/README.md +29 -0
- data/vendor/gems/table_builder/Rakefile +2 -0
- data/vendor/gems/table_builder/lib/table_builder.rb +27 -0
- data/vendor/gems/table_builder/lib/table_builder/body.rb +28 -0
- data/vendor/gems/table_builder/lib/table_builder/cell.rb +21 -0
- data/vendor/gems/table_builder/lib/table_builder/column.rb +26 -0
- data/vendor/gems/table_builder/lib/table_builder/foot.rb +6 -0
- data/vendor/gems/table_builder/lib/table_builder/head.rb +16 -0
- data/vendor/gems/table_builder/lib/table_builder/row.rb +40 -0
- data/vendor/gems/table_builder/lib/table_builder/rows.rb +26 -0
- data/vendor/gems/table_builder/lib/table_builder/table.rb +75 -0
- data/vendor/gems/table_builder/lib/table_builder/tag.rb +58 -0
- data/vendor/gems/table_builder/lib/table_builder/version.rb +3 -0
- data/vendor/gems/table_builder/table_builder.gemspec +17 -0
- data/vendor/gems/table_builder/test/fixtures/templates/table_all.html.erb +20 -0
- data/vendor/gems/table_builder/test/fixtures/templates/table_auto_body.html.erb +3 -0
- data/vendor/gems/table_builder/test/fixtures/templates/table_auto_columns.html.erb +1 -0
- data/vendor/gems/table_builder/test/fixtures/templates/table_simple.html.erb +7 -0
- data/vendor/gems/table_builder/test/table_builder/table_test.rb +230 -0
- data/vendor/gems/table_builder/test/test_helper.rb +49 -0
- data/vendor/gems/tags/.gitignore +17 -0
- data/vendor/gems/tags/Gemfile +4 -0
- data/vendor/gems/tags/LICENSE +22 -0
- data/vendor/gems/tags/README.md +29 -0
- data/vendor/gems/tags/Rakefile +2 -0
- data/vendor/gems/tags/lib/breadcrumbs.rb +13 -0
- data/vendor/gems/tags/lib/menu.rb +179 -0
- data/vendor/gems/tags/lib/menu/builder.rb +74 -0
- data/vendor/gems/tags/lib/tags.rb +7 -0
- data/vendor/gems/tags/lib/tags/tag.rb +125 -0
- data/vendor/gems/tags/lib/tags/version.rb +3 -0
- data/vendor/gems/tags/tags.gemspec +17 -0
- data/vendor/gems/tags/test/tags/menu_test.rb +173 -0
- data/vendor/gems/tags/test/tags/tag_test.rb +13 -0
- data/vendor/gems/tags/test/test_helper.rb +18 -0
- data/vendor/gems/xss_terminate/.gitignore +17 -0
- data/vendor/gems/xss_terminate/Gemfile +4 -0
- data/vendor/gems/xss_terminate/LICENSE +22 -0
- data/vendor/gems/xss_terminate/MIT-LICENSE +20 -0
- data/vendor/gems/xss_terminate/README +94 -0
- data/vendor/gems/xss_terminate/README.md +29 -0
- data/vendor/gems/xss_terminate/Rakefile +23 -0
- data/vendor/gems/xss_terminate/lib/html5lib_sanitize.rb +2453 -0
- data/vendor/gems/xss_terminate/lib/rails_sanitize.rb +8 -0
- data/vendor/gems/xss_terminate/lib/xss_terminate.rb +141 -0
- data/vendor/gems/xss_terminate/lib/xss_terminate/version.rb +3 -0
- data/vendor/gems/xss_terminate/tasks/xss_terminate_tasks.rake +7 -0
- data/vendor/gems/xss_terminate/test/models/comment.rb +5 -0
- data/vendor/gems/xss_terminate/test/models/entry.rb +7 -0
- data/vendor/gems/xss_terminate/test/models/message.rb +3 -0
- data/vendor/gems/xss_terminate/test/models/person.rb +5 -0
- data/vendor/gems/xss_terminate/test/models/review.rb +5 -0
- data/vendor/gems/xss_terminate/test/schema.rb +34 -0
- data/vendor/gems/xss_terminate/test/setup_test.rb +16 -0
- data/vendor/gems/xss_terminate/test/xss_terminate_test.rb +50 -0
- data/vendor/gems/xss_terminate/xss_terminate.gemspec +17 -0
- metadata +744 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class PageCounterTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@page = Page.find_by_permalink('a-page')
|
7
|
+
end
|
8
|
+
|
9
|
+
test "has_one comments_counter" do
|
10
|
+
@page.should have_one(:comments_counter)
|
11
|
+
end
|
12
|
+
|
13
|
+
test "responds to :comments_count" do
|
14
|
+
@page.should respond_to(:comments_count)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "after create it has a counter initialized and saved" do
|
18
|
+
@page.comments_counter.should_not be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
test "#comments_count is a shortcut to #comments_counter.count" do
|
22
|
+
@page.comments_counter.count = 5
|
23
|
+
@page.comments_count.should == 5
|
24
|
+
end
|
25
|
+
|
26
|
+
test "increments the counter when a comment has been created" do
|
27
|
+
assert_difference('@page.comments_counter(true).count') do
|
28
|
+
create_comment!
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
test "decrements the counter when a comment has been destroyed" do
|
33
|
+
@comment = create_comment!
|
34
|
+
assert_difference('@page.comments_counter(true).count', -1) do
|
35
|
+
@comment.section.comments_counter.reload # hmmmm ...
|
36
|
+
@comment.destroy
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_comment!
|
41
|
+
@page.comments.create!(:section => @page, :body => 'body', :author => User.first, :commentable => Article.first)
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class FooObserver; def handle_foo!(event) nil; end; end
|
4
|
+
class BarObserver; def handle_event!(event) nil; end; end
|
5
|
+
|
6
|
+
class EventTest < ActiveSupport::TestCase
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@old_observers = Event.observers.clone
|
10
|
+
Event.observers.clear
|
11
|
+
Event.observers << @foo_observer = FooObserver.new
|
12
|
+
Event.observers << @bar_observer = BarObserver.new
|
13
|
+
@event = Event.new(:foo, nil, nil)
|
14
|
+
stub(Event).new(:foo, :object, :source, {}).returns(@event)
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
super
|
19
|
+
Event.observers = @old_observers
|
20
|
+
end
|
21
|
+
|
22
|
+
test '#add_observer takes observers' do
|
23
|
+
lambda { Event.observers << mock('observer') }.should_not raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
test "#trigger instantiates a new Event" do
|
27
|
+
mock(Event).new(:foo, :object, :source, {}).returns(@event)
|
28
|
+
Event.trigger(:foo, :object, :source)
|
29
|
+
end
|
30
|
+
|
31
|
+
test "#trigger calls the handle_[event_type]! callback on each observer that implements it" do
|
32
|
+
mock(@foo_observer).handle_foo!(@event)
|
33
|
+
Event.trigger(:foo, :object, :source)
|
34
|
+
end
|
35
|
+
|
36
|
+
test "#trigger calls the handle_event! callback on each observer that implements but does not implement handle_[event_type]!" do
|
37
|
+
mock(@bar_observer).handle_event!(@event)
|
38
|
+
Event.trigger(:foo, :object, :source)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class NestedCategoriesTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@page = Page.first
|
7
|
+
@category = Category.create!(:title => 'fi', :section => @page)
|
8
|
+
@child_category = Category.create!(:title => 'joensuu', :section => @page)
|
9
|
+
@child_category.move_to_child_of(@category)
|
10
|
+
|
11
|
+
@article_1 = @page.articles.build(:title => 'finland', :body => 'polar bears & penguins', :author => User.first).save!
|
12
|
+
@article_2 = @page.articles.build(:title => 'joensuu', :body => 'north karelian capital', :author => User.first).save!
|
13
|
+
@article_1 = Article.find_by_title('finland')
|
14
|
+
@article_2 = Article.find_by_title('joensuu')
|
15
|
+
|
16
|
+
@article_1.categories << @category
|
17
|
+
@article_2.categories << @child_category
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'all_contents returns a scope of all the contents of category and its descendants' do
|
21
|
+
assert_equal [@article_1, @article_2], @category.all_contents
|
22
|
+
assert_equal [@article_2], @child_category.all_contents
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'all_contents returns categories of a certain section only' do
|
26
|
+
# There is a 'a category' named category for a blog, a page and for a wiki,
|
27
|
+
# we do not want it to return wiki or blog category contents
|
28
|
+
category = Category.find_by_title('a category')
|
29
|
+
category.all_contents.each do |content|
|
30
|
+
content.should be_an(Article)
|
31
|
+
content.section.should be_a(Page)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class PageTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@site = Site.first
|
7
|
+
@page = Page.find_by_permalink('a-page')
|
8
|
+
end
|
9
|
+
|
10
|
+
test "Page.content_type returns 'Article'" do
|
11
|
+
Page.content_type.should == 'Article'
|
12
|
+
end
|
13
|
+
|
14
|
+
test "a page has a single_article_mode option that returns true by default" do
|
15
|
+
Page.new.should respond_to(:single_article_mode)
|
16
|
+
Page.new.should be_in_single_article_mode
|
17
|
+
end
|
18
|
+
|
19
|
+
# articles association
|
20
|
+
|
21
|
+
test "articles#primary returns the topmost published article" do
|
22
|
+
@page.articles.primary.should == Article.find_by_permalink('a-page-article')
|
23
|
+
end
|
24
|
+
|
25
|
+
# PUBLIC INSTANCE METHODS
|
26
|
+
test "#published?, published_at and published_at= are delegated to article (single article mode)" do
|
27
|
+
parent_section = Page.new(:site => @site, :single_article_mode => false)
|
28
|
+
parent_section.save(false)
|
29
|
+
page = Page.new(:site => @site)
|
30
|
+
page.save(false)
|
31
|
+
page.move_to_child_of(parent_section)
|
32
|
+
article = page.articles.build(:published_at => nil)
|
33
|
+
|
34
|
+
article.should_not be_published
|
35
|
+
page.should_not be_published
|
36
|
+
page.published_at.should be_nil
|
37
|
+
|
38
|
+
article.published_at = Time.local(2009, 5, 19, 12, 0, 0)
|
39
|
+
article.should be_published
|
40
|
+
page.should be_published
|
41
|
+
page.published_at.should == Time.local(2009, 5, 19, 12, 0, 0)
|
42
|
+
|
43
|
+
page.published_at = Time.local(2009, 5, 19, 14, 0, 0)
|
44
|
+
article.published_at.should == Time.local(2009, 5, 19, 14, 0, 0)
|
45
|
+
|
46
|
+
page.published_at = nil
|
47
|
+
page.should_not be_published
|
48
|
+
article.should_not be_published
|
49
|
+
end
|
50
|
+
|
51
|
+
test "#published? is false if any ancestor section is not published (single article mode)" do
|
52
|
+
parent_section = Page.new(:site => @site, :published_at => nil)
|
53
|
+
parent_section.save(false)
|
54
|
+
# TODO: nested set bug?
|
55
|
+
# section = Page.new(:site => @site, :parent => parent_section, :published_at => 2.days.ago, :single_article_mode => false)
|
56
|
+
page = Page.new(:site => @site)
|
57
|
+
page.save(false)
|
58
|
+
page.move_to_child_of(parent_section)
|
59
|
+
article = page.articles.build(:published_at => 2.days.ago)
|
60
|
+
|
61
|
+
page.published?(true).should be_false
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,315 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class SectionTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@site = Site.first
|
7
|
+
@section = @site.sections.first
|
8
|
+
@new_section = Section.new(:site => @site, :title => 'a test section', :parent_id => @section.id)
|
9
|
+
@unpublished_section = Section.find_by_title('an unpublished section')
|
10
|
+
end
|
11
|
+
|
12
|
+
test "acts as a role context for the moderator role" do
|
13
|
+
Section.should act_as_role_context(:roles => :moderator)
|
14
|
+
end
|
15
|
+
|
16
|
+
test "serializes its actual permissions" do
|
17
|
+
Section.serialized_attributes.keys.should include('permissions')
|
18
|
+
end
|
19
|
+
|
20
|
+
test "has an option :contents_per_page" do
|
21
|
+
lambda{ @section.contents_per_page }.should_not raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
test "serialize the option :contents_per_page to the database" do
|
25
|
+
@section.instance_variable_set(:@options, nil)
|
26
|
+
@section.save; @section.reload
|
27
|
+
@section.contents_per_page.should == Section.option_definitions[:contents_per_page][:default]
|
28
|
+
|
29
|
+
@section.contents_per_page = 20
|
30
|
+
@section.save; @section.reload
|
31
|
+
@section.contents_per_page.should == 20
|
32
|
+
end
|
33
|
+
|
34
|
+
test "has a permalink generated from the title" do
|
35
|
+
Category.should have_permalink(:title)
|
36
|
+
|
37
|
+
@section.title = 'new section title'
|
38
|
+
@section.permalink = nil
|
39
|
+
@section.send(:ensure_unique_url)
|
40
|
+
@section.permalink.should == 'new-section-title'
|
41
|
+
end
|
42
|
+
|
43
|
+
test "acts as a nested set" do
|
44
|
+
Section.should act_as_nested_set
|
45
|
+
end
|
46
|
+
|
47
|
+
test "has many comments" do
|
48
|
+
Section.should have_many_comments
|
49
|
+
end
|
50
|
+
|
51
|
+
test "instantiates with single table inheritance" do
|
52
|
+
Section.should instantiate_with_sti
|
53
|
+
end
|
54
|
+
|
55
|
+
test "has a comments counter" do
|
56
|
+
Section.should have_counter(:comments)
|
57
|
+
end
|
58
|
+
|
59
|
+
test "belongs to a site" do
|
60
|
+
@section.should belong_to(:site)
|
61
|
+
end
|
62
|
+
|
63
|
+
test "has many articles" do
|
64
|
+
@section.should have_many(:articles)
|
65
|
+
end
|
66
|
+
|
67
|
+
test "has many categories" do
|
68
|
+
@section.should have_many(:categories)
|
69
|
+
end
|
70
|
+
|
71
|
+
# categories association
|
72
|
+
|
73
|
+
test "categories#roots returns all categories that do not have a parent category" do
|
74
|
+
mock(@section.categories).find(:all, hash_including(:conditions => { :parent_id => nil }))
|
75
|
+
@section.categories.roots
|
76
|
+
end
|
77
|
+
|
78
|
+
# callbacks
|
79
|
+
|
80
|
+
test "sets the comment age before validation" do
|
81
|
+
Section.before_validation.should include(:set_comment_age)
|
82
|
+
end
|
83
|
+
|
84
|
+
test "updates the path before save" do
|
85
|
+
Section.before_save.should include(:update_path)
|
86
|
+
end
|
87
|
+
|
88
|
+
# validations
|
89
|
+
|
90
|
+
# FIXME ... seems to break with install_controller#index
|
91
|
+
# test "validates the presence of a site" do
|
92
|
+
# @section.should validate_presence_of(:site)
|
93
|
+
# end
|
94
|
+
|
95
|
+
test "validates the presence of a title" do
|
96
|
+
@section.should validate_presence_of(:title)
|
97
|
+
end
|
98
|
+
|
99
|
+
test "validates the uniqueness of the permalink per site" do
|
100
|
+
@section.should validate_uniqueness_of(:permalink, :scope => :site_id)
|
101
|
+
end
|
102
|
+
|
103
|
+
# CLASS METHODS
|
104
|
+
|
105
|
+
test "Section.types returns a collection of registered Section types" do
|
106
|
+
Section.types.should include('Page')
|
107
|
+
end
|
108
|
+
|
109
|
+
test "Section.register_type adds a Section type to the type collection" do
|
110
|
+
Section.register_type('Galerie')
|
111
|
+
Section.types.should include('Galerie')
|
112
|
+
end
|
113
|
+
|
114
|
+
test "Section.register_type should not shift 'Page' from the top position" do
|
115
|
+
Section.register_type('123-foo-bar')
|
116
|
+
Section.types.first.should == 'Page'
|
117
|
+
end
|
118
|
+
|
119
|
+
# PUBLIC INSTANCE METHODS
|
120
|
+
|
121
|
+
test "#type returns 'Page' for a Page" do
|
122
|
+
s = Page.create!(:title => 'title', :site => @site)
|
123
|
+
s.type.should == 'Page'
|
124
|
+
end
|
125
|
+
|
126
|
+
test "#owner returns the site" do
|
127
|
+
@section.owner.should == @site
|
128
|
+
end
|
129
|
+
|
130
|
+
test "#tag_counts returns the tag_counts for this site's content's tags" do
|
131
|
+
mock(Content).tag_counts(:conditions => "section_id = #{@section.id}")
|
132
|
+
@section.tag_counts
|
133
|
+
end
|
134
|
+
|
135
|
+
# FIXME
|
136
|
+
# test "#render_options should be specified but looks pretty uncomprehensible right now"
|
137
|
+
|
138
|
+
test "#root_section? returns true if this section is the site's root section" do
|
139
|
+
@site.sections.root.should be_root_section
|
140
|
+
Section.new(:site => @site).should_not be_root_section
|
141
|
+
end
|
142
|
+
|
143
|
+
test "#accept_comments? is true when comments are not 'not-allowed' (-1) (see comment_expiration_options)" do
|
144
|
+
@section.comment_age = 0
|
145
|
+
@section.should accept_comments
|
146
|
+
end
|
147
|
+
|
148
|
+
test "#accept_comments? is false when comments are 'not-allowed' (-1) (see comment_expiration_options)" do
|
149
|
+
@section.comment_age = -1
|
150
|
+
@section.should_not accept_comments
|
151
|
+
end
|
152
|
+
|
153
|
+
test "#state returns :pending if section isn't published" do
|
154
|
+
page = Page.new(:site => @site, :single_article_mode => false)
|
155
|
+
page.save(false)
|
156
|
+
page.update_attribute(:published_at, nil)
|
157
|
+
|
158
|
+
page.move_to_child_of(@section)
|
159
|
+
|
160
|
+
page.state.should == :pending
|
161
|
+
|
162
|
+
page.published_at = 2.days.from_now
|
163
|
+
page.state.should == :pending
|
164
|
+
end
|
165
|
+
|
166
|
+
test "#state returns :published if section is published" do
|
167
|
+
page = Page.new(:site => @site, :single_article_mode => false)
|
168
|
+
page.save(false)
|
169
|
+
page.move_to_child_of(@section)
|
170
|
+
|
171
|
+
page.published_at = 2.days.ago
|
172
|
+
page.state.should == :published
|
173
|
+
end
|
174
|
+
|
175
|
+
test "#published? is always true for root section" do
|
176
|
+
@section.published_at = nil
|
177
|
+
@section.should be_published
|
178
|
+
end
|
179
|
+
|
180
|
+
test "#published? is true when published_at is set to a date in the past" do
|
181
|
+
page = Page.new(:site => @site, :single_article_mode => false)
|
182
|
+
page.save(false)
|
183
|
+
page.move_to_child_of(@section)
|
184
|
+
|
185
|
+
page.published_at = 2.days.ago
|
186
|
+
page.should be_published
|
187
|
+
end
|
188
|
+
|
189
|
+
test "#published? is false when published_at is not set or set to a date in the future" do
|
190
|
+
page = Page.new(:site => @site, :single_article_mode => false)
|
191
|
+
page.save(false)
|
192
|
+
page.move_to_child_of(@section)
|
193
|
+
|
194
|
+
page.published_at = nil
|
195
|
+
page.should_not be_published
|
196
|
+
|
197
|
+
page.published_at = 2.days.from_now
|
198
|
+
page.should_not be_published
|
199
|
+
end
|
200
|
+
|
201
|
+
# TODO - check if necessary - could (or should) be implemented on controller level
|
202
|
+
test "#published? is true if all ancestors are published too" do
|
203
|
+
# TODO: nested set bug?
|
204
|
+
# section = Page.new(:site => @site, :parent => parent_section, :published_at => 2.days.ago, :single_article_mode => false)
|
205
|
+
section = Page.new(:title => 'test section', :site => @site, :published_at => 2.days.ago, :single_article_mode => false)
|
206
|
+
section.save(false)
|
207
|
+
section.move_to_child_of(@section)
|
208
|
+
|
209
|
+
section.published?(true).should be_true
|
210
|
+
end
|
211
|
+
|
212
|
+
test "#published? is false if any ancestor is not published" do
|
213
|
+
# TODO: nested set bug?
|
214
|
+
# section = Page.new(:site => @site, :parent => parent_section, :published_at => 2.days.ago, :single_article_mode => false)
|
215
|
+
section = Page.new(:site => @site, :published_at => 2.days.ago, :single_article_mode => false)
|
216
|
+
section.save(false)
|
217
|
+
section.move_to_child_of(@unpublished_section)
|
218
|
+
|
219
|
+
section.published?(true).should be_false
|
220
|
+
end
|
221
|
+
|
222
|
+
test "#published= sets published_at to current time if set to 1 and published_at is blank" do
|
223
|
+
stub(Time).now { Time.local(2009, 5, 20, 12, 0, 0) }
|
224
|
+
section = Page.new(:single_article_mode => false)
|
225
|
+
section.published_at = nil
|
226
|
+
|
227
|
+
section.published = '1'
|
228
|
+
section.published_at.should == Time.local(2009, 5, 20, 12, 0, 0)
|
229
|
+
end
|
230
|
+
|
231
|
+
test "#published= sets published_at to nil if set to 0" do
|
232
|
+
section = Page.new(:single_article_mode => false)
|
233
|
+
section.published_at = 2.days.ago
|
234
|
+
|
235
|
+
section.published = '0'
|
236
|
+
section.published_at.should be_nil
|
237
|
+
end
|
238
|
+
|
239
|
+
# PROTECTED INSTANCE METHODS
|
240
|
+
|
241
|
+
test "#set_comment_age sets the comment_age to -1 if it's not already set" do
|
242
|
+
@section.comment_age = nil
|
243
|
+
@section.send(:set_comment_age)
|
244
|
+
@section.comment_age.should_not be_nil
|
245
|
+
end
|
246
|
+
|
247
|
+
test "#set_comment_age does not change an already set comment_age" do
|
248
|
+
@section.comment_age = 99
|
249
|
+
@section.send(:set_comment_age)
|
250
|
+
@section.comment_age.should == 99
|
251
|
+
end
|
252
|
+
|
253
|
+
test "#update_path rebuilds the section's path when the permalink has changed" do
|
254
|
+
# grrr ... can't stub dynamic methods with RR
|
255
|
+
# stub(@section).permalink_changed?.returns(true)
|
256
|
+
stub(@section).attribute_changed?('permalink').returns(true)
|
257
|
+
mock(@section).build_path.returns('the-new-path')
|
258
|
+
@section.send(:update_path)
|
259
|
+
@section.path.should == 'the-new-path'
|
260
|
+
end
|
261
|
+
|
262
|
+
test "#build_path builds a path by joining self and anchestor permalinks with '/'" do
|
263
|
+
section = bunch_of_nested_sections!
|
264
|
+
section.send(:build_path).should == "home/about/location"
|
265
|
+
end
|
266
|
+
|
267
|
+
test "#update_paths moves a new section to a child of its parent and updates the section paths" do
|
268
|
+
@new_section.save
|
269
|
+
assert_equal @section, @new_section.parent
|
270
|
+
end
|
271
|
+
|
272
|
+
test "publish sections by default" do
|
273
|
+
@new_section.save
|
274
|
+
assert_equal true, @new_section.published
|
275
|
+
end
|
276
|
+
|
277
|
+
test "publish sections by default, but respect user set published_at time" do
|
278
|
+
time = Time.local(2009, 5, 20, 12, 0, 0)
|
279
|
+
@new_section.published_at = time
|
280
|
+
@new_section.save
|
281
|
+
assert_equal time, @new_section.published_at
|
282
|
+
end
|
283
|
+
|
284
|
+
test "#update_paths should not lose the title of the section while moving the section - a bug fix" do
|
285
|
+
unnested_section = Section.new(:site => @site, :title => 'unnested section')
|
286
|
+
assert_equal 'unnested section', unnested_section.title
|
287
|
+
assert unnested_section.save
|
288
|
+
assert_equal 'unnested section', unnested_section.title
|
289
|
+
assert_equal 'a test section', @new_section.title
|
290
|
+
assert @new_section.save
|
291
|
+
assert_equal 'a test section', @new_section.title
|
292
|
+
end
|
293
|
+
|
294
|
+
# NESTED SET
|
295
|
+
|
296
|
+
test "initializes the lft and rgt attributes" do
|
297
|
+
home, about, location = *bunch_of_sections!
|
298
|
+
expected = [about.lft - 2, about.rgt - 2, location.lft - 2, location.rgt - 2]
|
299
|
+
[home.lft, home.rgt, about.lft, about.rgt].should == expected
|
300
|
+
end
|
301
|
+
|
302
|
+
def bunch_of_sections!
|
303
|
+
home = @site.sections.create!(:title => 'homepage', :permalink => 'home')
|
304
|
+
about = @site.sections.create!(:title => 'about us', :permalink => 'about')
|
305
|
+
location = @site.sections.create!(:title => 'how to find us', :permalink => 'location')
|
306
|
+
[home, about, location]
|
307
|
+
end
|
308
|
+
|
309
|
+
def bunch_of_nested_sections!
|
310
|
+
home, about, location = *bunch_of_sections!
|
311
|
+
about.move_to_child_of(home)
|
312
|
+
location.move_to_child_of(about)
|
313
|
+
location
|
314
|
+
end
|
315
|
+
end
|