browsercms 3.4.2 → 3.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -0
- data/app/assets/images/cms/file-uploading.gif +0 -0
- data/app/assets/javascripts/cms/application.js +1 -0
- data/app/assets/javascripts/cms/attachment_manager.js.erb +87 -0
- data/app/assets/javascripts/cms/core_library.js.erb +38 -25
- data/app/assets/stylesheets/cms/application.css.erb +1 -0
- data/app/assets/stylesheets/cms/attachment_manager.css.scss +28 -0
- data/app/controllers/cms/application_controller.rb +1 -1
- data/app/controllers/cms/attachments_controller.rb +45 -10
- data/app/controllers/cms/cache_controller.rb +1 -1
- data/app/controllers/cms/content_block_controller.rb +134 -122
- data/app/controllers/cms/content_controller.rb +143 -155
- data/app/controllers/cms/dashboard_controller.rb +11 -9
- data/app/controllers/cms/error_handling.rb +19 -7
- data/app/controllers/cms/file_blocks_controller.rb +2 -2
- data/app/controllers/cms/home_controller.rb +3 -0
- data/app/controllers/cms/section_nodes_controller.rb +52 -44
- data/app/controllers/cms/sections_controller.rb +4 -2
- data/app/controllers/cms/toolbar_controller.rb +14 -10
- data/app/helpers/cms/application_helper.rb +23 -19
- data/app/helpers/cms/form_builder.rb +65 -18
- data/app/helpers/cms/mobile_helper.rb +19 -0
- data/app/helpers/cms/path_helper.rb +30 -4
- data/app/helpers/cms/rendering_helper.rb +9 -1
- data/app/models/cms/abstract_file_block.rb +6 -6
- data/app/models/cms/attachment.rb +196 -107
- data/app/models/cms/category.rb +3 -0
- data/app/models/cms/category_type.rb +2 -0
- data/app/models/cms/connector.rb +3 -0
- data/app/models/cms/content_type.rb +3 -0
- data/app/models/cms/content_type_group.rb +2 -0
- data/app/models/cms/dynamic_view.rb +4 -0
- data/app/models/cms/email_message.rb +2 -0
- data/app/models/cms/file_block.rb +9 -2
- data/app/models/cms/group.rb +5 -2
- data/app/models/cms/group_permission.rb +2 -0
- data/app/models/cms/group_section.rb +3 -0
- data/app/models/cms/group_type.rb +2 -0
- data/app/models/cms/group_type_permission.rb +2 -0
- data/app/models/cms/html_block.rb +3 -2
- data/app/models/cms/image_block.rb +13 -2
- data/app/models/cms/page.rb +14 -3
- data/app/models/cms/page_route.rb +4 -0
- data/app/models/cms/page_route_condition.rb +1 -0
- data/app/models/cms/page_route_option.rb +2 -0
- data/app/models/cms/page_route_requirement.rb +1 -0
- data/app/models/cms/permission.rb +3 -0
- data/app/models/cms/portlet.rb +2 -2
- data/app/models/cms/redirect.rb +2 -0
- data/app/models/cms/section.rb +15 -1
- data/app/models/cms/section_node.rb +1 -0
- data/app/models/cms/site.rb +3 -0
- data/app/models/cms/tag.rb +2 -0
- data/app/models/cms/tagging.rb +3 -0
- data/app/models/cms/task.rb +5 -1
- data/app/models/cms/user.rb +1 -1
- data/app/models/cms/user_group_membership.rb +3 -0
- data/app/views/cms/attachments/_attachment.html.erb +14 -0
- data/app/views/cms/attachments/_attachment_table.html.erb +17 -0
- data/app/views/cms/attachments/_attachment_wrapper.html.erb +4 -0
- data/app/views/cms/blocks/index.html.erb +2 -3
- data/app/views/cms/blocks/show.html.erb +1 -1
- data/app/views/cms/dynamic_views/index.html.erb +1 -1
- data/app/views/cms/email_messages/index.html.erb +1 -1
- data/app/views/cms/file_blocks/_form.html.erb +1 -27
- data/app/views/cms/file_blocks/_section_selector.html.erb +13 -0
- data/app/views/cms/file_blocks/render.html.erb +3 -3
- data/app/views/cms/form_builder/_cms_attachment_manager.html.erb +26 -0
- data/app/views/cms/form_builder/_cms_file_field.html.erb +27 -35
- data/app/views/cms/groups/index.html.erb +1 -1
- data/app/views/cms/image_blocks/_form.html.erb +1 -27
- data/app/views/cms/image_blocks/render.html.erb +4 -1
- data/app/views/cms/page_routes/index.html.erb +3 -0
- data/app/views/cms/shared/error.xml.erb +8 -0
- data/app/views/cms/tags/render.html.erb +1 -1
- data/app/views/cms/toolbar/_mobile_toggle.html.erb +33 -0
- data/app/views/cms/users/index.html.erb +1 -1
- data/app/views/layouts/_page_toolbar.html.erb +2 -1
- data/bin/bcms +21 -26
- data/config/routes.rb +3 -2
- data/db/browsercms.seeds.rb +2 -1
- data/db/migrate/20111130221145_browsercms340.rb +5 -4
- data/db/migrate/20120329144406_browsercms350.rb +32 -0
- data/{test/dummy/db → db}/schema.rb +97 -128
- data/{performance_tuning_notes.md → doc/performance_tuning_notes.md} +0 -0
- data/doc/release_notes.md +74 -0
- data/lib/browsercms.rb +3 -0
- data/lib/cms/acts/content_block.rb +10 -2
- data/lib/cms/addressable.rb +8 -0
- data/lib/cms/attachments/attachment_serving.rb +59 -0
- data/lib/cms/attachments/configuration.rb +88 -0
- data/lib/cms/behaviors/attaching.rb +305 -136
- data/lib/cms/behaviors/connecting.rb +3 -4
- data/lib/cms/behaviors/dynamic_attributes.rb +121 -118
- data/lib/cms/behaviors/flush_cache_on_change.rb +1 -3
- data/lib/cms/behaviors/naming.rb +16 -0
- data/lib/cms/behaviors/pagination.rb +4 -1
- data/lib/cms/behaviors/publishing.rb +9 -3
- data/lib/cms/behaviors/searching.rb +3 -8
- data/lib/cms/behaviors/soft_deleting.rb +1 -0
- data/lib/cms/behaviors/taggable.rb +2 -0
- data/lib/cms/behaviors/versioning.rb +73 -120
- data/lib/cms/caching.rb +53 -11
- data/lib/cms/commands/actions.rb +19 -2
- data/lib/cms/configuration.rb +44 -0
- data/lib/cms/content_rendering_support.rb +9 -6
- data/lib/cms/default_accessible.rb +13 -0
- data/lib/cms/domain_support.rb +22 -0
- data/lib/cms/engine.rb +40 -19
- data/lib/cms/engine_helper.rb +54 -0
- data/lib/cms/extensions/active_record/connection_adapters/abstract/schema_statements.rb +14 -2
- data/lib/cms/mobile_aware.rb +67 -0
- data/lib/cms/route_extensions.rb +3 -0
- data/lib/cms/upgrades/v3_5_0.rb +155 -0
- data/lib/cms/version.rb +6 -1
- data/lib/generators/cms/content_block/content_block_generator.rb +14 -9
- data/lib/generators/cms/content_block/templates/_form.html.erb +17 -6
- data/lib/generators/cms/content_block/templates/render.html.erb +12 -5
- data/lib/generators/cms/template/template_generator.rb +11 -2
- data/lib/tasks/cms.rake +23 -0
- data/lib/templates/active_record/model/model.rb +6 -0
- metadata +127 -517
- data/.gitignore +0 -24
- data/.rvmrc +0 -2
- data/Gemfile +0 -29
- data/Gemfile.lock +0 -196
- data/Rakefile +0 -97
- data/app/assets/images/browsercms/.gitkeep +0 -0
- data/app/controllers/browsercms/application_controller.rb +0 -4
- data/browsercms.gemspec +0 -35
- data/config/cucumber.yml +0 -8
- data/config/database.jdbcmysql.yml +0 -30
- data/config/database.mysql.yml +0 -27
- data/config/database.postgres.yml +0 -25
- data/config/database.sqlite3.yml +0 -11
- data/config/environment.rb +0 -6
- data/config/initializers/query_reviewer_patch.rb +0 -12
- data/config/initializers/rack_1_2_1_patch.rb +0 -12
- data/config/locales/en.yml +0 -5
- data/features/acts_as_content_page.feature +0 -62
- data/features/add_content_to_pages.feature +0 -45
- data/features/caching.feature +0 -13
- data/features/ckeditor.feature +0 -11
- data/features/commands/confirm_aruba_works.feature +0 -24
- data/features/commands/generate_module.feature +0 -54
- data/features/commands/install_browsercms.feature +0 -21
- data/features/commands/new_demo_project.feature +0 -30
- data/features/commands/new_projects.feature +0 -50
- data/features/commands/upgrade_modules_to_3_4_0_from_3_1_x.feature +0 -19
- data/features/commands/upgrade_project_to_3_4_0_from_3_3_x.feature +0 -52
- data/features/commands/upgrading_modules.feature +0 -67
- data/features/content_blocks/manage_custom_blocks.feature +0 -67
- data/features/content_blocks/manage_html_blocks.feature +0 -48
- data/features/content_blocks/manage_image_blocks.feature +0 -41
- data/features/content_files.feature +0 -37
- data/features/content_pages.feature +0 -21
- data/features/generators/content_blocks_for_modules.feature +0 -58
- data/features/generators/content_blocks_for_projects.feature +0 -109
- data/features/install_content.feature +0 -25
- data/features/jquery-testplan.txt +0 -12
- data/features/manage_groups.feature +0 -33
- data/features/manage_page_routes.feature +0 -72
- data/features/manage_redirects.feature +0 -20
- data/features/manage_sections.feature +0 -12
- data/features/manage_tasks.feature +0 -25
- data/features/manage_users.feature +0 -38
- data/features/page_templates.feature +0 -49
- data/features/portlets/email_friend_portlet.feature +0 -29
- data/features/portlets/portlets.feature +0 -100
- data/features/portlets/tag_cloud_portlet.feature +0 -28
- data/features/sitemap/create_pages.feature +0 -15
- data/features/sitemap/manage_links.feature +0 -29
- data/features/sitemap/sitemap.feature +0 -18
- data/features/step_definitions/acts_as_content_page_steps.rb.rb +0 -3
- data/features/step_definitions/ckeditor_steps.rb +0 -13
- data/features/step_definitions/command_line_steps.rb +0 -212
- data/features/step_definitions/content_pages_steps.rb +0 -170
- data/features/step_definitions/data_steps.rb +0 -48
- data/features/step_definitions/edit_page_templates_steps.rb +0 -21
- data/features/step_definitions/html_blocks_steps.rb +0 -9
- data/features/step_definitions/install_content_steps.rb +0 -4
- data/features/step_definitions/manage_content_blocks_steps.rb +0 -26
- data/features/step_definitions/manage_image_blocks_steps.rb +0 -31
- data/features/step_definitions/manage_sections_steps.rb +0 -18
- data/features/step_definitions/manage_user_steps.rb +0 -22
- data/features/step_definitions/more_custom_block_steps.rb +0 -34
- data/features/step_definitions/page_route_steps.rb +0 -65
- data/features/step_definitions/page_template_steps.rb +0 -5
- data/features/step_definitions/permissions_steps.rb +0 -13
- data/features/step_definitions/portlets_steps.rb +0 -64
- data/features/step_definitions/redirect_steps.rb +0 -12
- data/features/step_definitions/sitemap_steps.rb +0 -18
- data/features/step_definitions/tag_cloud_steps.rb +0 -11
- data/features/step_definitions/task_steps.rb +0 -4
- data/features/step_definitions/taxonomy_steps.rb +0 -16
- data/features/step_definitions/upgrade_module_steps.rb +0 -76
- data/features/step_definitions/web_steps.rb +0 -211
- data/features/support/async_support.rb +0 -17
- data/features/support/command_line_helpers.rb +0 -63
- data/features/support/debug_formatter.rb +0 -7
- data/features/support/debugging.rb +0 -28
- data/features/support/env.rb +0 -73
- data/features/support/git_api.rb +0 -9
- data/features/support/open_on_first_failure.rb +0 -25
- data/features/support/paths.rb +0 -32
- data/features/support/rails_api.rb +0 -8
- data/features/support/selectors.rb +0 -39
- data/features/support/transforms.rb +0 -7
- data/features/taxonomy/add_content_with_category.feature +0 -30
- data/features/taxonomy/manage_categories.feature +0 -20
- data/features/taxonomy/manage_category_types.feature +0 -16
- data/lib/cms/init.rb +0 -105
- data/lib/tasks/data.rake +0 -43
- data/lib/tasks/db.rake +0 -82
- data/public/styled_file_field/index.html +0 -72
- data/script/cucumber +0 -10
- data/script/rails +0 -6
- data/test/console_helper.rb +0 -5
- data/test/custom_assertions.rb +0 -84
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -9
- data/test/dummy/app/assets/javascripts/content_page.js +0 -2
- data/test/dummy/app/assets/stylesheets/application.css +0 -7
- data/test/dummy/app/assets/stylesheets/content_page.css +0 -4
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/controllers/cms/products_controller.rb +0 -2
- data/test/dummy/app/controllers/cms/sample_blocks_controller.rb +0 -3
- data/test/dummy/app/controllers/content_page_controller.rb +0 -13
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/content_page_helper.rb +0 -2
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/cms/sample_block.rb +0 -22
- data/test/dummy/app/models/product.rb +0 -5
- data/test/dummy/app/views/cms/products/_form.html.erb +0 -7
- data/test/dummy/app/views/cms/products/render.html.erb +0 -3
- data/test/dummy/app/views/content_page/custom_page.html.erb +0 -3
- data/test/dummy/app/views/content_page/index.html.erb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/layouts/templates/default.html.erb +0 -17
- data/test/dummy/app/views/layouts/templates/subpage.html.erb +0 -16
- data/test/dummy/app/views/test_route/index.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -45
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -27
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -32
- data/test/dummy/config/environments/production.rb +0 -60
- data/test/dummy/config/environments/test.rb +0 -46
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/browsercms.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/quiet_sprocket_assets.rb +0 -13
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -23
- data/test/dummy/db/migrate/20111228141250_create_products.rb +0 -16
- data/test/dummy/db/seeds.rb +0 -1
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -26
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/dummy/test/functional/content_page_controller_test.rb +0 -9
- data/test/dummy/test/unit/helpers/content_page_helper_test.rb +0 -4
- data/test/factories.rb +0 -235
- data/test/fixtures/multipart/foo.jpg +0 -0
- data/test/fixtures/multipart/sample_upload.txt +0 -1
- data/test/fixtures/multipart/second_upload.txt +0 -1
- data/test/fixtures/multipart/test.jpg +0 -0
- data/test/fixtures/multipart/version1.txt +0 -1
- data/test/fixtures/multipart/version2.txt +0 -1
- data/test/functional/cms/cache_controller_test.rb +0 -16
- data/test/functional/cms/categories_controller_test.rb +0 -28
- data/test/functional/cms/connectors_controller_test.rb +0 -64
- data/test/functional/cms/content_block_controller_test.rb +0 -127
- data/test/functional/cms/content_controller_test.rb +0 -351
- data/test/functional/cms/dashboard_controller_test.rb +0 -20
- data/test/functional/cms/file_blocks_controller_test.rb +0 -55
- data/test/functional/cms/home_controller_test.rb +0 -160
- data/test/functional/cms/html_blocks_controller_test.rb +0 -159
- data/test/functional/cms/image_blocks_controller_test.rb +0 -78
- data/test/functional/cms/links_controller_test.rb +0 -92
- data/test/functional/cms/log/test.log +0 -0
- data/test/functional/cms/pages_controller_test.rb +0 -233
- data/test/functional/cms/portlets_controller_test.rb +0 -57
- data/test/functional/cms/sections_controller_test.rb +0 -234
- data/test/functional/cms/sessions_controller_test.rb +0 -80
- data/test/functional/cms/tasks_controller_test.rb +0 -64
- data/test/functional/cms/toolbar_controller_test.rb +0 -76
- data/test/functional/cms/users_controller_test.rb +0 -218
- data/test/integration/cms/password_management_test.rb +0 -66
- data/test/integration/sitemap_performance_test.rb +0 -26
- data/test/mock_file.rb +0 -33
- data/test/performance/browsing_test.rb +0 -9
- data/test/support/engine_controller_hacks.rb +0 -34
- data/test/support/factory_helpers.rb +0 -57
- data/test/support/rails_3_1_routes_hack.rb +0 -70
- data/test/test_helper.rb +0 -199
- data/test/test_logging.rb +0 -67
- data/test/unit/active_record_callbacks.rb +0 -50
- data/test/unit/behaviors/attaching_test.rb +0 -370
- data/test/unit/behaviors/cms_user_test.rb +0 -67
- data/test/unit/behaviors/connectable_test.rb +0 -32
- data/test/unit/behaviors/connecting_test.rb +0 -56
- data/test/unit/behaviors/dynamic_attributes_test.rb +0 -74
- data/test/unit/behaviors/namespacing_test.rb +0 -76
- data/test/unit/behaviors/publishable_test.rb +0 -83
- data/test/unit/behaviors/rendering_test.rb +0 -68
- data/test/unit/behaviors/searching_test.rb +0 -102
- data/test/unit/behaviors/taggable_test.rb +0 -110
- data/test/unit/behaviors/userstamping_test.rb +0 -27
- data/test/unit/behaviors/versioning_test.rb +0 -102
- data/test/unit/extensions/active_record/base_test.rb +0 -25
- data/test/unit/extensions/hash_test.rb +0 -26
- data/test/unit/extensions/integer_test.rb +0 -10
- data/test/unit/extensions/string_test.rb +0 -14
- data/test/unit/factories_test.rb +0 -50
- data/test/unit/generators/install_generator_test.rb +0 -15
- data/test/unit/helpers/application_helper_test.rb +0 -104
- data/test/unit/helpers/date_picker_test.rb +0 -17
- data/test/unit/helpers/menu_helper_test.rb +0 -240
- data/test/unit/helpers/page_helper_test.rb +0 -69
- data/test/unit/helpers/path_helper_test.rb +0 -38
- data/test/unit/helpers/rendering_helper_test.rb +0 -8
- 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/engine_helper_test.rb +0 -119
- data/test/unit/lib/cms/sitemap_test.rb +0 -210
- data/test/unit/lib/cms_domain_support_test.rb +0 -44
- data/test/unit/lib/command_line_test.rb +0 -70
- data/test/unit/lib/content_block_test.rb +0 -304
- 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 -98
- data/test/unit/mock_file_test.rb +0 -19
- data/test/unit/models/attachment_test.rb +0 -160
- 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_group_test.rb +0 -26
- data/test/unit/models/content_type_test.rb +0 -177
- data/test/unit/models/dynamic_views_test.rb +0 -36
- data/test/unit/models/email_page_portlet_test.rb +0 -20
- data/test/unit/models/file_block_test.rb +0 -246
- data/test/unit/models/group_test.rb +0 -29
- data/test/unit/models/html_block_test.rb +0 -121
- data/test/unit/models/image_block_test.rb +0 -35
- data/test/unit/models/link_test.rb +0 -52
- data/test/unit/models/namespaces_test.rb +0 -57
- data/test/unit/models/page_partial_test.rb +0 -37
- data/test/unit/models/page_route_test.rb +0 -113
- data/test/unit/models/page_template_test.rb +0 -50
- data/test/unit/models/page_test.rb +0 -879
- data/test/unit/models/permission_test.rb +0 -10
- data/test/unit/models/portlet_test.rb +0 -99
- data/test/unit/models/sections_test.rb +0 -278
- data/test/unit/models/site_test.rb +0 -50
- data/test/unit/models/task_test.rb +0 -150
- data/test/unit/models/user_test.rb +0 -358
- data/test/unit/schema_statements_test.rb +0 -137
- data/todo_list.markdown +0 -50
@@ -1,50 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '/../test_helper')
|
2
|
-
|
3
|
-
class ActiveRecordCallbacksTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
# test "When callbacks occur" do
|
6
|
-
# b = HtmlBlock.new(:name=>"NAME")
|
7
|
-
# assert b.save
|
8
|
-
# end
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@page = Factory(:page, :section => root_section)
|
12
|
-
@block = Factory(:html_block, :name => "Versioned Content Block")
|
13
|
-
@page.create_connector(@block, "main")
|
14
|
-
reset(:page, :block)
|
15
|
-
end
|
16
|
-
|
17
|
-
# Copy back to content_block_test if there are any changes.
|
18
|
-
# def test_editing_connected_to_an_unpublished_page
|
19
|
-
# page_version_count = Page::Version.count
|
20
|
-
# assert_equal 2, @page.versions.size, "Should be two versions of the page"
|
21
|
-
# assert !@page.published?
|
22
|
-
#
|
23
|
-
# pages = Page.connected_to(:connectable => @block, :version => @block.version).all
|
24
|
-
# assert_equal [@page], pages, "block should be connected to page"
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# assert @block.update_attributes(:name => "something different")
|
28
|
-
# assert_equal false, @block.skip_callbacks
|
29
|
-
# assert_equal 2, @block.versions.size, "should be two versions of this block"
|
30
|
-
# reset(:page)
|
31
|
-
#
|
32
|
-
#
|
33
|
-
# assert !@page.published?
|
34
|
-
# assert_equal 3, @page.versions.size, "Should be three versions of the page."
|
35
|
-
# assert_equal 3, @page.draft.version, "Draft version of page should be updated to v3 since its connected to the updated block."
|
36
|
-
# assert_incremented page_version_count, Page::Version.count
|
37
|
-
# assert_match /^HtmlBlock #\d+ was Edited/, @page.draft.version_comment
|
38
|
-
#
|
39
|
-
# conns = @block.connectors.all(:order => 'id')
|
40
|
-
# assert_equal 2, conns.size
|
41
|
-
# assert_properties conns[0], :page => @page, :page_version => 2, :connectable => @block, :connectable_version => 1, :container => "main"
|
42
|
-
# assert_properties conns[1], :page => @page, :page_version => 3, :connectable => @block, :connectable_version => 2, :container => "main"
|
43
|
-
# end
|
44
|
-
|
45
|
-
test "Creation of connectors" do
|
46
|
-
assert_equal 1, @block.connectors.all.size
|
47
|
-
assert @block.update_attributes(:name => "something different")
|
48
|
-
assert_equal 2, @block.connectors.all.size
|
49
|
-
end
|
50
|
-
end
|
@@ -1,370 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
|
4
|
-
ActiveRecord::Base.connection.instance_eval do
|
5
|
-
drop_table(:default_attachables) rescue nil
|
6
|
-
drop_table(:default_attachable_versions) rescue nil
|
7
|
-
create_content_table(:default_attachables, :prefix => false) do |t|
|
8
|
-
t.string :name
|
9
|
-
t.integer :attachment_id
|
10
|
-
t.integer :attachment_version
|
11
|
-
t.timestamps
|
12
|
-
end
|
13
|
-
|
14
|
-
drop_table(:versioned_attachables) rescue nil
|
15
|
-
drop_table(:versioned_attachable_versions) rescue nil
|
16
|
-
create_content_table(:versioned_attachables, :prefix => false) do |t|
|
17
|
-
t.string :name
|
18
|
-
t.integer :attachment_id
|
19
|
-
t.integer :attachment_version
|
20
|
-
t.timestamps
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class DefaultAttachable < ActiveRecord::Base
|
25
|
-
acts_as_content_block :belongs_to_attachment => true
|
26
|
-
end
|
27
|
-
|
28
|
-
class VersionedAttachable < ActiveRecord::Base
|
29
|
-
acts_as_content_block :belongs_to_attachment => true
|
30
|
-
|
31
|
-
def use_default_attachment_path
|
32
|
-
if @attachment_file_path && @attachment_file_path != attachment.file_path
|
33
|
-
attachment.file_path = @attachment_file_path
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def set_attachment_section
|
38
|
-
if @attachment_section_id && @attachment_section_id != attachment.section_id
|
39
|
-
attachment.section_id = @attachment_section_id
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
module Cms
|
45
|
-
class AttachableBehaviorTest < ActiveSupport::TestCase
|
46
|
-
|
47
|
-
def setup
|
48
|
-
@file = mock_file
|
49
|
-
@attachable = DefaultAttachable.create!(:name => "File Name", :attachment_section_id => root_section, :attachment_file => @file, :publish_on_save => true)
|
50
|
-
end
|
51
|
-
|
52
|
-
test "Saving a block which an attachment should save both and associate it" do
|
53
|
-
content = DefaultAttachable.find(@attachable.id)
|
54
|
-
assert_not_nil content.attachment
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
class DefaultAttachableTest < ActiveSupport::TestCase
|
59
|
-
def setup
|
60
|
-
remove_all_sitemap_fixtures_to_avoid_bugs
|
61
|
-
|
62
|
-
#file is a mock of the object that Rails wraps file uploads in
|
63
|
-
@file = mock_file
|
64
|
-
@section = root_section
|
65
|
-
end
|
66
|
-
|
67
|
-
test "Create a block with an attached file" do
|
68
|
-
@attachable = DefaultAttachable.create!(:name => "File Name", :attachment_file => @file, :publish_on_save => true)
|
69
|
-
|
70
|
-
assert_equal @section, @attachable.attachment_section
|
71
|
-
|
72
|
-
@attachable = DefaultAttachable.find(@attachable.id)
|
73
|
-
|
74
|
-
assert_not_nil @attachable.attachment, "Should have an attachment"
|
75
|
-
assert_equal @section, @attachable.attachment_section
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_create_with_attachment_file
|
80
|
-
@attachable = DefaultAttachable.new(:name => "File Name", :attachment_file => @file, :publish_on_save => true)
|
81
|
-
attachable_count = DefaultAttachable.count
|
82
|
-
|
83
|
-
@attachable.save!
|
84
|
-
|
85
|
-
assert_incremented attachable_count, DefaultAttachable.count
|
86
|
-
assert_equal @section, @attachable.attachment_section
|
87
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
88
|
-
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
89
|
-
|
90
|
-
reset(:attachable)
|
91
|
-
|
92
|
-
assert_equal @section, @attachable.attachment_section
|
93
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
94
|
-
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
95
|
-
assert @attachable.attachment.published?
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_create_without_attachment_and_then_add_attachment_on_edit
|
99
|
-
@attachable = DefaultAttachable.new(:name => "File Name",
|
100
|
-
:attachment_file => nil, :publish_on_save => true)
|
101
|
-
|
102
|
-
assert_difference 'DefaultAttachable.count' do
|
103
|
-
assert_valid @attachable
|
104
|
-
@attachable.save!
|
105
|
-
end
|
106
|
-
|
107
|
-
assert_nil @attachable.attachment_file_path
|
108
|
-
assert_nil @attachable.attachment, "There should be no attachment saved."
|
109
|
-
|
110
|
-
reset(:attachable)
|
111
|
-
|
112
|
-
@attachable.attachment_file = @file
|
113
|
-
assert_equal true, @attachable.save!
|
114
|
-
assert_equal true, @attachable.publish!
|
115
|
-
|
116
|
-
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
117
|
-
|
118
|
-
assert_not_nil @attachable.attachment, "After attaching a file, the Attachment should exist"
|
119
|
-
|
120
|
-
reset(:attachable)
|
121
|
-
|
122
|
-
assert_not_nil @attachable.attachment, "The attachment should have been saved and reloaded."
|
123
|
-
assert_equal @section, @attachable.attachment_section
|
124
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
125
|
-
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
126
|
-
assert @attachable.attachment.published?
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
class AttachingTest < ActiveSupport::TestCase
|
132
|
-
|
133
|
-
def test_block_without_attaching_behavior
|
134
|
-
assert !Cms::HtmlBlock.belongs_to_attachment?
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_file_path_sanitization
|
138
|
-
{
|
139
|
-
"Draft #1.txt" => "Draft_1.txt",
|
140
|
-
"Copy of 100% of Paul's Time(1).txt" => "Copy_of_100_of_Pauls_Time-1-.txt"
|
141
|
-
}.each do |example, expected|
|
142
|
-
assert_equal expected,
|
143
|
-
VersionedAttachable.new.sanitize_file_path(example)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
class AttachableTest < ActiveSupport::TestCase
|
150
|
-
|
151
|
-
def setup
|
152
|
-
#file is a mock of the object that Rails wraps file uploads in
|
153
|
-
@file = mock_file(:original_filename => "sample_upload.txt")
|
154
|
-
|
155
|
-
@section = Factory(:section, :name => "attachables", :parent => root_section)
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_create_with_attachment_section_id_attachment_file_and_attachment_file_path
|
159
|
-
@attachable = VersionedAttachable.new(:name => "Section ID, File and File Name",
|
160
|
-
:attachment_section_id => @section.id,
|
161
|
-
:attachment_file => @file,
|
162
|
-
:attachment_file_path => "test.jpg")
|
163
|
-
|
164
|
-
assert_was_saved_properly
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_create_with_attachment_section_attachment_file_and_attachment_file_path
|
168
|
-
@attachable = VersionedAttachable.new(:name => "Section, File and File Name",
|
169
|
-
:attachment_section => @section,
|
170
|
-
:attachment_file => @file,
|
171
|
-
:attachment_file_path => "test.jpg")
|
172
|
-
|
173
|
-
assert_was_saved_properly
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_create_with_an_attachment_section_but_no_attachment_file
|
177
|
-
@attachable = VersionedAttachable.new(:name => "Section, No File",
|
178
|
-
:attachment_section => @section)
|
179
|
-
|
180
|
-
attachable_count = VersionedAttachable.count
|
181
|
-
|
182
|
-
assert !@attachable.save
|
183
|
-
|
184
|
-
assert_equal attachable_count, VersionedAttachable.count
|
185
|
-
assert_equal @section, @attachable.attachment_section
|
186
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
187
|
-
assert_nil @attachable.attachment_file_path
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_create_with_an_attachment_file_but_no_attachment_section
|
191
|
-
@attachable = VersionedAttachable.new(:name => "File Name, No File",
|
192
|
-
:attachment_file_path => "whatever.jpg")
|
193
|
-
|
194
|
-
attachable_count = VersionedAttachable.count
|
195
|
-
|
196
|
-
assert !@attachable.save
|
197
|
-
|
198
|
-
assert_equal attachable_count, VersionedAttachable.count
|
199
|
-
assert_nil @attachable.attachment_section
|
200
|
-
assert_nil @attachable.attachment_section_id
|
201
|
-
assert_equal "whatever.jpg", @attachable.attachment_file_path
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_create_screwy_attachment_file_name
|
205
|
-
@attachable = VersionedAttachable.new(:name => "Section ID, File and File Name",
|
206
|
-
:attachment_section_id => @section.id,
|
207
|
-
:attachment_file => @file,
|
208
|
-
:attachment_file_path => "Broken? Yes & No!.txt")
|
209
|
-
|
210
|
-
attachable_count = VersionedAttachable.count
|
211
|
-
|
212
|
-
assert @attachable.save
|
213
|
-
|
214
|
-
assert_incremented attachable_count, VersionedAttachable.count
|
215
|
-
assert_equal "/Broken_Yes_-_No.txt", @attachable.attachment_file_path
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_updating_the_attachment_file_name
|
219
|
-
@attachable = VersionedAttachable.create!(:name => "Foo",
|
220
|
-
:attachment_section_id => @section.id,
|
221
|
-
:attachment_file => @file,
|
222
|
-
:attachment_file_path => "test.jpg")
|
223
|
-
reset(:attachable)
|
224
|
-
|
225
|
-
attachment_count = Cms::Attachment.count
|
226
|
-
attachment_version = @attachable.attachment_version
|
227
|
-
attachment_version_count = Cms::Attachment::Version.count
|
228
|
-
|
229
|
-
assert @attachable.update_attributes(:attachment_file_path => "test2.jpg", :publish_on_save => true)
|
230
|
-
|
231
|
-
assert_equal attachment_count, Cms::Attachment.count
|
232
|
-
|
233
|
-
assert_incremented attachment_version, @attachable.attachment_version
|
234
|
-
assert_incremented attachment_version_count, Cms::Attachment::Version.count
|
235
|
-
assert_equal "/test2.jpg", @attachable.attachment_file_path
|
236
|
-
|
237
|
-
reset(:attachable)
|
238
|
-
|
239
|
-
assert_equal attachment_count, Cms::Attachment.count
|
240
|
-
assert_incremented attachment_version, @attachable.attachment_version
|
241
|
-
assert_incremented attachment_version_count, Cms::Attachment::Version.count
|
242
|
-
assert_equal "/test2.jpg", @attachable.attachment_file_path
|
243
|
-
end
|
244
|
-
|
245
|
-
def test_updating_the_attachment_file
|
246
|
-
@attachable = VersionedAttachable.create!(:name => "Foo",
|
247
|
-
:attachment_section_id => @section.id,
|
248
|
-
:attachment_file => @file,
|
249
|
-
:attachment_file_path => "test.jpg")
|
250
|
-
|
251
|
-
reset(:attachable)
|
252
|
-
|
253
|
-
@file2 = mock_file(:original_filename => "second_upload.txt")
|
254
|
-
|
255
|
-
attachment_count = Cms::Attachment.count
|
256
|
-
attachment_version = @attachable.attachment_version
|
257
|
-
attachment_version_count = Cms::Attachment::Version.count
|
258
|
-
|
259
|
-
assert @attachable.update_attributes(:attachment_file => @file2)
|
260
|
-
|
261
|
-
assert_equal attachment_count, Cms::Attachment.count
|
262
|
-
assert_equal attachment_version, @attachable.reload.attachment_version
|
263
|
-
assert_incremented attachment_version_count, Cms::Attachment::Version.count
|
264
|
-
@file.rewind
|
265
|
-
assert_equal @file.read, open(@attachable.attachment.full_file_location) { |f| f.read }
|
266
|
-
|
267
|
-
reset(:attachable)
|
268
|
-
@file.rewind
|
269
|
-
@file2.rewind
|
270
|
-
|
271
|
-
assert_equal @file.read, open(@attachable.attachment.as_of_version(1).full_file_location) { |f| f.read }
|
272
|
-
assert_equal @file2.read, open(@attachable.attachment.as_of_version(2).full_file_location) { |f| f.read }
|
273
|
-
|
274
|
-
end
|
275
|
-
|
276
|
-
protected
|
277
|
-
def assert_was_saved_properly
|
278
|
-
attachable_count = VersionedAttachable.count
|
279
|
-
|
280
|
-
assert @attachable.save
|
281
|
-
|
282
|
-
assert_incremented attachable_count, VersionedAttachable.count
|
283
|
-
assert_equal @section, @attachable.attachment_section
|
284
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
285
|
-
assert_equal "/test.jpg", @attachable.attachment_file_path
|
286
|
-
|
287
|
-
reset(:attachable)
|
288
|
-
|
289
|
-
assert_equal @section, @attachable.attachment_section
|
290
|
-
assert_equal @section.id, @attachable.attachment_section_id
|
291
|
-
assert_equal "/test.jpg", @attachable.attachment_file_path
|
292
|
-
end
|
293
|
-
|
294
|
-
end
|
295
|
-
|
296
|
-
class VersionedAttachableTest < ActiveSupport::TestCase
|
297
|
-
def setup
|
298
|
-
#file is a mock of the object that Rails wraps file uploads in
|
299
|
-
@file = mock_file
|
300
|
-
|
301
|
-
@section = Factory(:section, :name => "attachables", :parent => root_section)
|
302
|
-
|
303
|
-
@attachable = VersionedAttachable.create!(:name => "Foo v1",
|
304
|
-
:attachment_section_id => @section.id,
|
305
|
-
:attachment_file => @file,
|
306
|
-
:attachment_file_path => "test.jpg")
|
307
|
-
reset(:attachable)
|
308
|
-
end
|
309
|
-
|
310
|
-
def test_updating_the_versioned_attachable
|
311
|
-
attachment_count = Cms::Attachment.count
|
312
|
-
attachment_version = @attachable.attachment_version
|
313
|
-
attachment_version_count = Cms::Attachment::Version.count
|
314
|
-
|
315
|
-
assert @attachable.update_attributes(:name => "Foo v2")
|
316
|
-
|
317
|
-
assert_equal attachment_count, Cms::Attachment.count
|
318
|
-
assert_equal attachment_version, @attachable.attachment_version
|
319
|
-
assert_equal attachment_version_count, Cms::Attachment::Version.count
|
320
|
-
assert_equal "Foo v2", @attachable.name
|
321
|
-
assert_equal @attachable.as_of_version(1).attachment, @attachable.as_of_version(2).attachment
|
322
|
-
end
|
323
|
-
|
324
|
-
def test_updating_the_versioned_attachable_attachment_file_path
|
325
|
-
attachable_count = VersionedAttachable.count
|
326
|
-
attachment_count = Cms::Attachment.count
|
327
|
-
attachment_version = @attachable.attachment_version
|
328
|
-
attachment_version_count = Cms::Attachment::Version.count
|
329
|
-
|
330
|
-
assert @attachable.update_attributes(:attachment_file_path => "test2.jpg")
|
331
|
-
|
332
|
-
assert_equal attachable_count, VersionedAttachable.count
|
333
|
-
assert_equal attachment_count, Cms::Attachment.count
|
334
|
-
assert_incremented attachment_version, @attachable.attachment_version
|
335
|
-
assert_incremented attachment_version_count, Cms::Attachment::Version.count
|
336
|
-
assert_equal "/test2.jpg", @attachable.attachment_file_path
|
337
|
-
|
338
|
-
assert_equal @attachable.as_of_version(1).attachment, @attachable.as_of_version(2).attachment
|
339
|
-
assert_not_equal @attachable.as_of_version(1).attachment_version, @attachable.as_of_version(2).attachment_version
|
340
|
-
assert_equal "/test.jpg", @attachable.as_of_version(1).attachment_file_path
|
341
|
-
assert_equal "/test2.jpg", @attachable.as_of_version(2).attachment_file_path
|
342
|
-
end
|
343
|
-
|
344
|
-
def test_updating_the_versioned_attachable_attachment_file
|
345
|
-
@file2 = mock_file(:original_filename => "second_upload.txt")
|
346
|
-
|
347
|
-
attachable_count = VersionedAttachable.count
|
348
|
-
attachment_count = Cms::Attachment.count
|
349
|
-
attachment_version = @attachable.attachment_version
|
350
|
-
attachment_version_count = Cms::Attachment::Version.count
|
351
|
-
|
352
|
-
assert @attachable.update_attributes(:attachment_file => @file2)
|
353
|
-
|
354
|
-
assert_equal attachable_count, VersionedAttachable.count
|
355
|
-
assert_equal attachment_count, Cms::Attachment.count
|
356
|
-
assert_incremented attachment_version, @attachable.attachment_version
|
357
|
-
assert_incremented attachment_version_count, Cms::Attachment::Version.count
|
358
|
-
|
359
|
-
@file2.rewind
|
360
|
-
assert_equal @file2.read, open(@attachable.attachment.full_file_location) { |f| f.read }
|
361
|
-
|
362
|
-
@file.rewind
|
363
|
-
assert_equal @file.read, open(@attachable.attachment.as_of_version(1).full_file_location) { |f| f.read }
|
364
|
-
|
365
|
-
@file2.rewind
|
366
|
-
assert_equal @file2.read, open(@attachable.attachment.as_of_version(2).full_file_location) { |f| f.read }
|
367
|
-
end
|
368
|
-
|
369
|
-
end
|
370
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
ActiveRecord::Base.connection.instance_eval do
|
4
|
-
drop_table(:external_users) if table_exists?(:external_users)
|
5
|
-
create_table(:external_users) do |t|
|
6
|
-
t.string :name
|
7
|
-
t.string :type
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
EXTERNAL_USER_GROUPS = Hash.new {|hash,key| hash[key] = Factory.build(:group)}
|
13
|
-
|
14
|
-
class ExternalUser < ActiveRecord::Base
|
15
|
-
end
|
16
|
-
|
17
|
-
class ExternalUserA < ExternalUser
|
18
|
-
acts_as_cms_user
|
19
|
-
end
|
20
|
-
|
21
|
-
class ExternalUserB < ExternalUser
|
22
|
-
acts_as_cms_user :groups => [EXTERNAL_USER_GROUPS['external-user-b']]
|
23
|
-
end
|
24
|
-
|
25
|
-
class ExternalUserC < ExternalUser
|
26
|
-
acts_as_cms_user :groups => Proc.new{ |external_user_c| EXTERNAL_USER_GROUPS['external-user-c'] }
|
27
|
-
end
|
28
|
-
|
29
|
-
class ExternalUserD < ExternalUser
|
30
|
-
acts_as_cms_user :groups => :get_groups
|
31
|
-
|
32
|
-
def get_groups
|
33
|
-
[EXTERNAL_USER_GROUPS['external-user-d1'], EXTERNAL_USER_GROUPS['external-user-d2']]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
class CmsUserTestCase < ActiveSupport::TestCase
|
40
|
-
def test_responds_to
|
41
|
-
@object = ExternalUserA.new(:name => "New Record")
|
42
|
-
[:cms_groups, :viewable_sections, :permissions, :able_to_view?, :able_to?].each do |req_method|
|
43
|
-
assert @object.respond_to?(req_method), "expected cms users to respond to #{req_method}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_default
|
48
|
-
@object = ExternalUserA.new(:name => "New Record")
|
49
|
-
assert_equal [Cms::Group.guest], @object.cms_groups
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_array_option
|
53
|
-
@object = ExternalUserB.new(:name => "New Record")
|
54
|
-
assert_equal [EXTERNAL_USER_GROUPS['external-user-b']], @object.cms_groups
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_proc_option
|
58
|
-
@object = ExternalUserC.new(:name => "New Record")
|
59
|
-
assert_equal [EXTERNAL_USER_GROUPS['external-user-c']], @object.cms_groups
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_instance_method_option
|
63
|
-
@object = ExternalUserD.new(:name => "New Record")
|
64
|
-
assert_equal [EXTERNAL_USER_GROUPS['external-user-d1'], EXTERNAL_USER_GROUPS['external-user-d2']], @object.cms_groups
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|