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,191 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class ArticleTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@page = Page.first
|
7
|
+
@article = @page.articles.published.first
|
8
|
+
end
|
9
|
+
|
10
|
+
test "sanitizes the attributes excerpt, excerpt_html, body and body_html" do
|
11
|
+
Article.should filter_attributes(:except => [:excerpt, :excerpt_html, :body, :body_html, :cached_tag_list])
|
12
|
+
end
|
13
|
+
|
14
|
+
test "has many comments" do
|
15
|
+
Article.should have_many_comments
|
16
|
+
end
|
17
|
+
|
18
|
+
test "sets the position before create" do
|
19
|
+
Article.before_create.should include(:set_position)
|
20
|
+
end
|
21
|
+
|
22
|
+
# validations
|
23
|
+
|
24
|
+
# FIXME implement!
|
25
|
+
test "validates presence of an author (through belongs_to_author)" do
|
26
|
+
@article.should validate_presence_of(:author)
|
27
|
+
end
|
28
|
+
|
29
|
+
test "validates that the author is valid (through belongs_to_author)" do
|
30
|
+
@article.author = User.new
|
31
|
+
@article.should_not be_valid
|
32
|
+
end
|
33
|
+
|
34
|
+
test "validates the uniqueness of the permalink per section" do
|
35
|
+
@article = Article.new
|
36
|
+
@article.should validate_uniqueness_of(:permalink, :scope => :section_id)
|
37
|
+
end
|
38
|
+
|
39
|
+
# # CLASS METHODS
|
40
|
+
#
|
41
|
+
# # find_by_permalink
|
42
|
+
|
43
|
+
test "#find_by_permalink finds articles within passed time span" do
|
44
|
+
article = Article.find_by_permalink '2008', '1', '1', 'a-page-article'
|
45
|
+
article.permalink.should == 'a-page-article'
|
46
|
+
article.published_at.to_date.should == Time.utc('2008', '1', '1').to_date
|
47
|
+
end
|
48
|
+
|
49
|
+
test "#find_by_permalink finds a record when the passed date scope matches the article's published date" do
|
50
|
+
date = [:year, :month, :day].map {|key| @article.published_at.send(key).to_s }
|
51
|
+
@page.articles.find_by_permalink(*date << @article.permalink).should == @article
|
52
|
+
end
|
53
|
+
|
54
|
+
test "#find_by_permalink does not find a record when the passed date scope does not match the article's published date" do
|
55
|
+
date = [:year, :month, :day].map {|key| @article.published_at.send(key).to_s }
|
56
|
+
date[2] = date[2].to_i + 1
|
57
|
+
@page.articles.find_by_permalink(*date << @article.permalink).should be_nil
|
58
|
+
end
|
59
|
+
|
60
|
+
test "#find_by_permalink finds a record when no date scope is passed" do
|
61
|
+
Article.find_by_permalink(@article.permalink).should == @article
|
62
|
+
end
|
63
|
+
|
64
|
+
# INSTANCE METHODS
|
65
|
+
|
66
|
+
# full_permalink
|
67
|
+
|
68
|
+
test '#full_permalink returns a hash with the year, month, day and permalink' do
|
69
|
+
@article.section = Blog.new
|
70
|
+
@article.full_permalink.should == { :year => @article.published_at.year.to_i,
|
71
|
+
:month => @article.published_at.month.to_i,
|
72
|
+
:day => @article.published_at.day.to_i,
|
73
|
+
:permalink => @article.permalink }
|
74
|
+
end
|
75
|
+
|
76
|
+
test '#full_permalink raises an exception when the article does not belong to a Blog' do
|
77
|
+
lambda{ @article.full_permalink }.should raise_error
|
78
|
+
end
|
79
|
+
|
80
|
+
# FIXME not true right now, investigate if we want this at all
|
81
|
+
# test '#full_permalink raises an exception when the article is not published' do
|
82
|
+
# @article.reload
|
83
|
+
# @article.published_at = nil
|
84
|
+
# lambda{ @article.full_permalink }.should raise_error
|
85
|
+
# end
|
86
|
+
|
87
|
+
# primary?
|
88
|
+
|
89
|
+
test "#primary? returns true when the article is its section's primary article" do
|
90
|
+
@page.articles.primary.should be_primary
|
91
|
+
end
|
92
|
+
|
93
|
+
test "#primary? returns false when the article is not section's primary article" do
|
94
|
+
@page.articles.build.should_not be_primary
|
95
|
+
end
|
96
|
+
|
97
|
+
# has_excerpt?
|
98
|
+
test "has an excerpt if the excerpt is not blank" do
|
99
|
+
@article.excerpt = 'excerpt'
|
100
|
+
@article.should have_excerpt
|
101
|
+
end
|
102
|
+
|
103
|
+
test "does not have an excerpt if the excerpt is nil or blank" do
|
104
|
+
@article.excerpt = nil
|
105
|
+
@article.should_not have_excerpt
|
106
|
+
|
107
|
+
@article.excerpt = ''
|
108
|
+
@article.should_not have_excerpt
|
109
|
+
end
|
110
|
+
|
111
|
+
# accept_comments?
|
112
|
+
|
113
|
+
test "accepts comments if comments are set to never expire" do
|
114
|
+
# FIXME wtf, srsly. use CONSTANTS instead of integers. that's what they are for.
|
115
|
+
@article.comment_age = 0
|
116
|
+
@article.published_at = 1.days.ago
|
117
|
+
@article.should accept_comments
|
118
|
+
end
|
119
|
+
|
120
|
+
test "accepts comments if comments are allowed and not yet expired" do
|
121
|
+
@article.comment_age = 3
|
122
|
+
@article.published_at = 1.days.ago
|
123
|
+
@article.should accept_comments
|
124
|
+
end
|
125
|
+
|
126
|
+
test "does not accept comments if comments are allowed but already expired" do
|
127
|
+
@article.comment_age = 1
|
128
|
+
@article.published_at = 1.days.ago
|
129
|
+
@article.should_not accept_comments
|
130
|
+
end
|
131
|
+
|
132
|
+
test "does not accept comments if comments are not allowed" do
|
133
|
+
@article.comment_age = -1
|
134
|
+
@article.published_at = 1.days.ago
|
135
|
+
@article.should_not accept_comments
|
136
|
+
end
|
137
|
+
|
138
|
+
test "does not accept comments if the article is not published" do
|
139
|
+
@article.comment_age = 0
|
140
|
+
@article.published_at = nil
|
141
|
+
@article.should_not accept_comments
|
142
|
+
end
|
143
|
+
|
144
|
+
# FIXME test the actual model instead
|
145
|
+
|
146
|
+
# # previous
|
147
|
+
#
|
148
|
+
# test "#previous finds the previous published article in the article's section" do
|
149
|
+
# options = {:conditions => ["published_at < ?", @article.published_at], :order=>:published_at}
|
150
|
+
# mock(Article).published(options)
|
151
|
+
# @article.previous
|
152
|
+
# end
|
153
|
+
#
|
154
|
+
# # next
|
155
|
+
#
|
156
|
+
# test "#next finds the next published article in the article's section" do
|
157
|
+
# options = {:conditions => ["published_at > ?", @article.published_at], :order=>:published_at}
|
158
|
+
# mock(Article).find_published(:first, options)
|
159
|
+
# @article.next
|
160
|
+
# end
|
161
|
+
|
162
|
+
# set_position
|
163
|
+
|
164
|
+
test "#set_position sorts the article to the bottom of the list (sets to max(position) + 1)" do
|
165
|
+
article = @page.articles.create! :title => 'title', :body => 'body', :author => User.first
|
166
|
+
article.position.should == @page.articles.maximum(:position).to_i
|
167
|
+
end
|
168
|
+
|
169
|
+
# move_to
|
170
|
+
|
171
|
+
test "#move_to moves the article to the right of given :left_id article" do
|
172
|
+
article = @page.articles.create! :title => 'title', :body => 'body', :author => User.first
|
173
|
+
article.move_to(:left_id => @page.articles.first.id)
|
174
|
+
article.reload.position.should == 2
|
175
|
+
Article.find(@page.articles.first.id).position.should == 1
|
176
|
+
end
|
177
|
+
|
178
|
+
test "#has_excerpt? works with fckenabled" do
|
179
|
+
@article.excerpt = "<p> </p>"
|
180
|
+
@article.should_not have_excerpt
|
181
|
+
end
|
182
|
+
|
183
|
+
# filtering
|
184
|
+
|
185
|
+
test "it allows using insecure html in article body and excerpt" do
|
186
|
+
@article.body = 'p{position:absolute; top:50px; left:10px; width:150px; height:150px}. insecure css'
|
187
|
+
@article.filter = 'textile_filter'
|
188
|
+
@article.save(false)
|
189
|
+
@article.body_html.should == %(<p style="position:absolute; top:50px; left:10px; width:150px; height:150px;">insecure css</p>)
|
190
|
+
end
|
191
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class CategoryTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@page = Page.first
|
7
|
+
@category = @page.categories.first
|
8
|
+
@new_category = Category.new(:section => @page, :title => 'a category', :parent => @category)
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'acts as a nested set' do
|
12
|
+
Category.should act_as_nested_set
|
13
|
+
end
|
14
|
+
|
15
|
+
test "has a permalink generated from the title" do
|
16
|
+
Category.should have_permalink(:title)
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'generates a permalink from the title' do
|
20
|
+
@category.title = "a category's title"
|
21
|
+
@category.permalink = nil
|
22
|
+
@category.send :ensure_unique_url
|
23
|
+
@category.permalink.should == 'a-categorys-title'
|
24
|
+
end
|
25
|
+
|
26
|
+
# ASSOCIATIONS
|
27
|
+
|
28
|
+
test "belongs to a section" do
|
29
|
+
@category.should belong_to(:section)
|
30
|
+
end
|
31
|
+
|
32
|
+
test "has many contents" do
|
33
|
+
@category.should have_many(:contents)
|
34
|
+
end
|
35
|
+
|
36
|
+
test "has many categorizations" do
|
37
|
+
@category.should have_many(:categorizations)
|
38
|
+
end
|
39
|
+
|
40
|
+
# VALIDATIONS
|
41
|
+
|
42
|
+
test 'validates the presence of a section' do
|
43
|
+
@category.should validate_presence_of(:section)
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'validates the presence of a title' do
|
47
|
+
@category.should validate_presence_of(:title)
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'validates the uniqueness of the permalink per section' do
|
51
|
+
@category.section = @page
|
52
|
+
@category.should validate_uniqueness_of(:permalink, :scope => :section_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
# CALLBACKS
|
56
|
+
|
57
|
+
test "#update_paths moves a new category to a child of its parent and updates the category paths" do
|
58
|
+
@new_category.save
|
59
|
+
@new_category.should be_child_of(@category)
|
60
|
+
end
|
61
|
+
|
62
|
+
# FIXME
|
63
|
+
#
|
64
|
+
# describe 'instance methods:' do
|
65
|
+
# test '#set_path should be specified'
|
66
|
+
# test '#update_child_paths usage + behaviour should be specified' # (this certainly can be done better)
|
67
|
+
# end
|
68
|
+
end
|
@@ -0,0 +1,409 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class ContentTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@page = Page.first
|
7
|
+
@content = @page.articles.first
|
8
|
+
@content_attributes = { :title => 'A new content', :body => 'body',:section => @page, :author => User.first }
|
9
|
+
end
|
10
|
+
|
11
|
+
test "acts as a taggable" do
|
12
|
+
Content.should act_as_taggable
|
13
|
+
end
|
14
|
+
|
15
|
+
test "acts as a role context for the author role" do
|
16
|
+
Content.should act_as_role_context(:roles => :author)
|
17
|
+
end
|
18
|
+
|
19
|
+
test "acts as versioned" do
|
20
|
+
Content.versioned_attributes.should_not be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
test "is configured to save a new version when the title, body or excerpt attribute changes" do
|
24
|
+
Content.versioned_attributes.should == [ :title, :body, :excerpt, :body_html, :excerpt_html ]
|
25
|
+
end
|
26
|
+
|
27
|
+
test "is configured to save up to 5 versions" do
|
28
|
+
Content.max_version_limit.should == 5
|
29
|
+
end
|
30
|
+
|
31
|
+
test "instantiates with single table inheritance" do
|
32
|
+
Content.should instantiate_with_sti
|
33
|
+
end
|
34
|
+
|
35
|
+
test "has a permalink generated from the title" do
|
36
|
+
Content.should have_permalink(:title)
|
37
|
+
end
|
38
|
+
|
39
|
+
test "filters the excerpt and body" do
|
40
|
+
@content.should filter_column(:excerpt)
|
41
|
+
@content.should filter_column(:body)
|
42
|
+
end
|
43
|
+
|
44
|
+
test "has many comments" do
|
45
|
+
Content.should have_many_comments
|
46
|
+
end
|
47
|
+
|
48
|
+
test "has a comments counter" do
|
49
|
+
Content.should have_counter(:comments)
|
50
|
+
end
|
51
|
+
|
52
|
+
# ASSOCIATIONS
|
53
|
+
|
54
|
+
test "belongs to a site" do
|
55
|
+
@content.should belong_to(:site)
|
56
|
+
end
|
57
|
+
|
58
|
+
test "belongs to a section" do
|
59
|
+
@content.should belong_to(:section)
|
60
|
+
end
|
61
|
+
|
62
|
+
test "belongs to an author" do
|
63
|
+
@content.should belong_to(:author)
|
64
|
+
end
|
65
|
+
|
66
|
+
test "has many assets" do
|
67
|
+
@content.should have_many(:assets)
|
68
|
+
end
|
69
|
+
|
70
|
+
test "has many asset_assignments" do
|
71
|
+
@content.should have_many(:asset_assignments)
|
72
|
+
end
|
73
|
+
|
74
|
+
test "has many categories" do
|
75
|
+
@content.should have_many(:categories)
|
76
|
+
end
|
77
|
+
|
78
|
+
test "has many categorizations" do
|
79
|
+
@content.should have_many(:categorizations)
|
80
|
+
end
|
81
|
+
|
82
|
+
# CALLBACKS
|
83
|
+
|
84
|
+
test "sets the site before validation" do
|
85
|
+
Content.before_validation.should include(:set_site)
|
86
|
+
end
|
87
|
+
|
88
|
+
test "apply filters before save" do
|
89
|
+
Content.before_save.should include(:process_filters)
|
90
|
+
end
|
91
|
+
|
92
|
+
# VALIDATIONS
|
93
|
+
|
94
|
+
test "validates presence of a title" do
|
95
|
+
@content.should validate_presence_of(:title)
|
96
|
+
end
|
97
|
+
|
98
|
+
test "validates presence of a body" do
|
99
|
+
@content.should validate_presence_of(:body)
|
100
|
+
end
|
101
|
+
|
102
|
+
# SCOPES
|
103
|
+
|
104
|
+
test "published scope returns published articles" do
|
105
|
+
Content.published.map(&:published?).uniq.should == [true]
|
106
|
+
end
|
107
|
+
|
108
|
+
test "published scope given a :year option returns articles published in that year" do
|
109
|
+
contents = Content.published('2008')
|
110
|
+
years = contents.map(&:published_at).map(&:year).uniq
|
111
|
+
years.should == [2008]
|
112
|
+
end
|
113
|
+
|
114
|
+
test "published scope given :year and :month options returns articles published in that month" do
|
115
|
+
contents = Content.published('2008', '1')
|
116
|
+
months = contents.map(&:published_at).map { |d| [d.year, d.month] }.uniq.flatten
|
117
|
+
months.should == [2008, 1]
|
118
|
+
end
|
119
|
+
|
120
|
+
test "published scope given :year, :month and day options returns articles published on that day" do
|
121
|
+
contents = Content.published('2008', '1', '1')
|
122
|
+
months = contents.map(&:published_at).map { |d| [d.year, d.month, d.day] }.uniq.flatten
|
123
|
+
months.should == [2008, 1, 1]
|
124
|
+
end
|
125
|
+
|
126
|
+
# FIXME delete these?
|
127
|
+
# # CLASS METHODS
|
128
|
+
#
|
129
|
+
# test "#find_published finds published articles" do
|
130
|
+
# @content.update_attributes! :published_at => 1.hour.ago
|
131
|
+
# Content.find_published(:all).should include(@content)
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
# test "#find_published does not find unpublished articles" do
|
135
|
+
# @content.update_attributes! :published_at => nil
|
136
|
+
# Content.find_published(:all).should_not include(@content)
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
# test "#find_in_time_delta finds articles in the given time delta" do
|
140
|
+
# published_at = date = 1.hour.ago
|
141
|
+
# delta = date.year, date.month, date.day
|
142
|
+
# @content.update_attributes! :published_at => published_at
|
143
|
+
# Content.find_in_time_delta(*delta).should include(@content)
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# test "#find_in_time_delta finds articles prior the given time delta" do
|
147
|
+
# published_at = 1.hour.ago
|
148
|
+
# date = 2.months.ago
|
149
|
+
# delta = date.year, date.month, date.day
|
150
|
+
# @content.update_attributes! :published_at => published_at
|
151
|
+
# Content.find_in_time_delta(*delta).should_not include(@content)
|
152
|
+
# end
|
153
|
+
#
|
154
|
+
# test "#find_in_time_delta finds articles after the given time delta" do
|
155
|
+
# published_at = 2.month.ago
|
156
|
+
# date = Time.zone.now
|
157
|
+
# delta = date.year, date.month, date.day
|
158
|
+
# @content.update_attributes! :published_at => published_at
|
159
|
+
# Content.find_in_time_delta(*delta).should_not include(@content)
|
160
|
+
# end
|
161
|
+
#
|
162
|
+
# INSTANCE METHODS
|
163
|
+
|
164
|
+
test "#owner returns the section" do
|
165
|
+
@content.owner.should == @page
|
166
|
+
end
|
167
|
+
|
168
|
+
# published_month
|
169
|
+
|
170
|
+
test '#published_month returns a time object for the first day of the month the content was published in' do
|
171
|
+
@content.published_month.should == Time.local(@content.published_at.year, @content.published_at.month, 1)
|
172
|
+
end
|
173
|
+
|
174
|
+
# draft?
|
175
|
+
|
176
|
+
test '#draft? returns true when the content has not published_at date' do
|
177
|
+
@content.published_at = nil
|
178
|
+
@content.should be_draft
|
179
|
+
end
|
180
|
+
|
181
|
+
test '#draft? returns false when the content has a published_at date' do
|
182
|
+
@content.published_at = 1.days.ago
|
183
|
+
@content.should_not be_draft
|
184
|
+
end
|
185
|
+
|
186
|
+
# published?
|
187
|
+
|
188
|
+
test "#published? returns true when published_at equals the current time" do
|
189
|
+
@content.published_at = Time.zone.now
|
190
|
+
@content.should be_published
|
191
|
+
end
|
192
|
+
|
193
|
+
test "#published? returns true when published_at is a past date" do
|
194
|
+
@content.published_at = 1.day.ago
|
195
|
+
@content.should be_published
|
196
|
+
end
|
197
|
+
|
198
|
+
test "#published? returns false when published_at is a future date" do
|
199
|
+
@content.published_at = 1.day.from_now
|
200
|
+
@content.should_not be_published
|
201
|
+
end
|
202
|
+
|
203
|
+
test "#published? returns false when published_at is nil" do
|
204
|
+
@content.published_at = nil
|
205
|
+
@content.should_not be_published
|
206
|
+
end
|
207
|
+
|
208
|
+
# just_published?
|
209
|
+
|
210
|
+
test "just_published? is true when the content was published during the current request cycle" do
|
211
|
+
@content.update_attributes :published_at => Time.now
|
212
|
+
@content.just_published?.should be_true
|
213
|
+
end
|
214
|
+
|
215
|
+
test "just_published? is false when the content was published during a previous request cycle" do
|
216
|
+
@content.update_attributes :published_at => Time.now
|
217
|
+
@content.clear_changes!
|
218
|
+
@content.just_published?.should be_false
|
219
|
+
end
|
220
|
+
|
221
|
+
test "just_published? is false when the content is not published" do
|
222
|
+
@content.update_attributes :published_at => nil
|
223
|
+
@content.clear_changes!
|
224
|
+
@content.just_published?.should be_false
|
225
|
+
end
|
226
|
+
|
227
|
+
# FIXME seems to cause some transaction error on sqlite
|
228
|
+
# test "#attributes= calls update_categories if attributes include a :category_ids key" do
|
229
|
+
# mock(@content).update_categories.with([1, 2, 3])
|
230
|
+
# @content.attributes = { :category_ids => [1, 2, 3] }
|
231
|
+
# end
|
232
|
+
|
233
|
+
# # FIXME actually diff something
|
234
|
+
# #
|
235
|
+
# # describe "#diff_against_version" do
|
236
|
+
# # before do
|
237
|
+
# # stub(HtmlDiff).diff
|
238
|
+
# # @other = Content.new :body_html => 'body', :excerpt_html => 'excerpt'
|
239
|
+
# # @content.body_html = 'body'
|
240
|
+
# # @content.excerpt_html = 'excerpt'
|
241
|
+
# # # stub(@content.versions).find_by_version(anything).returns @other
|
242
|
+
# # end
|
243
|
+
# #
|
244
|
+
# # test "creates a diff" do
|
245
|
+
# # expectation do
|
246
|
+
# # mock(HtmlDiff).diff.with anything
|
247
|
+
# # @content.diff_against_version(1)
|
248
|
+
# # end
|
249
|
+
# # end
|
250
|
+
# #
|
251
|
+
# # test "diffs excerpt_html + body_html" do
|
252
|
+
# # [@content, @other].each do |target| [:body_html, :excerpt_html].each do |method|
|
253
|
+
# # mock(target).stub!(method).returns method.to_s
|
254
|
+
# # end end
|
255
|
+
# # @content.diff_against_version(1)
|
256
|
+
# # end
|
257
|
+
# # end
|
258
|
+
#
|
259
|
+
# FIXME use constants for comment_age!
|
260
|
+
test "#comments_expired_at returns a date 1 day after the published_at date if comments expire after 1 day" do
|
261
|
+
@content.comment_age = 1
|
262
|
+
@content.comments_expired_at.should == @content.published_at + 1.day
|
263
|
+
end
|
264
|
+
|
265
|
+
test "#comments_expired_at returns the published_at date if comments are not allowed (i.e. expire after 0 days)" do
|
266
|
+
@content.comment_age = 0
|
267
|
+
@content.comments_expired_at.should == @content.published_at
|
268
|
+
end
|
269
|
+
|
270
|
+
test "#comments_expired_at returns a date in far future if comments never expire" do
|
271
|
+
@content.comment_age = -1
|
272
|
+
@content.comments_expired_at.should > 9998.years.from_now
|
273
|
+
end
|
274
|
+
|
275
|
+
# set_site
|
276
|
+
test "#set_site sets the site_id from the section" do
|
277
|
+
@content.site_id = nil
|
278
|
+
@content.send :set_site
|
279
|
+
@content.site_id.should == @content.section.site_id
|
280
|
+
end
|
281
|
+
|
282
|
+
test '#update_categories removes associated categories that are not included in passed category_ids' do
|
283
|
+
@foo = Category.create!(:title => 'foo', :section => @page)
|
284
|
+
@bar = Category.create!(:title => 'bar', :section => @page)
|
285
|
+
|
286
|
+
@content.send(:update_categories, [@foo.id, @bar.id])
|
287
|
+
@content.categories.should_not include(@category)
|
288
|
+
end
|
289
|
+
|
290
|
+
test '#update_categories assigns categories that are included in passed category_ids but not already associated' do
|
291
|
+
@foo = Category.create!(:title => 'foo', :section => @page)
|
292
|
+
@bar = Category.create!(:title => 'bar', :section => @page)
|
293
|
+
|
294
|
+
@content.send(:update_categories, [@foo.id, @bar.id])
|
295
|
+
@content.categories.should include(@foo, @bar)
|
296
|
+
end
|
297
|
+
|
298
|
+
# PERMALINK CREATION
|
299
|
+
|
300
|
+
test "it generates a permalink from the title on create if the given permalink is empty" do
|
301
|
+
content = Content.create!(@content_attributes)
|
302
|
+
content.permalink.should == 'a-new-content'
|
303
|
+
end
|
304
|
+
|
305
|
+
test "it does not change the permalink on create if the given permalink is not empty" do
|
306
|
+
content = Content.create!(@content_attributes.update(:permalink => 'something-else'))
|
307
|
+
content.permalink.should == 'something-else'
|
308
|
+
end
|
309
|
+
|
310
|
+
test "it regenerates the permalink from the title on update when the permalink is deleted" do
|
311
|
+
old_permalink = @content.permalink
|
312
|
+
@content.update_attributes!(:permalink => '')
|
313
|
+
@content.permalink.should == old_permalink
|
314
|
+
end
|
315
|
+
|
316
|
+
test "it does not regenerate the permalink on update if not updated with a new permalink" do
|
317
|
+
old_permalink = @content.permalink
|
318
|
+
@content.update_attributes!(:body => 'just a new body')
|
319
|
+
@content.permalink.should == old_permalink
|
320
|
+
end
|
321
|
+
|
322
|
+
test "it does not regenerate the permalink on update if the given permalink is not empty" do
|
323
|
+
@content.update_attributes!(:permalink => 'something-else')
|
324
|
+
@content.permalink.should == 'something-else'
|
325
|
+
end
|
326
|
+
|
327
|
+
test "creates unique permalinks" do
|
328
|
+
content = nil
|
329
|
+
4.times { content = Content.create!(@content_attributes.merge(:title => "unique")) }
|
330
|
+
content.permalink.should == 'unique-3'
|
331
|
+
end
|
332
|
+
|
333
|
+
test "it removes characters from the permalink" do
|
334
|
+
title = "it's a test title, <em>okay</em>?"
|
335
|
+
content = Content.create!(@content_attributes.merge(:title => title))
|
336
|
+
content.permalink.should == "its-a-test-title-okay"
|
337
|
+
end
|
338
|
+
|
339
|
+
test "transliterates characters for permalinks" do
|
340
|
+
transliterations = {
|
341
|
+
%w(À Á Â Ã Å) => "A",
|
342
|
+
%w(Ä Æ) => "Ae",
|
343
|
+
"Ç" => "C",
|
344
|
+
"Ð" => "D",
|
345
|
+
%w(È É Ê Ë) => "E",
|
346
|
+
%w(Ì Í Î Ï) => "I",
|
347
|
+
"Ñ" => "N",
|
348
|
+
%w(Ò Ó Ô Õ Ø) => "O",
|
349
|
+
"Ö" => "Oe",
|
350
|
+
%w(Ù Ú Û) => "U",
|
351
|
+
"Ü" => "Ue",
|
352
|
+
# "Ý" => "Y", # StringEx transliteration is 'U'
|
353
|
+
# "Þ" => "p", # StringEx transliteration is 'th'
|
354
|
+
%w(à á â ã å) => "a",
|
355
|
+
%w(ä æ) => "ae",
|
356
|
+
"ç" => "c",
|
357
|
+
"ð" => "d",
|
358
|
+
%w(è é ê ë) => "e",
|
359
|
+
%w(ì í î ï) => "i",
|
360
|
+
"ñ" => "n",
|
361
|
+
%w(ò ó ô õ ø) => "o",
|
362
|
+
"ö" => "oe",
|
363
|
+
"ß" => "ss",
|
364
|
+
%w(ù ú û) => "u",
|
365
|
+
"ü" => "ue",
|
366
|
+
"ý" => "y"
|
367
|
+
}
|
368
|
+
|
369
|
+
source, expected = '', ''
|
370
|
+
transliterations.each do |from, to|
|
371
|
+
from = [from] unless from.is_a?(Array)
|
372
|
+
source << from.join
|
373
|
+
expected << to * from.size
|
374
|
+
end
|
375
|
+
|
376
|
+
source.to_url.should == expected.downcase
|
377
|
+
end
|
378
|
+
|
379
|
+
# VERSIONING
|
380
|
+
|
381
|
+
test "does not create a new version if neither title, excerpt nor body attributes have changed" do
|
382
|
+
@content.should_not save_version
|
383
|
+
end
|
384
|
+
|
385
|
+
test "creates a new version if the title attribute has changed" do
|
386
|
+
@content.title = 'another title'
|
387
|
+
@content.should save_version
|
388
|
+
end
|
389
|
+
|
390
|
+
test "creates a new version if the excerpt attribute has changed" do
|
391
|
+
@content.excerpt = 'another excerpt'
|
392
|
+
@content.should save_version
|
393
|
+
end
|
394
|
+
|
395
|
+
test "creates a new version if the body attribute has changed" do
|
396
|
+
@content.body = 'another body'
|
397
|
+
@content.should save_version
|
398
|
+
end
|
399
|
+
|
400
|
+
# TAGGING
|
401
|
+
|
402
|
+
test "works with quoted tags" do
|
403
|
+
@content.tag_list = '"foo bar"'
|
404
|
+
@content.save!
|
405
|
+
@content.reload
|
406
|
+
@content.tag_list.should == ['foo bar']
|
407
|
+
@content.cached_tag_list.should == '"foo bar"'
|
408
|
+
end
|
409
|
+
end
|