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,165 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class BaseHelperTest < ActionView::TestCase
|
4
|
+
include BaseHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@site = Site.first
|
9
|
+
stub(Time.zone).now.returns Time.local(2008, 1, 2)
|
10
|
+
stub(Time.zone.now).yesterday.returns Time.local(2008, 1, 1)
|
11
|
+
end
|
12
|
+
|
13
|
+
# LINK HELPERS
|
14
|
+
|
15
|
+
# method commented out, doesn't seem to be used anyway
|
16
|
+
# TODO: should probably solved differently?
|
17
|
+
# test "#link_to_section_main_action builds a link to Wikipages index if section is a Wiki" do
|
18
|
+
# @section = Wiki.first
|
19
|
+
# stub(self).admin_wikipages_path(@site, @section).returns('/path/to/wikipages')
|
20
|
+
# link_to_section_main_action(@site, @section)
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# test "#link_to_section_main_action builds a link to Articles index if section is a Blog" do
|
24
|
+
# @section = Blog.first
|
25
|
+
# stub(self).admin_articles_path(@site, @section).returns('/path/to/articles')
|
26
|
+
# link_to_section_main_action(@site, @section)
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# test "#link_to_section_main_action builds a link to Articles index if section is a Section" do
|
30
|
+
# @section = Section.first
|
31
|
+
# stub(self).admin_articles_path(@site, @section).returns('/path/to/articles')
|
32
|
+
# link_to_section_main_action(@site, @section)
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# test "#link_to_section_main_action builds a link to Boards index if section is a Forum" do
|
36
|
+
# @section = Forum.first
|
37
|
+
# stub(self).admin_boards_path(@site, @section).returns('/path/to/boards')
|
38
|
+
# link_to_section_main_action(@site, @section)
|
39
|
+
# end
|
40
|
+
|
41
|
+
# SPLIT_FORM_FOR
|
42
|
+
|
43
|
+
test '#split_form_for' do
|
44
|
+
@head = '<form action="path/to/article" method="post">'
|
45
|
+
@form = "the form\n</form>"
|
46
|
+
stub(self).with_output_buffer.returns "#{@head}\n#{@form}"
|
47
|
+
|
48
|
+
mock(self).content_for :form, @head # the form header tag is pushed to content_for :form
|
49
|
+
mock(self).concat 'the form' # the form body is concated to the current output buffer
|
50
|
+
split_form_for :foo
|
51
|
+
end
|
52
|
+
|
53
|
+
# FIXME ... wtf again
|
54
|
+
#
|
55
|
+
# test '#split_form_for' do
|
56
|
+
# stub(self).protect_against_forgery?.returns false
|
57
|
+
# self.output_buffer = ''
|
58
|
+
# split_form_for(Article.first, {:url => 'path/to/article'}) { }
|
59
|
+
# self.output_buffer ... is still empty at this point
|
60
|
+
# end
|
61
|
+
|
62
|
+
# FILTER OPTIONS
|
63
|
+
|
64
|
+
test '#filter_options returns a nested array containing the installed column filters' do
|
65
|
+
filter_options.sort.should == [["Plain HTML", ""],
|
66
|
+
["Markdown", "markdown_filter"],
|
67
|
+
["Markdown with Smarty Pants", "smartypants_filter"],
|
68
|
+
["Textile", "textile_filter"]].sort
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class BaseHelperAuthorOptionsTest < ActiveSupport::TestCase
|
73
|
+
include BaseHelper
|
74
|
+
|
75
|
+
def setup
|
76
|
+
super
|
77
|
+
|
78
|
+
@user = User.new :name => 'John Doe'
|
79
|
+
@member_1 = User.new :name => 'Donald Duck'
|
80
|
+
@member_2 = User.new :name => 'Uncle Scrooge'
|
81
|
+
|
82
|
+
@user.save(false)
|
83
|
+
@member_1.save(false)
|
84
|
+
@member_2.save(false)
|
85
|
+
|
86
|
+
stub(self).current_user.returns @user
|
87
|
+
end
|
88
|
+
|
89
|
+
# AUTHOR OPTIONS
|
90
|
+
|
91
|
+
test '#author_options returns a nested array containing the current user as a fallback option if the site does not have any members' do
|
92
|
+
users = []
|
93
|
+
author_options(users).should == [['John Doe', @user.id]]
|
94
|
+
end
|
95
|
+
|
96
|
+
test '#author_options returns a nested array containing the members of the site' do
|
97
|
+
users = [@user]
|
98
|
+
author_options(users).should == [['John Doe', @user.id]]
|
99
|
+
end
|
100
|
+
|
101
|
+
test '#author_options always returns current_user as an option along with the given users and makes sure user names are unique' do
|
102
|
+
expected_options = [['John Doe', @user.id], ['Donald Duck', @member_1.id], ['Uncle Scrooge', @member_2.id]]
|
103
|
+
author_options([@member_1, @member_2]).should == expected_options
|
104
|
+
author_options([@user, @member_1, @member_2, @user]).should == expected_options
|
105
|
+
end
|
106
|
+
|
107
|
+
test "#author_selected returns an id of current_user if article does not have an author" do
|
108
|
+
author_selected(nil).should == @user.id
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class BaseHelperMicroformatsTest < ActiveSupport::TestCase
|
113
|
+
include ActionView::Helpers::TranslationHelper
|
114
|
+
include BaseHelper
|
115
|
+
|
116
|
+
def setup
|
117
|
+
super
|
118
|
+
Time.zone = 'Vienna'
|
119
|
+
@utc_time = Time.utc 2008, 10, 9, 12, 0, 0
|
120
|
+
@local_time = Time.zone.local 2008, 10, 9, 14, 0, 0
|
121
|
+
end
|
122
|
+
|
123
|
+
def teardown
|
124
|
+
super
|
125
|
+
Time.zone = 'UTC'
|
126
|
+
end
|
127
|
+
|
128
|
+
# DATETIME MICROFORMAT HELPERS
|
129
|
+
|
130
|
+
test "#datetime_with_microformat displays the passed object when passed a non-Date/Time object" do
|
131
|
+
datetime_with_microformat(nil).should be_nil
|
132
|
+
datetime_with_microformat(1).should == 1
|
133
|
+
datetime_with_microformat('1').should == '1'
|
134
|
+
end
|
135
|
+
|
136
|
+
test "#datetime_with_microformat displays a UTC time" do
|
137
|
+
datetime_with_microformat(@utc_time).should ==
|
138
|
+
'<abbr class="datetime" title="2008-10-09T12:00:00Z">Thu, 09 Oct 2008 14:00:00 +0200</abbr>'
|
139
|
+
end
|
140
|
+
|
141
|
+
test "#datetime_with_microformat displays a non-UTC time and converts it to UTC" do
|
142
|
+
datetime_with_microformat(@local_time).should ==
|
143
|
+
'<abbr class="datetime" title="2008-10-09T12:00:00Z">Thu, 09 Oct 2008 14:00:00 +0200</abbr>'
|
144
|
+
end
|
145
|
+
|
146
|
+
test "#datetime_with_microformat displays a UTC time with a given date format" do
|
147
|
+
datetime_with_microformat(@utc_time, :format => :long).should ==
|
148
|
+
'<abbr class="datetime" title="2008-10-09T12:00:00Z">October 09, 2008 14:00</abbr>'
|
149
|
+
end
|
150
|
+
|
151
|
+
test "#datetime_with_microformat displays a non-UTC time with a given date format and converts it to UTC" do
|
152
|
+
datetime_with_microformat(@local_time, :format => :long).should ==
|
153
|
+
'<abbr class="datetime" title="2008-10-09T12:00:00Z">October 09, 2008 14:00</abbr>'
|
154
|
+
end
|
155
|
+
|
156
|
+
test "#datetime_with_microformat displays a UTC time with a given custom date format" do
|
157
|
+
datetime_with_microformat(@utc_time, :format => '%Y/%m/%d').should ==
|
158
|
+
'<abbr class="datetime" title="2008-10-09T12:00:00Z">2008/10/09</abbr>'
|
159
|
+
end
|
160
|
+
|
161
|
+
test "#datetime_with_microformat displays a non-UTC time with a given custom date format and converts it to UTC" do
|
162
|
+
datetime_with_microformat(@local_time, :format => '%Y/%m/%d').should ==
|
163
|
+
'<abbr class="datetime" title="2008-10-09T12:00:00Z">2008/10/09</abbr>'
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class ContentHelperTest < ActionView::TestCase
|
4
|
+
include ContentHelper
|
5
|
+
include ResourceHelper
|
6
|
+
attr_reader :controller
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
@page = Page.find_by_title 'a page'
|
11
|
+
@site = @page.site
|
12
|
+
@article = @page.articles.published.first
|
13
|
+
@controller = Class.new { def controller_path; 'articles' end }.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# published_at_formatted
|
17
|
+
|
18
|
+
test "#published_at_formatted returns 'not published'
|
19
|
+
if the article is not published" do
|
20
|
+
@article.published_at = nil
|
21
|
+
published_at_formatted(@article).should == 'not published'
|
22
|
+
end
|
23
|
+
|
24
|
+
test "#published_at_formatted returns a short formatted date
|
25
|
+
if the article was published in the current year" do
|
26
|
+
@article.published_at = Time.utc(Time.now.utc.year, 1, 1)
|
27
|
+
published_at_formatted(@article).should == '01 Jan 00:00'
|
28
|
+
end
|
29
|
+
|
30
|
+
test "#published_at_formatted returns a mdy formatted date
|
31
|
+
if the article was published before the current year" do
|
32
|
+
previous_year = Time.now.utc.year - 1
|
33
|
+
@article.published_at = Time.utc(previous_year, 1, 1)
|
34
|
+
published_at_formatted(@article).should == "January 01, #{previous_year} 00:00"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class LinkToContentHelperTest < ActionView::TestCase
|
39
|
+
include ContentHelper
|
40
|
+
|
41
|
+
def setup
|
42
|
+
super
|
43
|
+
@page = Page.first
|
44
|
+
@article = @page.articles.find_by_title 'a page article'
|
45
|
+
@category = @page.categories.first
|
46
|
+
@tag = Tag.new :name => 'foo'
|
47
|
+
|
48
|
+
stub(self).page_category_path.returns '/path/to/page/category'
|
49
|
+
stub(self).page_tag_path.returns '/path/to/page/tag'
|
50
|
+
end
|
51
|
+
|
52
|
+
# content_status
|
53
|
+
|
54
|
+
test "#content_status returns an empty span if passed object does not respond_to published?" do
|
55
|
+
content_status(Object.new).should == %(<span> </span>)
|
56
|
+
end
|
57
|
+
|
58
|
+
test "#content_status returns span with published title and alt if passed object is published" do
|
59
|
+
content_status(@article).should == %(<span title='Published' alt='Published' class='status published'>Published</span>)
|
60
|
+
end
|
61
|
+
|
62
|
+
test "#content_status returns span with pending title and alt if passed object is not published" do
|
63
|
+
@article.stubs(:published?).returns false
|
64
|
+
content_status(@article).should == %(<span title='Pending' alt='Pending' class='status pending'>Pending</span>)
|
65
|
+
end
|
66
|
+
|
67
|
+
# link_to_category
|
68
|
+
|
69
|
+
test "#link_to_category links to the given category" do
|
70
|
+
link_to_category(@category).should == %(<a href="/path/to/page/category">#{@category.title}</a>)
|
71
|
+
end
|
72
|
+
|
73
|
+
test "#link_to_category given the first argument is a String it uses the String as link text" do
|
74
|
+
link_to_category('link text', @category).should == '<a href="/path/to/page/category">link text</a>'
|
75
|
+
end
|
76
|
+
|
77
|
+
# links_to_content_categories
|
78
|
+
|
79
|
+
test "#links_to_content_categories returns an array of links to the given content's categories" do
|
80
|
+
links_to_content_categories(@article).should include("<a href=\"/path/to/page/category\">#{@category.title}</a>")
|
81
|
+
end
|
82
|
+
|
83
|
+
test "#links_to_content_categories returns nil if the content has no categories" do
|
84
|
+
@article.categories.clear
|
85
|
+
links_to_content_categories(@article).should be_nil
|
86
|
+
end
|
87
|
+
|
88
|
+
# link_to_tag
|
89
|
+
|
90
|
+
test "#link_to_tag links to the given tag" do
|
91
|
+
link_to_tag(@page, @tag).should == '<a href="/path/to/page/tag">foo</a>'
|
92
|
+
end
|
93
|
+
|
94
|
+
test "#link_to_tag given the first argument is a String it uses the String as link text" do
|
95
|
+
link_to_tag('link text', @page, @tag).should == '<a href="/path/to/page/tag">link text</a>'
|
96
|
+
end
|
97
|
+
|
98
|
+
# links_to_content_tags
|
99
|
+
|
100
|
+
test "#links_to_content_tags returns an array of links to the given content's tags" do
|
101
|
+
links_to_content_tags(@article).should ==
|
102
|
+
['<a href="/path/to/page/tag">foo</a>', '<a href="/path/to/page/tag">bar</a>']
|
103
|
+
end
|
104
|
+
|
105
|
+
test "returns nil if the content has no tags" do
|
106
|
+
@article.tags.clear
|
107
|
+
links_to_content_tags(@article).should be_nil
|
108
|
+
end
|
109
|
+
|
110
|
+
# content_category_checkbox
|
111
|
+
|
112
|
+
test "#content_category_checkbox given an Article
|
113
|
+
returns a checkbox named 'article[category_ids][]' with the id article_category_1" do
|
114
|
+
result = content_category_checkbox(@article, @category)
|
115
|
+
result.should have_tag('input[type=?][name=?]', 'checkbox', 'article[category_ids][]')
|
116
|
+
end
|
117
|
+
|
118
|
+
test "#content_category_checkbox given an Article that belongs to the given Category the checkbox is checked" do
|
119
|
+
result = content_category_checkbox(@article, @category)
|
120
|
+
result.should have_tag('input[type=?][checked=?]', 'checkbox', 'checked')
|
121
|
+
end
|
122
|
+
|
123
|
+
test "#content_category_checkbox given an Article that does not belong to the given Category it the checkbox is not checked" do
|
124
|
+
@article.categories.clear
|
125
|
+
content_category_checkbox(@article, @category).should_not =~ /checked/
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
class ResourceHelperTest < ActionView::TestCase
|
4
|
+
include ResourceHelper
|
5
|
+
include ContentHelper
|
6
|
+
attr_reader :controller
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
@old_routing_filter_active, RoutingFilter.active = RoutingFilter.active, false
|
11
|
+
|
12
|
+
@blog_article = Article.find_by_title 'a blog article'
|
13
|
+
@page_article = Article.find_by_title 'a page article'
|
14
|
+
@blog = @blog_article.section
|
15
|
+
@page = @page_article.section
|
16
|
+
@site = @blog.site
|
17
|
+
|
18
|
+
@controller = Class.new { def controller_path; 'articles' end }.new
|
19
|
+
I18n.backend.send :merge_translations, :en, :foo => 'FOO'
|
20
|
+
|
21
|
+
@paths = {
|
22
|
+
:blog_articles => {
|
23
|
+
:show => %r(^/blogs/\d+/\d{4}/\d{1,2}/\d{1,2}/a-blog-article$),
|
24
|
+
},
|
25
|
+
:page_articles => {
|
26
|
+
:show => %r(^/pages/\d+/articles/a-page-article$),
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
RoutingFilter.active = @old_routing_filter_active
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'resource_path helpers for articles' do
|
36
|
+
show_path(@blog_article).should =~ @paths[:blog_articles][:show]
|
37
|
+
show_path(@page_article).should =~ @paths[:page_articles][:show]
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'resource_link helpers for articles' do
|
41
|
+
assert_html link_to_show(@blog_article), 'a[href=?][class=show article]', @paths[:blog_articles][:show], 'Show'
|
42
|
+
assert_html link_to_show(@page_article), 'a[href=?][class=show article]', @paths[:page_articles][:show], 'Show'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class AdminResourceHelperTest < ActionView::TestCase
|
47
|
+
include ResourceHelper
|
48
|
+
attr_reader :controller
|
49
|
+
|
50
|
+
def setup
|
51
|
+
super
|
52
|
+
@article = Article.find_by_title 'a page article'
|
53
|
+
@section = @article.section
|
54
|
+
@category = @article.categories.first
|
55
|
+
|
56
|
+
@site = @section.site
|
57
|
+
@controller = Class.new { def controller_path; 'admin/articles' end }.new
|
58
|
+
I18n.backend.send :merge_translations, :en, :foo => 'FOO'
|
59
|
+
|
60
|
+
@paths = {
|
61
|
+
:articles => {
|
62
|
+
:index => %r(^/admin/sites/\d+/sections/\d+/articles$),
|
63
|
+
:new => %r(^/admin/sites/\d+/sections/\d+/articles/new$),
|
64
|
+
:show => %r(^/admin/sites/\d+/sections/\d+/articles/\d+$),
|
65
|
+
:edit => %r(^/admin/sites/\d+/sections/\d+/articles/\d+/edit$),
|
66
|
+
},
|
67
|
+
:categories => {
|
68
|
+
:index => %r(^/admin/sites/\d+/sections/\d+/categories$),
|
69
|
+
:new => %r(^/admin/sites/\d+/sections/\d+/categories/new$),
|
70
|
+
:show => %r(^/admin/sites/\d+/sections/\d+/categories/\d+$),
|
71
|
+
:edit => %r(^/admin/sites/\d+/sections/\d+/categories/\d+/edit$),
|
72
|
+
},
|
73
|
+
:sections => {
|
74
|
+
:index => %r(^/admin/sites/\d+/sections$),
|
75
|
+
:new => %r(^/admin/sites/\d+/sections/new$),
|
76
|
+
:show => %r(^/admin/sites/\d+/sections/\d+$),
|
77
|
+
:edit => %r(^/admin/sites/\d+/sections/\d+/edit$),
|
78
|
+
},
|
79
|
+
:themes => {
|
80
|
+
:index => %r(^/admin/sites/\d+/themes$),
|
81
|
+
:new => %r(^/admin/sites/\d+/themes/new$),
|
82
|
+
:show => %r(^/admin/sites/\d+/themes/\d+$),
|
83
|
+
:edit => %r(^/admin/sites/\d+/themes/\d+/edit$),
|
84
|
+
},
|
85
|
+
:sites => {
|
86
|
+
:index => %r(^/admin/sites$),
|
87
|
+
:new => %r(^/admin/sites/new$),
|
88
|
+
:show => %r(^/admin/sites/\d+$),
|
89
|
+
:edit => %r(^/admin/sites/\d+/edit$),
|
90
|
+
}
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
def protect_against_forgery?
|
95
|
+
false
|
96
|
+
end
|
97
|
+
|
98
|
+
test 'resource_path helpers for articles' do
|
99
|
+
index_path([@section, :article]).should =~ @paths[:articles][:index]
|
100
|
+
new_path([@section, :article]).should =~ @paths[:articles][:new]
|
101
|
+
show_path(@article).should =~ @paths[:articles][:show]
|
102
|
+
edit_path(@article).should =~ @paths[:articles][:edit]
|
103
|
+
end
|
104
|
+
|
105
|
+
test 'resource_path helpers for categories' do
|
106
|
+
index_path([@section, :category]).should =~ @paths[:categories][:index]
|
107
|
+
new_path([@section, :category]).should =~ @paths[:categories][:new]
|
108
|
+
show_path(@category).should =~ @paths[:categories][:show]
|
109
|
+
edit_path(@category).should =~ @paths[:categories][:edit]
|
110
|
+
end
|
111
|
+
|
112
|
+
test 'resource_path helpers for sections' do
|
113
|
+
index_path([@site, :section]).should =~ @paths[:sections][:index]
|
114
|
+
new_path([@site, :section]).should =~ @paths[:sections][:new]
|
115
|
+
show_path(@section).should =~ @paths[:sections][:show]
|
116
|
+
edit_path(@section).should =~ @paths[:sections][:edit]
|
117
|
+
end
|
118
|
+
|
119
|
+
test 'resource_path helpers for sites' do
|
120
|
+
index_path([:site]).should =~ @paths[:sites][:index]
|
121
|
+
new_path([:site]).should =~ @paths[:sites][:new]
|
122
|
+
show_path(@site).should =~ @paths[:sites][:show]
|
123
|
+
edit_path(@site).should =~ @paths[:sites][:edit]
|
124
|
+
end
|
125
|
+
|
126
|
+
test 'resource_link helpers for articles' do
|
127
|
+
assert_html link_to_index([@section, :article]), 'a[href=?][class=index articles]', @paths[:articles][:index], 'Articles'
|
128
|
+
assert_html link_to_new([@section, :article]), 'a[href=?][class=new article]', @paths[:articles][:new], 'New'
|
129
|
+
assert_html link_to_show(@article), 'a[href=?][class=show article]', @paths[:articles][:show], 'Show'
|
130
|
+
assert_html link_to_edit(@article), 'a[href=?][class=edit article]', @paths[:articles][:edit], 'Edit'
|
131
|
+
assert_html link_to_delete(@article), 'a[href=?][class=delete article]', @paths[:articles][:show], 'Delete'
|
132
|
+
end
|
133
|
+
|
134
|
+
test 'resource_link helpers for articles with text' do
|
135
|
+
assert_html link_to_index(:foo, [@section, :article]), 'a[href=?][class=index articles]', @paths[:articles][:index], 'FOO'
|
136
|
+
assert_html link_to_new(:foo, [@section, :article]), 'a[href=?][class=new article]', @paths[:articles][:new], 'FOO'
|
137
|
+
assert_html link_to_show(:foo, @article), 'a[href=?][class=show article]', @paths[:articles][:show], 'FOO'
|
138
|
+
assert_html link_to_edit(:foo, @article), 'a[href=?][class=edit article]', @paths[:articles][:edit], 'FOO'
|
139
|
+
assert_html link_to_delete(:foo, @section), 'a[href=?][class=delete section]', @paths[:sections][:show], 'FOO'
|
140
|
+
end
|
141
|
+
|
142
|
+
test 'resource_link helpers for sections' do
|
143
|
+
assert_html link_to_index([@site, :section]), 'a[href=?][class=index sections]', @paths[:sections][:index], 'Sections'
|
144
|
+
assert_html link_to_new([@site, :section]), 'a[href=?][class=new section]', @paths[:sections][:new], 'Create a new section'
|
145
|
+
assert_html link_to_show(@section), 'a[href=?][class=show section]', @paths[:sections][:show], 'Show'
|
146
|
+
assert_html link_to_edit(@section), 'a[href=?][class=edit section]', @paths[:sections][:edit], 'Settings'
|
147
|
+
assert_html link_to_delete(@section), 'a[href=?][class=delete section]', @paths[:sections][:show], 'Delete'
|
148
|
+
end
|
149
|
+
|
150
|
+
test 'resource_link helpers for sites' do
|
151
|
+
assert_html link_to_index([:site]), 'a[href=?][class=index sites]', @paths[:sites][:index], 'Sites'
|
152
|
+
assert_html link_to_new([:site]), 'a[href=?][class=new site]', @paths[:sites][:new], 'New'
|
153
|
+
assert_html link_to_show(@site), 'a[href=?][class=show site]', @paths[:sites][:show], 'Show'
|
154
|
+
assert_html link_to_edit(@site), 'a[href=?][class=edit site]', @paths[:sites][:edit], 'Settings'
|
155
|
+
assert_html link_to_delete(@site), 'a[href=?][class=delete site]', @paths[:sites][:show], 'Delete'
|
156
|
+
end
|
157
|
+
|
158
|
+
test 'should populate title option with default value taken from adva.titles.#{action}' do
|
159
|
+
link_to_new(@article).should =~ /title="New"/
|
160
|
+
link_to_show(@article).should =~ /title="Show"/
|
161
|
+
link_to_edit(@article).should =~ /title="Edit"/
|
162
|
+
link_to_delete(@article).should =~ /title="Delete"/
|
163
|
+
end
|
164
|
+
|
165
|
+
test 'should not populate title option because there is no translation for given action' do
|
166
|
+
link_to_index(@article).should_not =~ /title=/
|
167
|
+
end
|
168
|
+
|
169
|
+
test 'should return given title' do
|
170
|
+
link_to_index(@article, :title => "test-title").should =~ /title="test-title"/
|
171
|
+
link_to_new(@article, :title => "test-title").should =~ /title="test-title"/
|
172
|
+
link_to_show(@article, :title => "test-title").should =~ /title="test-title"/
|
173
|
+
link_to_edit(@article, :title => "test-title").should =~ /title="test-title"/
|
174
|
+
link_to_delete(@article, :title => "test-title").should =~ /title="test-title"/
|
175
|
+
end
|
176
|
+
|
177
|
+
test 'resurce_url should return resource path with subclass' do
|
178
|
+
#TODO currently there are no subclass modelis in adva_cms to test against
|
179
|
+
end
|
180
|
+
end
|