browsercms 3.1.5 → 3.3.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/cms/base_controller.rb +3 -3
- data/app/controllers/cms/content_block_controller.rb +2 -2
- data/app/controllers/cms/content_controller.rb +5 -4
- data/app/controllers/cms/error_handling.rb +1 -1
- data/app/controllers/cms/routes_controller.rb +4 -5
- data/app/controllers/cms/section_nodes_controller.rb +1 -6
- data/app/controllers/cms/sections_controller.rb +2 -3
- data/app/controllers/cms/tasks_controller.rb +3 -0
- data/app/controllers/cms/users_controller.rb +1 -1
- data/app/helpers/cms/application_helper.rb +137 -34
- data/app/helpers/cms/form_builder.rb +33 -21
- data/app/helpers/cms/page_helper.rb +43 -10
- data/app/helpers/cms/path_helper.rb +1 -1
- data/app/helpers/cms/rendering_helper.rb +3 -4
- data/app/helpers/cms/section_nodes_helper.rb +5 -43
- data/app/models/abstract_file_block.rb +1 -16
- data/app/models/attachment.rb +57 -22
- data/app/models/category.rb +4 -4
- data/app/models/category_type.rb +2 -2
- data/app/models/cms/view_context.rb +46 -0
- data/app/models/connector.rb +7 -6
- data/app/models/content_type.rb +3 -3
- data/app/models/dynamic_view.rb +1 -1
- data/app/models/email_message.rb +2 -2
- data/app/models/file_block.rb +12 -0
- data/app/models/group.rb +4 -4
- data/app/models/group_type.rb +4 -4
- data/app/models/html_block.rb +1 -1
- data/app/models/image_block.rb +12 -0
- data/app/models/link.rb +22 -5
- data/app/models/page.rb +87 -46
- data/app/models/page_route.rb +61 -6
- data/app/models/permission.rb +1 -1
- data/app/models/portlet.rb +14 -4
- data/app/models/section.rb +48 -86
- data/app/models/section_node.rb +25 -40
- data/app/models/site.rb +1 -1
- data/app/models/tag.rb +1 -1
- data/app/models/task.rb +8 -7
- data/app/models/user.rb +2 -7
- data/app/portlets/forgot_password_portlet.rb +6 -2
- data/app/portlets/reset_password_portlet.rb +1 -1
- data/app/views/cms/blocks/_toolbar.html.erb +1 -1
- data/app/views/cms/blocks/_toolbar_for_collection.html.erb +3 -6
- data/app/views/cms/blocks/_toolbar_for_member.html.erb +3 -5
- data/app/views/cms/blocks/edit.html.erb +4 -4
- data/app/views/cms/blocks/index.html.erb +7 -7
- data/app/views/cms/blocks/new.html.erb +4 -4
- data/app/views/cms/blocks/show.html.erb +2 -2
- data/app/views/cms/blocks/usages.html.erb +2 -2
- data/app/views/cms/blocks/versions.html.erb +4 -4
- data/app/views/cms/cache/show.html.erb +2 -2
- data/app/views/cms/categories/_form.html.erb +2 -2
- data/app/views/cms/connectors/new.html.erb +6 -8
- data/app/views/cms/content/no_page.html.erb +1 -1
- data/app/views/cms/content/show.html.erb +2 -7
- data/app/views/cms/dashboard/_page_drafts.html.erb +1 -1
- data/app/views/cms/dashboard/_tasks.html.erb +1 -1
- data/app/views/cms/dashboard/index.html.erb +1 -1
- data/app/views/cms/dynamic_views/_form.html.erb +2 -2
- data/app/views/cms/dynamic_views/index.html.erb +7 -10
- data/app/views/cms/email_messages/show.html.erb +2 -2
- data/app/views/cms/file_blocks/_form.html.erb +4 -4
- data/app/views/cms/form_builder/_cms_fancy_drop_down.html.erb +2 -2
- data/app/views/cms/form_builder/_cms_file_field.html.erb +2 -2
- data/app/views/cms/form_builder/_cms_tag_list.html.erb +2 -2
- data/app/views/cms/form_builder/_cms_text_editor.html.erb +2 -2
- data/app/views/cms/groups/_form.html.erb +5 -5
- data/app/views/cms/groups/_permissions.html.erb +4 -4
- data/app/views/cms/groups/_sections.html.erb +1 -2
- data/app/views/cms/groups/index.html.erb +1 -1
- data/app/views/cms/html_blocks/render.html.erb +1 -1
- data/app/views/cms/image_blocks/_form.html.erb +4 -5
- data/app/views/cms/links/_form.html.erb +1 -1
- data/app/views/cms/links/edit.html.erb +2 -2
- data/app/views/cms/links/new.html.erb +2 -2
- data/app/views/cms/page_routes/_form.html.erb +2 -2
- data/app/views/cms/page_routes/index.html.erb +6 -9
- data/app/views/cms/page_routes/show.html.erb +5 -8
- data/app/views/cms/pages/_edit_connector.html.erb +1 -1
- data/app/views/cms/pages/_form.html.erb +3 -3
- data/app/views/cms/pages/edit.html.erb +2 -2
- data/app/views/cms/pages/new.html.erb +7 -7
- data/app/views/cms/pages/versions.html.erb +4 -4
- data/app/views/cms/redirects/_form.html.erb +2 -2
- data/app/views/cms/redirects/index.html.erb +8 -7
- data/app/views/cms/routes/index.html.erb +2 -2
- data/app/views/cms/section_nodes/_link.html.erb +3 -6
- data/app/views/cms/section_nodes/_node.html.erb +4 -13
- data/app/views/cms/section_nodes/_page.html.erb +7 -13
- data/app/views/cms/section_nodes/_section.html.erb +8 -24
- data/app/views/cms/section_nodes/_section_node.html.erb +10 -0
- data/app/views/cms/section_nodes/index.html.erb +18 -30
- data/app/views/cms/sections/_form.html.erb +4 -6
- data/app/views/cms/sections/edit.html.erb +2 -2
- data/app/views/cms/sections/index.html.erb +3 -3
- data/app/views/cms/sections/new.html.erb +3 -3
- data/app/views/cms/sessions/new.html.erb +3 -3
- data/app/views/cms/shared/_pagination.html.erb +1 -1
- data/app/views/cms/shared/error.html.erb +1 -1
- data/app/views/cms/tags/render.html.erb +2 -2
- data/app/views/cms/tasks/new.html.erb +4 -4
- data/app/views/cms/users/_form.html.erb +3 -3
- data/app/views/cms/users/_toolbar.html.erb +3 -3
- data/app/views/cms/users/change_password.html.erb +5 -5
- data/app/views/cms/users/edit.html.erb +2 -2
- data/app/views/cms/users/index.html.erb +4 -4
- data/app/views/cms/users/new.html.erb +2 -2
- data/app/views/cms/users/show.html.erb +16 -16
- data/app/views/layouts/_cms_toolbar.html.erb +5 -5
- data/app/views/layouts/_page_toolbar.html.erb +11 -11
- data/app/views/layouts/cms/_footer.erb +1 -1
- data/app/views/layouts/cms/_head.html.erb +2 -6
- data/app/views/layouts/cms/administration.html.erb +32 -32
- data/app/views/layouts/cms/content_library.html.erb +5 -5
- data/app/views/layouts/cms/toolbar.html.erb +1 -1
- data/app/views/portlets/email_page/render.html.erb +2 -2
- data/app/views/portlets/forgot_password/render.html.erb +1 -1
- data/app/views/portlets/login/render.html.erb +4 -2
- data/app/views/portlets/reset_password/render.html.erb +1 -1
- data/app/views/tests/pretend/open_with_layout.html.erb +1 -1
- data/bin/bcms +0 -0
- data/bin/bcms-upgrade +232 -0
- data/bin/browsercms +2 -2
- data/browsercms.gemspec +16 -14
- data/db/migrate/20100705083859_browsercms_3_3_0.rb +56 -0
- data/db/seeds.rb +58 -0
- data/doc/guides/html/authentication.html +448 -192
- data/doc/guides/html/build_it_yourself.html +454 -175
- data/doc/guides/html/building_modules.html +451 -220
- data/doc/guides/html/building_templates.html +448 -498
- data/doc/guides/html/content_blocks.html +450 -470
- data/doc/guides/html/customizing_browsercms.html +453 -169
- data/doc/guides/html/deployment_guide.html +443 -82
- data/doc/guides/html/files/bcmsorg.js +28 -0
- data/doc/guides/html/files/clearfix.css +8 -0
- data/doc/guides/html/files/cufon.js +7 -0
- data/doc/guides/html/files/global.css +190 -0
- data/doc/guides/html/files/helvetica.js +91 -0
- data/doc/guides/html/files/jquery.js +11 -0
- data/doc/guides/html/getting_started.html +454 -213
- data/doc/guides/html/index.html +454 -174
- data/doc/guides/html/installing_modules.html +454 -186
- data/doc/guides/html/portlets.html +451 -232
- data/doc/guides/html/user_guide.html +452 -270
- data/doc/guides/html/writing_guides.html +454 -161
- data/lib/acts_as_list.rb +1 -1
- data/lib/browsercms.rb +10 -6
- data/lib/cms/acts.rb +7 -0
- data/lib/cms/authentication.rb +4 -0
- data/lib/cms/authentication/controller.rb +1 -1
- data/lib/cms/behaviors.rb +1 -1
- data/lib/cms/behaviors/archiving.rb +2 -2
- data/lib/cms/behaviors/attaching.rb +28 -43
- data/lib/cms/behaviors/categorizing.rb +1 -1
- data/lib/cms/behaviors/connecting.rb +27 -12
- data/lib/cms/behaviors/dynamic_attributes.rb +8 -5
- data/lib/cms/behaviors/hiding.rb +2 -2
- data/lib/cms/behaviors/publishing.rb +32 -22
- data/lib/cms/behaviors/rendering.rb +41 -18
- data/lib/cms/behaviors/searching.rb +1 -1
- data/lib/cms/behaviors/soft_deleting.rb +58 -29
- data/lib/cms/behaviors/taggable.rb +1 -1
- data/lib/cms/behaviors/userstamping.rb +5 -4
- data/lib/cms/behaviors/versioning.rb +192 -111
- data/lib/cms/content_rendering_support.rb +3 -3
- data/lib/cms/date_picker.rb +23 -0
- data/lib/cms/engine.rb +46 -0
- data/lib/cms/extensions.rb +1 -1
- data/lib/cms/extensions/active_record/errors.rb +2 -2
- data/lib/cms/extensions/hash.rb +4 -2
- data/lib/cms/extensions/string.rb +7 -2
- data/lib/cms/init.rb +32 -21
- data/lib/cms/module.rb +22 -0
- data/lib/cms/module_installation.rb +38 -0
- data/lib/cms/routes.rb +127 -115
- data/lib/cms/version.rb +2 -2
- data/lib/generators/browser_cms.rb +12 -0
- data/lib/generators/browser_cms/cms/USAGE +2 -0
- data/lib/generators/browser_cms/cms/cms_generator.rb +36 -0
- data/{rails_generators/browser_cms → lib/generators/browser_cms/cms}/templates/README +0 -0
- data/{rails_generators/browser_cms_demo_site → lib/generators/browser_cms/demo_site}/USAGE +0 -0
- data/lib/generators/browser_cms/demo_site/demo_site_generator.rb +138 -0
- data/lib/generators/browser_cms/demo_site/templates/demo_site.rake +11 -0
- data/{rails_generators/browser_cms_demo_site/templates/migration.rb → lib/generators/browser_cms/demo_site/templates/migration.erb} +2 -8
- data/lib/generators/cms/content_block/USAGE +22 -0
- data/lib/generators/cms/content_block/content_block_generator.rb +55 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/_form.html.erb +0 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/content_block.rb +0 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/controller.rb +0 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/functional_test.erb +0 -0
- data/{rails_generators/content_block/templates/migration.rb → lib/generators/cms/content_block/templates/migration.erb} +1 -1
- data/{rails_generators → lib/generators/cms}/content_block/templates/render.html.erb +0 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/unit_test.erb +0 -0
- data/lib/generators/cms/install/USAGE +8 -0
- data/lib/generators/cms/install/install_generator.rb +20 -0
- data/{rails_generators → lib/generators/cms}/portlet/USAGE +3 -16
- data/lib/generators/cms/portlet/portlet_generator.rb +38 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/_form.html.erb +0 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/portlet.rb +0 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/portlet_helper.rb +0 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/render.html.erb +0 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/unit_test.erb +0 -0
- data/{rails_generators → lib/generators/cms}/template/USAGE +1 -1
- data/lib/generators/cms/template/template_generator.rb +18 -0
- data/lib/generators/cms/template/templates/template.erb +2 -0
- data/lib/generators/cms/upgrade_module/README.txt +3 -0
- data/lib/generators/cms/upgrade_module/templates/20100705083859_browsercms_3_3_0.rb +56 -0
- data/lib/generators/cms/upgrade_module/templates/README +1 -0
- data/lib/generators/cms/upgrade_module/templates/USAGE.erb +10 -0
- data/lib/generators/cms/upgrade_module/templates/build_gem.rake +5 -0
- data/lib/generators/cms/upgrade_module/templates/engine.erb +7 -0
- data/lib/generators/cms/upgrade_module/templates/gemspec.erb +25 -0
- data/lib/generators/cms/upgrade_module/templates/gitignore.erb +11 -0
- data/lib/generators/cms/upgrade_module/templates/install.erb +9 -0
- data/lib/generators/cms/upgrade_module/templates/module_file.erb +3 -0
- data/lib/generators/cms/upgrade_module/templates/routes.erb +7 -0
- data/lib/generators/cms/upgrade_module/upgrade_module_generator.rb +61 -0
- data/lib/tasks/build_gem.rake +1 -0
- data/lib/tasks/cms.rake +34 -6
- data/lib/tasks/cucumber.rake +53 -0
- data/lib/tasks/db.rake +2 -2
- data/public/javascripts/cms/application.js +144 -135
- data/public/javascripts/cms/sitemap.js +383 -357
- data/public/javascripts/jquery-ui.js +782 -591
- data/public/javascripts/jquery.cookie.js +38 -43
- data/public/javascripts/jquery.js +13 -8
- data/public/javascripts/jquery.taglist.js +7 -0
- data/public/stylesheets/cms/date_picker.css +49 -40
- data/rails/init.rb +2 -3
- data/templates/blank.rb +13 -7
- data/templates/demo.rb +15 -7
- data/templates/module.rb +12 -75
- metadata +87 -407
- data/app/helpers/cms/content_block_helper.rb +0 -27
- data/app/views/layouts/cms/thickbox.html.erb +0 -24
- data/db/migrate/20120117144039_browsercms315.rb +0 -94
- data/db/migrate/20121114172307_load_seeds.rb +0 -70
- data/lib/cms/addressable.rb +0 -83
- data/lib/cms/error_pages.rb +0 -8
- data/public/images/cms/thickbox/loadingAnimation.gif +0 -0
- data/public/images/cms/thickbox/macFFBgHack.png +0 -0
- data/public/javascripts/jquery.contextMenu.js +0 -211
- data/public/javascripts/jquery.dimensions.js +0 -119
- data/public/javascripts/jquery.thickbox.js +0 -10
- data/public/stylesheets/cms/jquery.contextMenu.css +0 -61
- data/public/stylesheets/cms/thickbox.css +0 -163
- data/rails_generators/browser_cms/USAGE +0 -2
- data/rails_generators/browser_cms/browser_cms_generator.rb +0 -35
- data/rails_generators/browser_cms_demo_site/browser_cms_demo_site_generator.rb +0 -63
- data/rails_generators/content_block/USAGE +0 -32
- data/rails_generators/content_block/content_block_generator.rb +0 -69
- data/rails_generators/portlet/portlet_generator.rb +0 -35
- data/rails_generators/template/template_generator.rb +0 -18
- data/rails_generators/template/templates/template.erb +0 -3
- data/test/custom_assertions.rb +0 -74
- data/test/factories.rb +0 -111
- data/test/factories/sitemap_factories.rb +0 -28
- data/test/fixtures/connectors.yml +0 -97
- data/test/fixtures/content_type_groups.yml +0 -13
- data/test/fixtures/content_types.yml +0 -50
- data/test/fixtures/dynamic_view_versions.yml +0 -26
- data/test/fixtures/dynamic_views.yml +0 -26
- data/test/fixtures/group_permissions.yml +0 -16
- data/test/fixtures/group_sections.yml +0 -31
- data/test/fixtures/group_type_permissions.yml +0 -11
- data/test/fixtures/group_types.yml +0 -25
- data/test/fixtures/groups.yml +0 -25
- data/test/fixtures/html_block_versions.yml +0 -67
- data/test/fixtures/html_blocks.yml +0 -63
- data/test/fixtures/page_versions.yml +0 -265
- data/test/fixtures/pages.yml +0 -85
- data/test/fixtures/permissions.yml +0 -28
- data/test/fixtures/section_nodes.yml +0 -46
- data/test/fixtures/sections.yml +0 -19
- data/test/fixtures/sites.yml +0 -9
- data/test/fixtures/user_group_memberships.yml +0 -11
- data/test/fixtures/users.yml +0 -15
- data/test/functional/cms/cache_controller_test.rb +0 -14
- data/test/functional/cms/categories_controller_test.rb +0 -25
- data/test/functional/cms/connectors_controller_test.rb +0 -60
- data/test/functional/cms/content_block_controller_test.rb +0 -120
- data/test/functional/cms/content_controller_test.rb +0 -439
- data/test/functional/cms/content_types_controller_test.rb +0 -18
- data/test/functional/cms/dashboard_controller_test.rb +0 -16
- data/test/functional/cms/dynamic_views_controller_test.rb +0 -52
- data/test/functional/cms/file_blocks_controller_test.rb +0 -52
- data/test/functional/cms/groups_controller_test.rb +0 -50
- data/test/functional/cms/home_controller_test.rb +0 -156
- data/test/functional/cms/html_blocks_controller_test.rb +0 -164
- data/test/functional/cms/image_blocks_controller_test.rb +0 -82
- data/test/functional/cms/links_controller_test.rb +0 -148
- data/test/functional/cms/pages_controller_test.rb +0 -227
- data/test/functional/cms/portlets_controller_test.rb +0 -67
- data/test/functional/cms/section_nodes_controller_test.rb +0 -112
- data/test/functional/cms/sections_controller_test.rb +0 -227
- data/test/functional/cms/sessions_controller_test.rb +0 -76
- data/test/functional/cms/toolbar_controller_test.rb +0 -64
- data/test/functional/cms/users_controller_test.rb +0 -231
- data/test/functional/tests/pretend_controller_test.rb +0 -57
- data/test/integration/cms/ckeditor_test.rb +0 -30
- data/test/integration/cms/password_management_test.rb +0 -56
- data/test/integration/login_test.rb +0 -14
- data/test/integration/sitemap_performance_test.rb +0 -26
- data/test/selenium-core/Blank.html +0 -7
- data/test/selenium-core/InjectedRemoteRunner.html +0 -8
- data/test/selenium-core/RemoteRunner.html +0 -110
- data/test/selenium-core/SeleniumLog.html +0 -109
- data/test/selenium-core/TestPrompt.html +0 -145
- data/test/selenium-core/TestRunner-splash.html +0 -55
- data/test/selenium-core/TestRunner.hta +0 -176
- data/test/selenium-core/TestRunner.html +0 -176
- data/test/selenium-core/domviewer/butmin.gif +0 -0
- data/test/selenium-core/domviewer/butplus.gif +0 -0
- data/test/selenium-core/domviewer/domviewer.css +0 -298
- data/test/selenium-core/domviewer/domviewer.html +0 -16
- data/test/selenium-core/domviewer/selenium-domviewer.js +0 -205
- data/test/selenium-core/icons/all.png +0 -0
- data/test/selenium-core/icons/continue.png +0 -0
- data/test/selenium-core/icons/continue_disabled.png +0 -0
- data/test/selenium-core/icons/pause.png +0 -0
- data/test/selenium-core/icons/pause_disabled.png +0 -0
- data/test/selenium-core/icons/selected.png +0 -0
- data/test/selenium-core/icons/step.png +0 -0
- data/test/selenium-core/icons/step_disabled.png +0 -0
- data/test/selenium-core/iedoc-core.xml +0 -1515
- data/test/selenium-core/iedoc.xml +0 -1469
- data/test/selenium-core/lib/cssQuery/cssQuery-p.js +0 -6
- data/test/selenium-core/lib/cssQuery/src/cssQuery-level2.js +0 -142
- data/test/selenium-core/lib/cssQuery/src/cssQuery-level3.js +0 -150
- data/test/selenium-core/lib/cssQuery/src/cssQuery-standard.js +0 -53
- data/test/selenium-core/lib/cssQuery/src/cssQuery.js +0 -356
- data/test/selenium-core/lib/prototype.js +0 -2006
- data/test/selenium-core/lib/scriptaculous/builder.js +0 -101
- data/test/selenium-core/lib/scriptaculous/controls.js +0 -815
- data/test/selenium-core/lib/scriptaculous/dragdrop.js +0 -915
- data/test/selenium-core/lib/scriptaculous/effects.js +0 -958
- data/test/selenium-core/lib/scriptaculous/scriptaculous.js +0 -47
- data/test/selenium-core/lib/scriptaculous/slider.js +0 -283
- data/test/selenium-core/lib/scriptaculous/unittest.js +0 -383
- data/test/selenium-core/scripts/find_matching_child.js +0 -69
- data/test/selenium-core/scripts/htmlutils.js +0 -894
- data/test/selenium-core/scripts/injection.html +0 -72
- data/test/selenium-core/scripts/js2html.js +0 -70
- data/test/selenium-core/scripts/narcissus-defs.js +0 -175
- data/test/selenium-core/scripts/narcissus-exec.js +0 -1054
- data/test/selenium-core/scripts/narcissus-parse.js +0 -1003
- data/test/selenium-core/scripts/se2html.js +0 -63
- data/test/selenium-core/scripts/selenium-api.js +0 -2409
- data/test/selenium-core/scripts/selenium-browserbot.js +0 -2203
- data/test/selenium-core/scripts/selenium-browserdetect.js +0 -150
- data/test/selenium-core/scripts/selenium-commandhandlers.js +0 -377
- data/test/selenium-core/scripts/selenium-executionloop.js +0 -175
- data/test/selenium-core/scripts/selenium-logging.js +0 -147
- data/test/selenium-core/scripts/selenium-remoterunner.js +0 -571
- data/test/selenium-core/scripts/selenium-testrunner.js +0 -1333
- data/test/selenium-core/scripts/selenium-version.js +0 -5
- data/test/selenium-core/scripts/user-extensions.js +0 -3
- data/test/selenium-core/scripts/user-extensions.js.sample +0 -75
- data/test/selenium-core/scripts/xmlextras.js +0 -153
- data/test/selenium-core/selenium-logo.png +0 -0
- data/test/selenium-core/selenium-test.css +0 -43
- data/test/selenium-core/selenium.css +0 -299
- data/test/selenium-core/xpath/dom.js +0 -428
- data/test/selenium-core/xpath/misc.js +0 -252
- data/test/selenium-core/xpath/xpath.js +0 -2223
- data/test/selenium/_login_as_cmsadmin.rsel +0 -4
- data/test/selenium/dashboard.rsel +0 -5
- data/test/selenium/html_blocks.rsel +0 -4
- data/test/selenium/login/failed_login.rsel +0 -8
- data/test/selenium/login/successful_login.rsel +0 -9
- data/test/selenium/page_templates.rsel +0 -12
- data/test/selenium/pages/edit_properties.rsel +0 -5
- data/test/selenium/site/view_home_page.rsel +0 -4
- data/test/selenium/sitemap/move_page.rsel +0 -9
- data/test/selenium/sitemap/open_section.rsel +0 -6
- data/test/selenium/sitemap/select_page.rsel +0 -12
- data/test/selenium/sitemap/select_section.rsel +0 -17
- data/test/test_helper.rb +0 -193
- data/test/test_logging.rb +0 -67
- data/test/unit/behaviors/attaching_test.rb +0 -357
- data/test/unit/behaviors/connectable_test.rb +0 -29
- data/test/unit/behaviors/dynamic_attributes_test.rb +0 -38
- data/test/unit/behaviors/publishable_test.rb +0 -84
- data/test/unit/behaviors/searching_test.rb +0 -102
- data/test/unit/behaviors/taggable_test.rb +0 -109
- data/test/unit/behaviors/versioning_test.rb +0 -36
- data/test/unit/extensions/active_record/base_test.rb +0 -10
- data/test/unit/extensions/hash_test.rb +0 -17
- data/test/unit/extensions/integer_test.rb +0 -10
- data/test/unit/helpers/application_helper_test.rb +0 -77
- data/test/unit/helpers/form_builder_test.rb +0 -36
- data/test/unit/helpers/menu_helper_test.rb +0 -242
- data/test/unit/helpers/page_helper_test.rb +0 -67
- data/test/unit/helpers/path_helper_test.rb +0 -57
- data/test/unit/lib/acts_as_content_page_test.rb +0 -72
- data/test/unit/lib/cms/authentication/controller_test.rb +0 -20
- data/test/unit/lib/cms/sitemap_test.rb +0 -206
- data/test/unit/lib/cms_domain_support_test.rb +0 -43
- data/test/unit/lib/command_line_test.rb +0 -70
- data/test/unit/lib/content_block_test.rb +0 -203
- data/test/unit/lib/content_rendering_support_test.rb +0 -40
- data/test/unit/lib/generators_test.rb +0 -40
- data/test/unit/lib/routes_test.rb +0 -57
- data/test/unit/models/attachment_test.rb +0 -116
- data/test/unit/models/category_test.rb +0 -40
- data/test/unit/models/category_type_test.rb +0 -8
- data/test/unit/models/connector_test.rb +0 -152
- data/test/unit/models/content_type_test.rb +0 -56
- data/test/unit/models/email_page_portlet_test.rb +0 -14
- data/test/unit/models/file_block_test.rb +0 -230
- data/test/unit/models/group_test.rb +0 -13
- data/test/unit/models/html_block_test.rb +0 -102
- data/test/unit/models/link_test.rb +0 -52
- data/test/unit/models/page_partial_test.rb +0 -29
- data/test/unit/models/page_route_test.rb +0 -29
- data/test/unit/models/page_template_test.rb +0 -40
- data/test/unit/models/page_test.rb +0 -792
- data/test/unit/models/permission_test.rb +0 -10
- data/test/unit/models/portlet_test.rb +0 -69
- data/test/unit/models/sections_test.rb +0 -264
- data/test/unit/models/site_test.rb +0 -50
- data/test/unit/models/task_test.rb +0 -141
- data/test/unit/models/user_test.rb +0 -352
- data/test/unit/schema_statements_test.rb +0 -41
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
setup :fixtures => :all
|
|
2
|
-
include_partial 'login_as_cmsadmin'
|
|
3
|
-
open '/cms/page_templates'
|
|
4
|
-
assert_title 'View Page Templates'
|
|
5
|
-
click_and_wait "link=*New Page Template"
|
|
6
|
-
assert_title "New Page Template"
|
|
7
|
-
type "page_template_name", "Test"
|
|
8
|
-
type "page_template_file_name", "test"
|
|
9
|
-
type "page_template_body", "<html><body><%= yield %></body></html>"
|
|
10
|
-
click_and_wait "page_template_submit"
|
|
11
|
-
assert_title "View Page Templates"
|
|
12
|
-
assert_text "//table[@id='blocks']/tbody/tr[3]/td[1]", "Test"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
setup :fixtures => :all
|
|
2
|
-
include_partial 'login_as_cmsadmin'
|
|
3
|
-
open '/cms/sitemap'
|
|
4
|
-
verify_text_not_present "Page 'Home' was moved to 'About'."
|
|
5
|
-
assert_not_visible "//span[@class='page' and text()='About Us']"
|
|
6
|
-
#TODO: Figure out why selenium drag and drop doesn't work
|
|
7
|
-
#drag_and_drop_to_object "//span[@class='page' and text()='Home']", "//span[@class='section' and text()='About']"
|
|
8
|
-
#assert_visible "//span[@class='page' and text()='About Us']"
|
|
9
|
-
#verify_text_present "Page 'Home' was moved to 'About'."
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
setup :fixtures => :all
|
|
2
|
-
include_partial 'login_as_cmsadmin'
|
|
3
|
-
open '/cms/sitemap'
|
|
4
|
-
assert_not_visible "//span[@class='page' and text()='About Us']"
|
|
5
|
-
click "//span[@class='section' and text()='About']/../a"
|
|
6
|
-
assert_visible "//span[@class='page' and text()='About Us']"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
setup :fixtures => :all
|
|
2
|
-
@page = Page.find_by_name('Home')
|
|
3
|
-
include_partial 'login_as_cmsadmin'
|
|
4
|
-
open '/cms/sitemap'
|
|
5
|
-
assert_title 'Sitemap'
|
|
6
|
-
#assert_not_editable 'edit-button'
|
|
7
|
-
#assert_not_editable 'properties-button'
|
|
8
|
-
click "//span[@class='page' and text()='#{@page.name}']"
|
|
9
|
-
#assert_editable 'edit-button'
|
|
10
|
-
#assert_editable 'properties-button'
|
|
11
|
-
assert_attribute "//a[@id='edit-button']", 'href', "/cms/pages/show/#{@page.id}"
|
|
12
|
-
assert_attribute "//a[@id='properties-button']", 'href', "/cms/pages/edit/#{@page.id}"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
setup :fixtures => :all
|
|
2
|
-
@section = Section.find_by_name('About')
|
|
3
|
-
include_partial 'login_as_cmsadmin'
|
|
4
|
-
open '/cms/sitemap'
|
|
5
|
-
assert_title 'Sitemap'
|
|
6
|
-
# assert_not_editable 'edit-button'
|
|
7
|
-
# assert_not_editable 'properties-button'
|
|
8
|
-
# assert_not_editable 'add-page-button'
|
|
9
|
-
# assert_not_editable 'add-section-button'
|
|
10
|
-
click "//span[@class='section' and text()='#{@section.name}']"
|
|
11
|
-
# assert_not_editable 'edit-button'
|
|
12
|
-
# assert_editable 'properties-button'
|
|
13
|
-
# assert_editable 'add-page-button'
|
|
14
|
-
# assert_editable 'add-section-button'
|
|
15
|
-
assert_attribute "//a[@id='properties-button']", 'href', "/cms/sections/edit/#{@section.id}"
|
|
16
|
-
assert_attribute "//a[@id='add-page-button']", 'href', "/cms/pages/new?section_id=#{@section.id}"
|
|
17
|
-
assert_attribute "//a[@id='add-section-button']", 'href', "/cms/sections/new?section_id=#{@section.id}"
|
data/test/test_helper.rb
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
|
3
|
-
require 'test_help'
|
|
4
|
-
require 'action_view/test_case'
|
|
5
|
-
require 'mocha'
|
|
6
|
-
require 'redgreen'
|
|
7
|
-
|
|
8
|
-
class ActiveSupport::TestCase
|
|
9
|
-
# Transactional fixtures accelerate your tests by wrapping each test method
|
|
10
|
-
# in a transaction that's rolled back on completion. This ensures that the
|
|
11
|
-
# test database remains unchanged so your fixtures don't have to be reloaded
|
|
12
|
-
# between every test method. Fewer database queries means faster tests.
|
|
13
|
-
#
|
|
14
|
-
# Read Mike Clark's excellent walkthrough at
|
|
15
|
-
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
|
16
|
-
#
|
|
17
|
-
# Every Active Record database supports transactions except MyISAM tables
|
|
18
|
-
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
|
19
|
-
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
|
20
|
-
# is recommended.
|
|
21
|
-
#
|
|
22
|
-
# The only drawback to using transactional fixtures is when you actually
|
|
23
|
-
# need to test transactions. Since your test is bracketed by a transaction,
|
|
24
|
-
# any transactions started in your code will be automatically rolled back.
|
|
25
|
-
self.use_transactional_fixtures = true
|
|
26
|
-
|
|
27
|
-
# Instantiated fixtures are slow, but give you @david where otherwise you
|
|
28
|
-
# would need people(:david). If you don't want to migrate your existing
|
|
29
|
-
# test cases which use the @david style and don't mind the speed hit (each
|
|
30
|
-
# instantiated fixtures translates to a database query per test method),
|
|
31
|
-
# then set this back to true.
|
|
32
|
-
self.use_instantiated_fixtures = false
|
|
33
|
-
|
|
34
|
-
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
35
|
-
#
|
|
36
|
-
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
37
|
-
# -- they do not yet inherit this setting
|
|
38
|
-
fixtures :all
|
|
39
|
-
|
|
40
|
-
# Add more helper methods to be used by all tests here...
|
|
41
|
-
|
|
42
|
-
require File.dirname(__FILE__) + '/test_logging'
|
|
43
|
-
include TestLogging
|
|
44
|
-
require File.dirname(__FILE__) + '/custom_assertions'
|
|
45
|
-
include CustomAssertions
|
|
46
|
-
|
|
47
|
-
#----- Test Macros -----------------------------------------------------------
|
|
48
|
-
class << self
|
|
49
|
-
def should_validate_presence_of(*fields)
|
|
50
|
-
fields.each do |f|
|
|
51
|
-
class_name = name.sub(/Test$/,'')
|
|
52
|
-
define_method("test_validates_presence_of_#{f}") do
|
|
53
|
-
model = Factory.build(class_name.underscore.to_sym, f => nil)
|
|
54
|
-
assert !model.valid?
|
|
55
|
-
assert_has_error_on model, f, "can't be blank"
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
def should_validate_uniqueness_of(*fields)
|
|
60
|
-
fields.each do |f|
|
|
61
|
-
class_name = name.sub(/Test$/,'')
|
|
62
|
-
define_method("test_validates_uniqueness_of_#{f}") do
|
|
63
|
-
existing_model = Factory(class_name.underscore.to_sym)
|
|
64
|
-
model = Factory.build(class_name.underscore.to_sym, f => existing_model.send(f))
|
|
65
|
-
assert !model.valid?
|
|
66
|
-
assert_has_error_on model, f, "has already been taken"
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
#----- Fixture/Data related helpers ------------------------------------------
|
|
74
|
-
|
|
75
|
-
def admin_user
|
|
76
|
-
users(:user_1)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def create_or_find_permission_named(name)
|
|
80
|
-
Permission.named(name).first || Factory(:permission, :name => name)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def create_admin_user(attrs={})
|
|
84
|
-
user = Factory(:user, {:login => "cmsadmin"}.merge(attrs))
|
|
85
|
-
group = Factory(:group, :group_type => Factory(:group_type, :cms_access => true))
|
|
86
|
-
group.permissions << create_or_find_permission_named("administrate")
|
|
87
|
-
group.permissions << create_or_find_permission_named("edit_content")
|
|
88
|
-
group.permissions << create_or_find_permission_named("publish_content")
|
|
89
|
-
user.groups << group
|
|
90
|
-
user
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def file_upload_object(options)
|
|
94
|
-
file = ActionController::UploadedTempfile.new(options[:original_filename])
|
|
95
|
-
open(file.path, 'w') {|f| f << options[:read]}
|
|
96
|
-
file.original_path = options[:original_filename]
|
|
97
|
-
file.content_type = options[:content_type]
|
|
98
|
-
file
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def guest_group
|
|
102
|
-
Group.guest || Factory(:group, :code => Group::GUEST_CODE)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def login_as(user)
|
|
106
|
-
@request.session[:user_id] = user ? user.id : nil
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def login_as_cms_admin
|
|
110
|
-
login_as(User.first)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def mock_file(options = {})
|
|
114
|
-
file_upload_object({:original_filename => "test.jpg",
|
|
115
|
-
:content_type => "image/jpeg", :rewind => true,
|
|
116
|
-
:size => "99", :read => "01010010101010101"}.merge(options))
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# Takes a list of the names of instance variables to "reset"
|
|
120
|
-
# Each instance variable will be set to a new instance
|
|
121
|
-
# That is found by looking that object by id
|
|
122
|
-
def reset(*args)
|
|
123
|
-
args.each do |v|
|
|
124
|
-
val = instance_variable_get("@#{v}")
|
|
125
|
-
instance_variable_set("@#{v}", val.class.find(val.id))
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def root_section
|
|
130
|
-
@root_section ||= Factory(:root_section)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# Fixtures add incorrect Section/Section node data. We don't want to replace fixtures AGAIN (this is handled in CMS 3.3)
|
|
134
|
-
# so we can just clean it out using this method where needed to avoid test breakage.
|
|
135
|
-
def remove_all_sitemap_fixtures_to_avoid_bugs
|
|
136
|
-
Section.delete_all
|
|
137
|
-
SectionNode.delete_all
|
|
138
|
-
Page.delete_all
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# Create a 'faux' sitemap which will work for tests (avoids need for fixtures)
|
|
142
|
-
def given_a_site_exists
|
|
143
|
-
remove_all_sitemap_fixtures_to_avoid_bugs
|
|
144
|
-
@root = root_section
|
|
145
|
-
@homepage = Factory(:public_page, :name=>"Home", :section=>@root, :path=>"/")
|
|
146
|
-
@system_section = Factory(:public_page, :name=>"System", :section=>@root, :path=>"/system")
|
|
147
|
-
@not_found_page = Factory(:public_page, :name=>"Not Found", :section=>@system_section, :path=>Cms::ErrorPages::NOT_FOUND_PATH)
|
|
148
|
-
@access_denied_page = Factory(:public_page, :name=>"Access Denied", :section=>@system_section, :path=>Cms::ErrorPages::FORBIDDEN_PATH)
|
|
149
|
-
@error_page = Factory(:public_page, :name=>"Server Error", :section=>@system_section, :path=>Cms::ErrorPages::SERVER_ERROR_PATH)
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
module Cms::ControllerTestHelper
|
|
154
|
-
def self.included(test_case)
|
|
155
|
-
test_case.send(:include, Cms::PathHelper)
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def request
|
|
159
|
-
@request
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def streaming_file_contents
|
|
163
|
-
#The body of a streaming response is a proc
|
|
164
|
-
streamer = @response.body
|
|
165
|
-
assert_equal Proc, streamer.class
|
|
166
|
-
|
|
167
|
-
#Create a dummy object for the proc to write to
|
|
168
|
-
output = Object.new
|
|
169
|
-
def output.write(contents)
|
|
170
|
-
(@contents ||= "") << contents
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
#run the proc
|
|
174
|
-
streamer.call(@response, output)
|
|
175
|
-
|
|
176
|
-
#return what it wrote to the dummy object
|
|
177
|
-
output.instance_variable_get("@contents")
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
module Cms::IntegrationTestHelper
|
|
182
|
-
def login_as(user, password = "password")
|
|
183
|
-
get cms_login_url
|
|
184
|
-
assert_response :success
|
|
185
|
-
post cms_login_url, :login => user.login, :password => password
|
|
186
|
-
assert_response :redirect
|
|
187
|
-
assert flash[:notice]
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def login_as_cms_admin
|
|
191
|
-
login_as(User.first, "cmsadmin")
|
|
192
|
-
end
|
|
193
|
-
end
|
data/test/test_logging.rb
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
module TestLogging
|
|
2
|
-
def log(msg)
|
|
3
|
-
Rails.logger.info(msg)
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
def log_array(obj, *columns)
|
|
7
|
-
lengths = columns.map{|m| m.to_s.length }
|
|
8
|
-
|
|
9
|
-
obj.each do |r|
|
|
10
|
-
columns.each_with_index do |m, i|
|
|
11
|
-
v = r.send(m)
|
|
12
|
-
if v.to_s.length > lengths[i]
|
|
13
|
-
lengths[i] = v.to_s.length
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
str = " "
|
|
19
|
-
columns.each_with_index do |m, i|
|
|
20
|
-
str << "%#{lengths[i]}s" % m
|
|
21
|
-
str << " "
|
|
22
|
-
end
|
|
23
|
-
str << "\n "
|
|
24
|
-
|
|
25
|
-
columns.each_with_index do |m, i|
|
|
26
|
-
str << ("-"*lengths[i])
|
|
27
|
-
str << " "
|
|
28
|
-
end
|
|
29
|
-
str << "\n "
|
|
30
|
-
|
|
31
|
-
obj.each do |r|
|
|
32
|
-
columns.each_with_index do |m, i|
|
|
33
|
-
str << "%#{lengths[i]}s" % r.send(m)
|
|
34
|
-
str << " "
|
|
35
|
-
end
|
|
36
|
-
str << "\n "
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
log str
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def log_table(cls, options={})
|
|
43
|
-
if options[:include_columns]
|
|
44
|
-
columns = options[:include_columns]
|
|
45
|
-
elsif options[:exclude_columns]
|
|
46
|
-
columns = cls.column_names - options[:exclude_columns].map(&:to_s)
|
|
47
|
-
else
|
|
48
|
-
columns = cls.column_names
|
|
49
|
-
end
|
|
50
|
-
log_array (cls.uses_soft_delete? ? cls.find_with_deleted(:all) : cls.all), *columns
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def log_table_with(cls, *columns)
|
|
54
|
-
log_table(cls, :include_columns => columns)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def log_table_without(cls, *columns)
|
|
58
|
-
log_table(cls, :exclude_columns => columns)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def log_table_without_stamps(cls, *columns)
|
|
62
|
-
log_table(cls, :exclude_columns => %w[created_at updated_at created_by_id updated_by_id] + columns)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
extend self
|
|
66
|
-
|
|
67
|
-
end
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '/../../test_helper')
|
|
2
|
-
|
|
3
|
-
ActiveRecord::Base.connection.instance_eval do
|
|
4
|
-
drop_table(:default_attachables) if table_exists?(:default_attachables)
|
|
5
|
-
drop_table(:default_attachable_versions) if table_exists?(:default_attachable_versions)
|
|
6
|
-
create_versioned_table(:default_attachables) do |t|
|
|
7
|
-
t.string :name
|
|
8
|
-
t.integer :attachment_id
|
|
9
|
-
t.integer :attachment_version
|
|
10
|
-
t.timestamps
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
drop_table(:versioned_attachables) if table_exists?(:versioned_attachables)
|
|
14
|
-
drop_table(:versioned_attachable_versions) if table_exists?(:versioned_attachable_versions)
|
|
15
|
-
create_versioned_table(:versioned_attachables) do |t|
|
|
16
|
-
t.string :name
|
|
17
|
-
t.integer :attachment_id
|
|
18
|
-
t.integer :attachment_version
|
|
19
|
-
t.timestamps
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
drop_table(:versioned_attachables) if table_exists?(:versioned_attachables)
|
|
23
|
-
drop_table(:versioned_attachable_versions) if table_exists?(:versioned_attachable_versions)
|
|
24
|
-
create_versioned_table(:versioned_attachables) do |t|
|
|
25
|
-
t.string :name
|
|
26
|
-
t.integer :attachment_id
|
|
27
|
-
t.integer :attachment_version
|
|
28
|
-
t.timestamps
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
class DefaultAttachable < ActiveRecord::Base
|
|
34
|
-
acts_as_content_block :belongs_to_attachment => true
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
class VersionedAttachable < ActiveRecord::Base
|
|
38
|
-
acts_as_content_block :belongs_to_attachment => true
|
|
39
|
-
|
|
40
|
-
def use_default_attachment_path
|
|
41
|
-
if @attachment_file_path && @attachment_file_path != attachment.file_path
|
|
42
|
-
attachment.file_path = @attachment_file_path
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def set_attachment_section
|
|
47
|
-
if @attachment_section_id && @attachment_section_id != attachment.section_id
|
|
48
|
-
attachment.section_id = @attachment_section_id
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
class DefaultAttachableTest < ActiveSupport::TestCase
|
|
54
|
-
def setup
|
|
55
|
-
remove_all_sitemap_fixtures_to_avoid_bugs
|
|
56
|
-
|
|
57
|
-
#file is a mock of the object that Rails wraps file uploads in
|
|
58
|
-
@file = file_upload_object(:original_filename => "foo.jpg",
|
|
59
|
-
:content_type => "image/jpeg", :rewind => true,
|
|
60
|
-
:size => "99", :read => "01010010101010101")
|
|
61
|
-
|
|
62
|
-
@section = root_section
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def test_create_with_attachment_file
|
|
66
|
-
@attachable = DefaultAttachable.new(:name => "File Name", :attachment_file => @file, :publish_on_save => true)
|
|
67
|
-
|
|
68
|
-
attachable_count = DefaultAttachable.count
|
|
69
|
-
|
|
70
|
-
@attachable.save!
|
|
71
|
-
|
|
72
|
-
assert_incremented attachable_count, DefaultAttachable.count
|
|
73
|
-
assert_equal @section, @attachable.attachment_section
|
|
74
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
|
75
|
-
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
|
76
|
-
|
|
77
|
-
reset(:attachable)
|
|
78
|
-
|
|
79
|
-
assert_equal @section, @attachable.attachment_section
|
|
80
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
|
81
|
-
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
|
82
|
-
assert @attachable.attachment.published?
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def test_create_without_attachment_and_then_add_attachment_on_edit
|
|
86
|
-
@attachable = DefaultAttachable.new(:name => "File Name",
|
|
87
|
-
:attachment_file => nil, :publish_on_save => true)
|
|
88
|
-
|
|
89
|
-
assert_difference 'DefaultAttachable.count' do
|
|
90
|
-
assert_valid @attachable
|
|
91
|
-
@attachable.save!
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
assert_nil @attachable.attachment_file_path
|
|
95
|
-
|
|
96
|
-
reset(:attachable)
|
|
97
|
-
|
|
98
|
-
@attachable.attachment_file = @file
|
|
99
|
-
@attachable.save
|
|
100
|
-
@attachable.publish
|
|
101
|
-
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
|
102
|
-
|
|
103
|
-
reset(:attachable)
|
|
104
|
-
|
|
105
|
-
assert_equal @section, @attachable.attachment_section
|
|
106
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
|
107
|
-
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
|
108
|
-
assert @attachable.attachment.published?
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
class AttachingTest < ActiveSupport::TestCase
|
|
113
|
-
|
|
114
|
-
def test_block_without_attaching_behavior
|
|
115
|
-
assert !HtmlBlock.belongs_to_attachment?
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def test_file_path_sanitization
|
|
119
|
-
{
|
|
120
|
-
"Draft #1.txt" => "Draft_1.txt",
|
|
121
|
-
"Copy of 100% of Paul's Time(1).txt" => "Copy_of_100_of_Pauls_Time-1-.txt"
|
|
122
|
-
}.each do |example, expected|
|
|
123
|
-
assert_equal expected,
|
|
124
|
-
VersionedAttachable.new.sanitize_file_path(example)
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
class AttachableTest < ActiveSupport::TestCase
|
|
131
|
-
def setup
|
|
132
|
-
#file is a mock of the object that Rails wraps file uploads in
|
|
133
|
-
@file = file_upload_object(:original_filename => "foo.jpg",
|
|
134
|
-
:content_type => "image/jpeg", :rewind => true,
|
|
135
|
-
:size => "99", :read => "01010010101010101")
|
|
136
|
-
|
|
137
|
-
@section = Factory(:section, :name => "attachables", :parent => root_section)
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def test_create_with_attachment_section_id_attachment_file_and_attachment_file_path
|
|
141
|
-
@attachable = VersionedAttachable.new(:name => "Section ID, File and File Name",
|
|
142
|
-
:attachment_section_id => @section.id,
|
|
143
|
-
:attachment_file => @file,
|
|
144
|
-
:attachment_file_path => "test.jpg")
|
|
145
|
-
|
|
146
|
-
assert_was_saved_properly
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def test_create_with_attachment_section_attachment_file_and_attachment_file_path
|
|
150
|
-
@attachable = VersionedAttachable.new(:name => "Section, File and File Name",
|
|
151
|
-
:attachment_section => @section,
|
|
152
|
-
:attachment_file => @file,
|
|
153
|
-
:attachment_file_path => "test.jpg")
|
|
154
|
-
|
|
155
|
-
assert_was_saved_properly
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def test_create_with_an_attachment_section_but_no_attachment_file
|
|
159
|
-
@attachable = VersionedAttachable.new(:name => "Section, No File",
|
|
160
|
-
:attachment_section => @section)
|
|
161
|
-
|
|
162
|
-
attachable_count = VersionedAttachable.count
|
|
163
|
-
|
|
164
|
-
assert !@attachable.save
|
|
165
|
-
|
|
166
|
-
assert_equal attachable_count, VersionedAttachable.count
|
|
167
|
-
assert_equal @section, @attachable.attachment_section
|
|
168
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
|
169
|
-
assert_nil @attachable.attachment_file_path
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def test_create_with_an_attachment_file_but_no_attachment_section
|
|
173
|
-
@attachable = VersionedAttachable.new(:name => "File Name, No File",
|
|
174
|
-
:attachment_file_path => "whatever.jpg")
|
|
175
|
-
|
|
176
|
-
attachable_count = VersionedAttachable.count
|
|
177
|
-
|
|
178
|
-
assert !@attachable.save
|
|
179
|
-
|
|
180
|
-
assert_equal attachable_count, VersionedAttachable.count
|
|
181
|
-
assert_nil @attachable.attachment_section
|
|
182
|
-
assert_nil @attachable.attachment_section_id
|
|
183
|
-
assert_equal "whatever.jpg", @attachable.attachment_file_path
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def test_create_screwy_attachment_file_name
|
|
187
|
-
@attachable = VersionedAttachable.new(:name => "Section ID, File and File Name",
|
|
188
|
-
:attachment_section_id => @section.id,
|
|
189
|
-
:attachment_file => @file,
|
|
190
|
-
:attachment_file_path => "Broken? Yes & No!.txt")
|
|
191
|
-
|
|
192
|
-
attachable_count = VersionedAttachable.count
|
|
193
|
-
|
|
194
|
-
assert @attachable.save
|
|
195
|
-
|
|
196
|
-
assert_incremented attachable_count, VersionedAttachable.count
|
|
197
|
-
assert_equal "/Broken_Yes_-_No.txt", @attachable.attachment_file_path
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def test_updating_the_attachment_file_name
|
|
201
|
-
@attachable = VersionedAttachable.create!(:name => "Foo",
|
|
202
|
-
:attachment_section_id => @section.id,
|
|
203
|
-
:attachment_file => @file,
|
|
204
|
-
:attachment_file_path => "test.jpg")
|
|
205
|
-
reset(:attachable)
|
|
206
|
-
|
|
207
|
-
attachment_count = Attachment.count
|
|
208
|
-
attachment_version = @attachable.attachment_version
|
|
209
|
-
attachment_version_count = Attachment::Version.count
|
|
210
|
-
|
|
211
|
-
assert @attachable.update_attributes(:attachment_file_path => "test2.jpg", :publish_on_save => true)
|
|
212
|
-
|
|
213
|
-
assert_equal attachment_count, Attachment.count
|
|
214
|
-
assert_incremented attachment_version, @attachable.attachment_version
|
|
215
|
-
assert_incremented attachment_version_count, Attachment::Version.count
|
|
216
|
-
assert_equal "/test2.jpg", @attachable.attachment_file_path
|
|
217
|
-
|
|
218
|
-
reset(:attachable)
|
|
219
|
-
|
|
220
|
-
assert_equal attachment_count, Attachment.count
|
|
221
|
-
assert_incremented attachment_version, @attachable.attachment_version
|
|
222
|
-
assert_incremented attachment_version_count, Attachment::Version.count
|
|
223
|
-
assert_equal "/test2.jpg", @attachable.attachment_file_path
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
def test_updating_the_attachment_file
|
|
227
|
-
@attachable = VersionedAttachable.create!(:name => "Foo",
|
|
228
|
-
:attachment_section_id => @section.id,
|
|
229
|
-
:attachment_file => @file,
|
|
230
|
-
:attachment_file_path => "test.jpg")
|
|
231
|
-
|
|
232
|
-
reset(:attachable)
|
|
233
|
-
|
|
234
|
-
@file2 = file_upload_object(:original_filename => "foo.txt",
|
|
235
|
-
:content_type => "image/jpeg", :rewind => true,
|
|
236
|
-
:size => "99", :read => "Foo v2")
|
|
237
|
-
|
|
238
|
-
attachment_count = Attachment.count
|
|
239
|
-
attachment_version = @attachable.attachment_version
|
|
240
|
-
attachment_version_count = Attachment::Version.count
|
|
241
|
-
|
|
242
|
-
assert @attachable.update_attributes(:attachment_file => @file2)
|
|
243
|
-
|
|
244
|
-
assert_equal attachment_count, Attachment.count
|
|
245
|
-
assert_equal attachment_version, @attachable.reload.attachment_version
|
|
246
|
-
assert_incremented attachment_version_count, Attachment::Version.count
|
|
247
|
-
@file.rewind
|
|
248
|
-
assert_equal @file.read, open(@attachable.attachment.full_file_location){|f| f.read}
|
|
249
|
-
|
|
250
|
-
reset(:attachable)
|
|
251
|
-
@file.rewind
|
|
252
|
-
@file2.rewind
|
|
253
|
-
|
|
254
|
-
assert_equal @file.read, open(@attachable.attachment.as_of_version(1).full_file_location){|f| f.read}
|
|
255
|
-
assert_equal @file2.read, open(@attachable.attachment.as_of_version(2).full_file_location){|f| f.read}
|
|
256
|
-
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
protected
|
|
260
|
-
def assert_was_saved_properly
|
|
261
|
-
attachable_count = VersionedAttachable.count
|
|
262
|
-
|
|
263
|
-
assert @attachable.save
|
|
264
|
-
|
|
265
|
-
assert_incremented attachable_count, VersionedAttachable.count
|
|
266
|
-
assert_equal @section, @attachable.attachment_section
|
|
267
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
|
268
|
-
assert_equal "/test.jpg", @attachable.attachment_file_path
|
|
269
|
-
|
|
270
|
-
reset(:attachable)
|
|
271
|
-
|
|
272
|
-
assert_equal @section, @attachable.attachment_section
|
|
273
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
|
274
|
-
assert_equal "/test.jpg", @attachable.attachment_file_path
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
class VersionedAttachableTest < ActiveSupport::TestCase
|
|
280
|
-
def setup
|
|
281
|
-
#file is a mock of the object that Rails wraps file uploads in
|
|
282
|
-
@file = file_upload_object(:original_filename => "foo.jpg",
|
|
283
|
-
:content_type => "image/jpeg", :rewind => true,
|
|
284
|
-
:size => "99", :read => "01010010101010101")
|
|
285
|
-
|
|
286
|
-
@section = Factory(:section, :name => "attachables", :parent => root_section)
|
|
287
|
-
|
|
288
|
-
@attachable = VersionedAttachable.create!(:name => "Foo v1",
|
|
289
|
-
:attachment_section_id => @section.id,
|
|
290
|
-
:attachment_file => @file,
|
|
291
|
-
:attachment_file_path => "test.jpg")
|
|
292
|
-
reset(:attachable)
|
|
293
|
-
end
|
|
294
|
-
|
|
295
|
-
def test_updating_the_versioned_attachable
|
|
296
|
-
attachment_count = Attachment.count
|
|
297
|
-
attachment_version = @attachable.attachment_version
|
|
298
|
-
attachment_version_count = Attachment::Version.count
|
|
299
|
-
|
|
300
|
-
assert @attachable.update_attributes(:name => "Foo v2")
|
|
301
|
-
|
|
302
|
-
assert_equal attachment_count, Attachment.count
|
|
303
|
-
assert_equal attachment_version, @attachable.attachment_version
|
|
304
|
-
assert_equal attachment_version_count, Attachment::Version.count
|
|
305
|
-
assert_equal "Foo v2", @attachable.name
|
|
306
|
-
assert_equal @attachable.as_of_version(1).attachment, @attachable.as_of_version(2).attachment
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
def test_updating_the_versioned_attachable_attachment_file_path
|
|
310
|
-
attachable_count = VersionedAttachable.count
|
|
311
|
-
attachment_count = Attachment.count
|
|
312
|
-
attachment_version = @attachable.attachment_version
|
|
313
|
-
attachment_version_count = Attachment::Version.count
|
|
314
|
-
|
|
315
|
-
assert @attachable.update_attributes(:attachment_file_path => "test2.jpg")
|
|
316
|
-
|
|
317
|
-
assert_equal attachable_count, VersionedAttachable.count
|
|
318
|
-
assert_equal attachment_count, Attachment.count
|
|
319
|
-
assert_incremented attachment_version, @attachable.attachment_version
|
|
320
|
-
assert_incremented attachment_version_count, Attachment::Version.count
|
|
321
|
-
assert_equal "/test2.jpg", @attachable.attachment_file_path
|
|
322
|
-
|
|
323
|
-
assert_equal @attachable.as_of_version(1).attachment, @attachable.as_of_version(2).attachment
|
|
324
|
-
assert_not_equal @attachable.as_of_version(1).attachment_version, @attachable.as_of_version(2).attachment_version
|
|
325
|
-
assert_equal "/test.jpg", @attachable.as_of_version(1).attachment_file_path
|
|
326
|
-
assert_equal "/test2.jpg", @attachable.as_of_version(2).attachment_file_path
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
def test_updating_the_versioned_attachable_attachment_file
|
|
330
|
-
@file2 = file_upload_object(:original_filename => "foo.txt",
|
|
331
|
-
:content_type => "image/jpeg", :rewind => true,
|
|
332
|
-
:size => "99", :read => "Foo v2")
|
|
333
|
-
|
|
334
|
-
attachable_count = VersionedAttachable.count
|
|
335
|
-
attachment_count = Attachment.count
|
|
336
|
-
attachment_version = @attachable.attachment_version
|
|
337
|
-
attachment_version_count = Attachment::Version.count
|
|
338
|
-
|
|
339
|
-
assert @attachable.update_attributes(:attachment_file => @file2)
|
|
340
|
-
|
|
341
|
-
assert_equal attachable_count, VersionedAttachable.count
|
|
342
|
-
assert_equal attachment_count, Attachment.count
|
|
343
|
-
assert_incremented attachment_version, @attachable.attachment_version
|
|
344
|
-
assert_incremented attachment_version_count, Attachment::Version.count
|
|
345
|
-
|
|
346
|
-
@file2.rewind
|
|
347
|
-
assert_equal @file2.read, open(@attachable.attachment.full_file_location){|f| f.read}
|
|
348
|
-
|
|
349
|
-
@file.rewind
|
|
350
|
-
assert_equal @file.read, open(@attachable.attachment.as_of_version(1).full_file_location){|f| f.read}
|
|
351
|
-
|
|
352
|
-
@file2.rewind
|
|
353
|
-
assert_equal @file2.read, open(@attachable.attachment.as_of_version(2).full_file_location){|f| f.read}
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
end
|
|
357
|
-
|