browsercms 3.4.2 → 3.5.0.rc1
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/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,35 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
module Cms
|
|
4
|
-
class ImageBlockTest < ActiveSupport::TestCase
|
|
5
|
-
|
|
6
|
-
def setup
|
|
7
|
-
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def teardown
|
|
11
|
-
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
test "#parent" do
|
|
15
|
-
image = Factory(:image_block)
|
|
16
|
-
assert_equal root_section, image.parent
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
test "default table_name" do
|
|
20
|
-
assert_equal Namespacing.prefix("file_blocks"), ImageBlock.table_name
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
test "non_versioned_columns should not include the version_foreign_ken" do
|
|
24
|
-
assert ImageBlock.non_versioned_columns.include?("original_record_id")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
test "version_foreign_key" do
|
|
28
|
-
assert_equal :original_record_id, ImageBlock.version_foreign_key
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "create works" do
|
|
32
|
-
ImageBlock.create!(:name=>"test")
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class LinkTest < ActiveSupport::TestCase
|
|
4
|
-
|
|
5
|
-
def setup
|
|
6
|
-
@link = Factory(:link)
|
|
7
|
-
@another_link = Factory(:link)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def test_create
|
|
11
|
-
assert Factory.build(:link).valid?
|
|
12
|
-
assert !Factory.build(:link, :name => "").valid?
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
test "draft_version is stored on pages" do
|
|
16
|
-
assert_equal 1, @link.version
|
|
17
|
-
assert_equal 1, @link.latest_version
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
test "#update increments the latest_version" do
|
|
21
|
-
@link.name = "New"
|
|
22
|
-
@link.save!
|
|
23
|
-
@link.reload
|
|
24
|
-
|
|
25
|
-
assert_equal 1, @link.version
|
|
26
|
-
assert_equal 2, @link.latest_version
|
|
27
|
-
|
|
28
|
-
assert_equal 1, @another_link.reload.latest_version, "Should only update its own version, not other tables"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "live?" do
|
|
32
|
-
assert @link.live?
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
test "updating makes it not live" do
|
|
36
|
-
@link.update_attributes(:name => "New")
|
|
37
|
-
@link.reload
|
|
38
|
-
refute @link.live?
|
|
39
|
-
|
|
40
|
-
@link.publish!
|
|
41
|
-
@link.reload
|
|
42
|
-
assert @link.live?
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
test "live? as_of_version" do
|
|
46
|
-
@link.update_attributes(:name => "New")
|
|
47
|
-
@link.publish!
|
|
48
|
-
|
|
49
|
-
v1 = @link.as_of_version(1)
|
|
50
|
-
assert v1.live?
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# This test is to verify that for all of our namespaced objects that the named reflections are valid.
|
|
3
|
-
# Mostly to ensure that :class_name is set where needed.
|
|
4
|
-
|
|
5
|
-
require 'test_helper'
|
|
6
|
-
|
|
7
|
-
class NamespacesTest < ActiveSupport::TestCase
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Fetches all of the subclasses from a given module by grabbing the defined constants
|
|
11
|
-
# and seeing if they are a Class or something else. Does not check to see if it is an
|
|
12
|
-
# AR class or if it has a blueprint.
|
|
13
|
-
def self.subclasses_from_module(module_name)
|
|
14
|
-
subclasses = []
|
|
15
|
-
mod = module_name.constantize
|
|
16
|
-
if mod.class == Module
|
|
17
|
-
mod.constants.each do |module_const_name|
|
|
18
|
-
begin
|
|
19
|
-
klass_name = "#{module_name}::#{module_const_name}"
|
|
20
|
-
klass = klass_name.constantize
|
|
21
|
-
if klass.class == Class
|
|
22
|
-
subclasses << klass
|
|
23
|
-
subclasses += klass.send(:descendants).collect{|x| x.respond_to?(:constantize) ? x.constantize : x}
|
|
24
|
-
else
|
|
25
|
-
subclasses += subclasses_from_module(klass_name)
|
|
26
|
-
end
|
|
27
|
-
rescue NameError
|
|
28
|
-
raise $!
|
|
29
|
-
puts $!.inspect
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
return subclasses
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# If you want to test more namespaces add them here.
|
|
37
|
-
classes = []
|
|
38
|
-
classes += subclasses_from_module("Cms")
|
|
39
|
-
classes.uniq!
|
|
40
|
-
|
|
41
|
-
classes.each do |klass|
|
|
42
|
-
test "ensure a #{klass.name} has valid reflections" do
|
|
43
|
-
if klass.kind_of? ActiveRecord::Base
|
|
44
|
-
@obj = klass.new
|
|
45
|
-
klass.reflections.each do |name, reflection|
|
|
46
|
-
assert_nothing_thrown("Error with #{name} reflection") do
|
|
47
|
-
@obj.send(name)
|
|
48
|
-
reflection.klass unless reflection.options[:polymorphic]
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class PagePartialTest < ActiveSupport::TestCase
|
|
4
|
-
def setup
|
|
5
|
-
@page_partial = Factory.build(:page_partial, :name => "_test")
|
|
6
|
-
File.delete(@page_partial.file_path) if File.exists?(@page_partial.file_path)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def teardown
|
|
10
|
-
File.delete(@page_partial.file_path) if File.exists?(@page_partial.file_path)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
test "Name used to build the form" do
|
|
14
|
-
assert_equal "page_partial", Cms::PagePartial.resource_collection_name
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
test "resource_name works for namespaced templates" do
|
|
18
|
-
assert_equal "page_partials", Cms::PagePartial.resource_name
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_create
|
|
22
|
-
assert !File.exists?(@page_partial.file_path), "partial file already exists"
|
|
23
|
-
assert_valid @page_partial
|
|
24
|
-
assert @page_partial.save
|
|
25
|
-
assert File.exists?(@page_partial.file_path), "partial file was not written to disk"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test_for_valid_name
|
|
29
|
-
assert_not_valid Factory.build(:page_partial, :name => "Fancy")
|
|
30
|
-
assert_not_valid Factory.build(:page_partial, :name => "foo bar")
|
|
31
|
-
partial = Factory.build(:page_partial, :name => "subpage_1_column")
|
|
32
|
-
assert_valid partial
|
|
33
|
-
assert_equal "_subpage_1_column", partial.name
|
|
34
|
-
assert_valid Factory.build(:page_partial, :name => "_sidebar")
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class PageRouteTest < ActiveSupport::TestCase
|
|
4
|
-
def setup
|
|
5
|
-
@route = Cms::PageRoute.new(:pattern=>"/:some/:pattern", :name=>"My Name")
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def test_create
|
|
10
|
-
page = Factory(:page, :path => "/things/overview")
|
|
11
|
-
route = page.page_routes.build(:pattern => "/things/:year/:month/:day")
|
|
12
|
-
route.add_requirement(:year, "\\d{4,}")
|
|
13
|
-
route.add_requirement(:month, "\\d{2,}")
|
|
14
|
-
route.add_requirement(:day, "\\d{2,}")
|
|
15
|
-
route.add_condition(:method, "get")
|
|
16
|
-
|
|
17
|
-
assert route.save!
|
|
18
|
-
assert_equal "/things/:year/:month/:day", route.pattern
|
|
19
|
-
assert_equal({
|
|
20
|
-
:controller => "cms/content",
|
|
21
|
-
:action => "show_page_route",
|
|
22
|
-
:_page_route_id => route.id.to_s,
|
|
23
|
-
:requirements => {
|
|
24
|
-
:year => /\d{4,}/,
|
|
25
|
-
:month => /\d{2,}/,
|
|
26
|
-
:day => /\d{2,}/
|
|
27
|
-
}, :conditions => {
|
|
28
|
-
:method => :get
|
|
29
|
-
}
|
|
30
|
-
}, route.options_map)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Rails 3 Routing
|
|
36
|
-
test "match :to" do
|
|
37
|
-
assert_equal "cms/content#show_page_route", @route.to
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
test "match :as" do
|
|
41
|
-
assert_equal "my_name", @route.route_name
|
|
42
|
-
assert_equal "my_name", @route.as
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
test "default method conditions" do
|
|
46
|
-
assert_equal [:get, :post], @route.via
|
|
47
|
-
end
|
|
48
|
-
test "setting method conditions" do
|
|
49
|
-
@route.add_condition(:method, "post")
|
|
50
|
-
assert_equal([:post], @route.via)
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
test "Using :via to constraint the callable methods" do
|
|
55
|
-
@route.via = :get
|
|
56
|
-
assert_equal [:get], @route.via
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
test "Specify multiple methods using :via to constraint the callable methods" do
|
|
60
|
-
@route.via = [:get, :propfind]
|
|
61
|
-
assert_equal [:get, :propfind], @route.via
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
test "constraints converts string key to symbol since routes requires it" do
|
|
65
|
-
@route.add_requirement("year", 'd{4}')
|
|
66
|
-
assert_equal(true, @route.constraints.include?(:year))
|
|
67
|
-
|
|
68
|
-
end
|
|
69
|
-
test "constraints allows for regular expressions to be set for pattern elements in a route" do
|
|
70
|
-
@route.add_requirement(:year, '\d{4,}')
|
|
71
|
-
assert_equal({:year => /\d{4,}/}, @route.constraints)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
test "add_constraint is replacement method for add_requirement " do
|
|
75
|
-
@route.add_requirement(:year, 'd{4}')
|
|
76
|
-
assert_equal({:year => /d{4}/}, @route.constraints)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
test "constraints handles more than one pattern" do
|
|
80
|
-
@route.add_requirement(:month, '\d{2,}')
|
|
81
|
-
@route.add_requirement(:day, '\d{2,}')
|
|
82
|
-
@route.add_requirement(:year, '\d{4,}')
|
|
83
|
-
assert_equal({:month => /\d{2,}/, :day => /\d{2,}/, :year => /\d{4,}/}, @route.constraints)
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class LoadingPageRoutesTest < ActiveSupport::TestCase
|
|
89
|
-
|
|
90
|
-
def setup
|
|
91
|
-
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
test "can_be_loaded?" do
|
|
95
|
-
Cms::PageRoute.expects(:database_exists?).returns(true)
|
|
96
|
-
Cms::PageRoute.expects(:table_exists?).returns(true)
|
|
97
|
-
|
|
98
|
-
assert_equal true, Cms::PageRoute.can_be_loaded?
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
test "Routes cannot be loaded if the table doesn't exist" do
|
|
102
|
-
Cms::PageRoute.expects(:database_exists?).returns(true)
|
|
103
|
-
Cms::PageRoute.expects(:table_exists?).returns(false)
|
|
104
|
-
|
|
105
|
-
assert_equal false, Cms::PageRoute.can_be_loaded?
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
test "Routes cannot be loaded if the database doesn't exist" do
|
|
109
|
-
Cms::PageRoute.expects(:database_exists?).returns(false)
|
|
110
|
-
|
|
111
|
-
assert_equal false, Cms::PageRoute.can_be_loaded?
|
|
112
|
-
end
|
|
113
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class PageTemplateTest < ActiveSupport::TestCase
|
|
4
|
-
def setup
|
|
5
|
-
@page_template = Factory.build(:page_template, :name => "test")
|
|
6
|
-
File.delete(@page_template.file_path) if File.exists?(@page_template.file_path)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def teardown
|
|
10
|
-
File.delete(@page_template.file_path) if File.exists?(@page_template.file_path)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
test "Name used to build the form" do
|
|
15
|
-
assert_equal "page_template", Cms::PageTemplate.resource_collection_name
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
test "resource_name works for namespaced templates" do
|
|
19
|
-
assert_equal "page_templates", Cms::PageTemplate.resource_name
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_create_and_destroy
|
|
24
|
-
assert !File.exists?(@page_template.file_path), "template file already exists"
|
|
25
|
-
assert_valid @page_template
|
|
26
|
-
assert @page_template.save
|
|
27
|
-
assert File.exists?(@page_template.file_path), "template file was not written to disk"
|
|
28
|
-
@page_template.destroy
|
|
29
|
-
assert !File.exists?(@page_template.file_path), "template file was not removed on destroy"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_for_valid_name
|
|
33
|
-
assert_not_valid Factory.build(:page_template, :name => "Fancy")
|
|
34
|
-
assert_not_valid Factory.build(:page_template, :name => "foo bar")
|
|
35
|
-
assert_valid Factory.build(:page_template, :name => "subpage_1_column")
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_find_by_file_name
|
|
39
|
-
assert @page_template.save, "Could not save page template"
|
|
40
|
-
assert_equal @page_template, Cms::PageTemplate.find_by_file_name("test.html.erb")
|
|
41
|
-
assert_nil Cms::PageTemplate.find_by_file_name("fail.html.erb")
|
|
42
|
-
assert_nil Cms::PageTemplate.find_by_file_name("fail.erb")
|
|
43
|
-
assert_nil Cms::PageTemplate.find_by_file_name("fail")
|
|
44
|
-
assert_nil Cms::PageTemplate.find_by_file_name(nil)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_default_body
|
|
48
|
-
assert_not_nil Cms::PageTemplate.default_body
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,879 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
module Cms
|
|
4
|
-
class CreatingPageTest < ActiveSupport::TestCase
|
|
5
|
-
|
|
6
|
-
test "Testing Database should be empty and have no pages" do
|
|
7
|
-
assert_nil Cms::Page.with_path("/").first
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def test_creating_a_page_and_updating_the_attributes
|
|
11
|
-
@page = Cms::Page.new(
|
|
12
|
-
:name => "Test",
|
|
13
|
-
:path => "test",
|
|
14
|
-
:section => root_section,
|
|
15
|
-
:publish_on_save => true)
|
|
16
|
-
|
|
17
|
-
assert @page.save
|
|
18
|
-
assert_path_is_unique
|
|
19
|
-
|
|
20
|
-
@page.update_attributes(:name => "Test v2")
|
|
21
|
-
page = Cms::Page.find_live_by_path("/test")
|
|
22
|
-
assert_equal "Test", page.name
|
|
23
|
-
|
|
24
|
-
assert_equal 1, page.version
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
test "Creating a page builds a section node" do
|
|
29
|
-
@page = Page.create!(:name => "Hello", :path => "/hello", :section => Factory(:root_section))
|
|
30
|
-
assert_not_nil @page.section_node
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
test "page with no parent" do
|
|
34
|
-
@page = Page.new
|
|
35
|
-
assert_nil @page.parent
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
test "#section is alias for #parent" do
|
|
39
|
-
@page = Page.new
|
|
40
|
-
assert_nil @page.section
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
protected
|
|
45
|
-
def assert_path_is_unique
|
|
46
|
-
page = Factory.build(:page, :path => @page.path)
|
|
47
|
-
assert_not_valid page
|
|
48
|
-
assert_has_error_on page, :path
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
class VersionTest < ActiveSupport::TestCase
|
|
54
|
-
|
|
55
|
-
def setup
|
|
56
|
-
@page = Factory(:public_page)
|
|
57
|
-
@another_page = Factory(:public_page)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
test "#latest_version set set when page is created" do
|
|
61
|
-
assert_equal 1, @page.version
|
|
62
|
-
assert_equal 1, @page.latest_version
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
test "#latest_version is incremented when page#update occurs" do
|
|
66
|
-
@page.name = "New"
|
|
67
|
-
@page.save!
|
|
68
|
-
@page.reload
|
|
69
|
-
|
|
70
|
-
assert_equal 1, @page.version
|
|
71
|
-
assert_equal 2, @page.latest_version
|
|
72
|
-
|
|
73
|
-
assert_equal 1, @another_page.reload.latest_version, "Should only update its own version, not other tables"
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
test "live? using latest version" do
|
|
77
|
-
assert @page.live?
|
|
78
|
-
|
|
79
|
-
@page.update_attributes(:name => "New")
|
|
80
|
-
@page.reload
|
|
81
|
-
refute @page.live?
|
|
82
|
-
|
|
83
|
-
@page.publish!
|
|
84
|
-
@page.reload
|
|
85
|
-
assert @page.live?
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
test "live? as_of_version" do
|
|
89
|
-
@page.update_attributes(:name => "New")
|
|
90
|
-
@page.publish!
|
|
91
|
-
|
|
92
|
-
v1 = @page.as_of_version(1)
|
|
93
|
-
assert v1.live?
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
class PageTest < ActiveSupport::TestCase
|
|
97
|
-
|
|
98
|
-
def test_creating_page_with_reserved_path
|
|
99
|
-
@page = Cms::Page.new(:name => "FAIL", :path => "/cms")
|
|
100
|
-
assert_not_valid @page
|
|
101
|
-
assert_has_error_on(@page, :path, "is invalid, '/cms' a reserved path")
|
|
102
|
-
|
|
103
|
-
@page = Cms::Page.new(:name => "FAIL", :path => "/cache")
|
|
104
|
-
assert_not_valid @page
|
|
105
|
-
assert_has_error_on(@page, :path, "is invalid, '/cache' a reserved path")
|
|
106
|
-
|
|
107
|
-
@page = Cms::Page.new(:name => "FTW", :path => "/whatever")
|
|
108
|
-
|
|
109
|
-
assert_valid @page
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def test_creating_page_with_trailing_slash
|
|
113
|
-
@page = Factory.build(:page, :path => "/slashed/")
|
|
114
|
-
@page.save
|
|
115
|
-
assert_equal @page.path, "/slashed"
|
|
116
|
-
|
|
117
|
-
@page = Factory.build(:page, :path => "/slashed/loooong/path/")
|
|
118
|
-
@page.save
|
|
119
|
-
assert_equal @page.path, "/slashed/loooong/path"
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def test_find_live_by_path
|
|
123
|
-
@page = Factory.build(:page, :path => '/foo')
|
|
124
|
-
assert_nil Cms::Page.find_live_by_path('/foo')
|
|
125
|
-
|
|
126
|
-
@page.publish!
|
|
127
|
-
reset(:page)
|
|
128
|
-
assert_equal @page, Cms::Page.find_live_by_path('/foo')
|
|
129
|
-
|
|
130
|
-
@page.update_attributes(:path => '/bar')
|
|
131
|
-
assert_equal @page, Cms::Page.find_live_by_path('/foo')
|
|
132
|
-
assert_nil Cms::Page.find_live_by_path('/bar')
|
|
133
|
-
|
|
134
|
-
@page.publish!
|
|
135
|
-
reset(:page)
|
|
136
|
-
assert_nil Cms::Page.find_live_by_path('/foo')
|
|
137
|
-
assert_equal @page, Cms::Page.find_live_by_path('/bar')
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
test "It should be possible to create a new page, using the same path as a previously deleted page" do
|
|
141
|
-
Cms::Page.delete_all
|
|
142
|
-
p = Time.now.to_f.to_s #use a unique, but consistent path
|
|
143
|
-
|
|
144
|
-
@page = Factory(:published_page, :path => "/#{p}")
|
|
145
|
-
@page.destroy
|
|
146
|
-
|
|
147
|
-
@page2 = Factory(:published_page, :path => "/#{p}")
|
|
148
|
-
assert_not_equal(@page, @page2)
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
test "Find by live path should not located deleted blocks, even if they share paths with live ones" do
|
|
152
|
-
@page = Factory.build(:page, :path => '/foo')
|
|
153
|
-
@page.publish!
|
|
154
|
-
reset(:page)
|
|
155
|
-
|
|
156
|
-
@page.mark_as_deleted!
|
|
157
|
-
assert_nil Cms::Page.find_live_by_path('/foo')
|
|
158
|
-
|
|
159
|
-
@new_page = Factory.build(:page, :path => '/foo')
|
|
160
|
-
assert_nil Cms::Page.find_live_by_path('/foo')
|
|
161
|
-
|
|
162
|
-
@new_page.publish!
|
|
163
|
-
reset(:new_page)
|
|
164
|
-
assert_equal @new_page, Cms::Page.find_live_by_path('/foo')
|
|
165
|
-
assert_not_equal @page, @new_page
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def test_path_normalization
|
|
169
|
-
page = Factory.build(:page, :path => 'foo/bar')
|
|
170
|
-
assert_valid page
|
|
171
|
-
assert_equal "/foo/bar", page.path
|
|
172
|
-
|
|
173
|
-
page = Factory.build(:page, :path => '/foo/bar')
|
|
174
|
-
assert_valid page
|
|
175
|
-
assert_equal "/foo/bar", page.path
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def test_template
|
|
179
|
-
page_template = Factory(:page_template, :name => 'test')
|
|
180
|
-
page = Factory.build(:page, :template_file_name => 'test.html.erb')
|
|
181
|
-
assert_equal 'test.html.erb', page.template_file_name
|
|
182
|
-
assert_equal 'Test (html/erb)', page.template_name
|
|
183
|
-
assert_equal page_template, page.template
|
|
184
|
-
assert_equal 'templates/test', page.layout
|
|
185
|
-
|
|
186
|
-
page = Factory.build(:page, :template_file_name => 'foo.html.erb')
|
|
187
|
-
assert_equal 'foo.html.erb', page.template_file_name
|
|
188
|
-
assert_equal 'Foo (html/erb)', page.template_name
|
|
189
|
-
assert_nil page.template
|
|
190
|
-
assert_equal 'templates/foo', page.layout
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def test_revision_comments
|
|
194
|
-
page = Factory(:page, :section => root_section, :name => "V1")
|
|
195
|
-
|
|
196
|
-
assert_equal 'Created', page.live_version.version_comment
|
|
197
|
-
|
|
198
|
-
assert page.reload.save
|
|
199
|
-
assert_equal 'Created', page.reload.live_version.version_comment
|
|
200
|
-
assert_equal page.live_version.version_comment,
|
|
201
|
-
page.as_of_version(page.version).live_version.version_comment
|
|
202
|
-
|
|
203
|
-
page.update_attributes(:name => "V2")
|
|
204
|
-
assert_equal 'Changed name', page.draft.version_comment
|
|
205
|
-
assert_equal 'Created', page.live_version.version_comment
|
|
206
|
-
|
|
207
|
-
block = Factory(:html_block, :name => "Hello, World!")
|
|
208
|
-
page.create_connector(block, "main")
|
|
209
|
-
assert_equal "Html Block 'Hello, World!' was added to the 'main' container",
|
|
210
|
-
page.draft.version_comment
|
|
211
|
-
assert_equal 'Created', page.live_version.version_comment
|
|
212
|
-
assert_equal 3, page.reload.draft.version
|
|
213
|
-
|
|
214
|
-
page.create_connector(Factory(:html_block, :name => "Whatever"), "main")
|
|
215
|
-
assert_equal 4, page.reload.draft.version
|
|
216
|
-
|
|
217
|
-
page.move_connector_down(page.connectors.for_page_version(page.reload.draft.version).for_connectable(block).first)
|
|
218
|
-
assert_equal "Html Block 'Hello, World!' was moved down within the 'main' container",
|
|
219
|
-
page.draft.version_comment
|
|
220
|
-
assert_equal 'Created', page.live_version.version_comment
|
|
221
|
-
|
|
222
|
-
page.move_connector_up(page.connectors.for_page_version(page.reload.draft.version).for_connectable(block).first)
|
|
223
|
-
assert_equal "Html Block 'Hello, World!' was moved up within the 'main' container",
|
|
224
|
-
page.draft.version_comment
|
|
225
|
-
assert_equal 'Created', page.live_version.version_comment
|
|
226
|
-
|
|
227
|
-
page.remove_connector(page.connectors.for_page_version(page.reload.draft.version).for_connectable(block).first)
|
|
228
|
-
assert_equal "Html Block 'Hello, World!' was removed from the 'main' container",
|
|
229
|
-
page.draft.version_comment
|
|
230
|
-
assert_equal 'Created', page.live_version.version_comment
|
|
231
|
-
|
|
232
|
-
page.revert_to(1)
|
|
233
|
-
assert_equal "Reverted to version 1",
|
|
234
|
-
page.reload.draft.version_comment
|
|
235
|
-
assert_equal 'Created', page.live_version.version_comment
|
|
236
|
-
|
|
237
|
-
assert_equal "Created", page.as_of_version(1).current_version.version_comment
|
|
238
|
-
assert_equal "Changed name", page.as_of_version(2).current_version.version_comment
|
|
239
|
-
assert_equal "Reverted to version 1", page.draft.version_comment
|
|
240
|
-
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
def test_container_live
|
|
244
|
-
page = Factory(:page)
|
|
245
|
-
published = Factory(:html_block, :publish_on_save => true)
|
|
246
|
-
unpublished = Factory(:html_block)
|
|
247
|
-
page.create_connector(published, "main")
|
|
248
|
-
page.create_connector(unpublished, "main")
|
|
249
|
-
assert !page.container_published?("main")
|
|
250
|
-
assert unpublished.publish
|
|
251
|
-
assert page.container_published?("main")
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
def test_move_page_to_another_section
|
|
255
|
-
page = Factory(:public_page)
|
|
256
|
-
new_section = Factory(:public_section)
|
|
257
|
-
|
|
258
|
-
assert_not_equal new_section, page.section
|
|
259
|
-
page.section = new_section
|
|
260
|
-
assert page.save
|
|
261
|
-
assert_equal new_section, page.section
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
def test_deleting_page
|
|
265
|
-
page = Factory(:page)
|
|
266
|
-
page_count = Cms::Page.count_with_deleted
|
|
267
|
-
|
|
268
|
-
page_version_count = page.versions.count
|
|
269
|
-
assert !page.deleted?
|
|
270
|
-
|
|
271
|
-
page.destroy
|
|
272
|
-
|
|
273
|
-
assert_equal page_count, Cms::Page.count_with_deleted
|
|
274
|
-
assert_incremented page_version_count, page.versions.count
|
|
275
|
-
assert page.deleted?
|
|
276
|
-
assert_raise ActiveRecord::RecordNotFound do
|
|
277
|
-
Cms::Page.find(page.id)
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
def test_adding_a_block_to_a_page_puts_page_in_draft_mode
|
|
283
|
-
@page = Factory(:page, :section => root_section, :publish_on_save => true)
|
|
284
|
-
@block = Factory(:html_block, :publish_on_save => true)
|
|
285
|
-
reset(:page, :block)
|
|
286
|
-
assert @page.published?
|
|
287
|
-
assert @block.published?
|
|
288
|
-
@page.create_connector(@block, "main")
|
|
289
|
-
reset(:page, :block)
|
|
290
|
-
assert !@page.live?
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
def test_reverting_and_then_publishing_a_page
|
|
294
|
-
@page = Factory(:page, :section => root_section, :publish_on_save => true)
|
|
295
|
-
|
|
296
|
-
@block = Factory(:html_block,
|
|
297
|
-
:connect_to_page_id => @page.id,
|
|
298
|
-
:connect_to_container => "main")
|
|
299
|
-
@page.publish
|
|
300
|
-
|
|
301
|
-
reset(:page, :block)
|
|
302
|
-
|
|
303
|
-
assert_equal 2, @page.version
|
|
304
|
-
assert_equal 1, @page.connectors.for_page_version(@page.version).count
|
|
305
|
-
|
|
306
|
-
@block.update_attributes(:content => "Something else")
|
|
307
|
-
@page.publish!
|
|
308
|
-
reset(:page, :block)
|
|
309
|
-
|
|
310
|
-
assert_equal 1, @page.connectors.for_page_version(@page.version).count
|
|
311
|
-
assert_equal 2, @block.version
|
|
312
|
-
assert_equal 3, @page.version
|
|
313
|
-
assert @block.live?
|
|
314
|
-
assert @page.live?
|
|
315
|
-
|
|
316
|
-
@page.revert_to(2)
|
|
317
|
-
reset(:page, :block)
|
|
318
|
-
|
|
319
|
-
assert_equal 3, @page.version
|
|
320
|
-
assert_equal 4, @page.draft.version
|
|
321
|
-
assert_equal 2, @block.version
|
|
322
|
-
assert_equal 3, @block.draft.version
|
|
323
|
-
assert_equal 1, @page.connectors.for_page_version(@page.version).count
|
|
324
|
-
assert_equal 1, @page.connectors.for_page_version(@page.draft.version).count
|
|
325
|
-
assert !@page.live?
|
|
326
|
-
assert !@block.live?
|
|
327
|
-
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
end
|
|
331
|
-
|
|
332
|
-
class UserStampingTest < ActiveSupport::TestCase
|
|
333
|
-
|
|
334
|
-
def setup
|
|
335
|
-
@first_guy = Factory(:user, :login => "first_guy")
|
|
336
|
-
@next_guy = Factory(:user, :login => "next_guy")
|
|
337
|
-
Cms::User.current = @first_guy
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
def teardown
|
|
341
|
-
Cms::User.current = nil
|
|
342
|
-
end
|
|
343
|
-
|
|
344
|
-
def test_user_stamps_are_applied_to_versions
|
|
345
|
-
page = Factory(:page, :name => "Original Value")
|
|
346
|
-
|
|
347
|
-
assert_equal page, page.draft.page
|
|
348
|
-
assert_equal @first_guy, page.updated_by
|
|
349
|
-
|
|
350
|
-
Cms::User.current = @new_guy
|
|
351
|
-
|
|
352
|
-
page.update_attributes(:name => "Something Different")
|
|
353
|
-
|
|
354
|
-
assert_equal "Something Different", page.draft.name
|
|
355
|
-
assert_equal "Original Value", page.reload.name
|
|
356
|
-
assert_equal "Original Value", page.versions.first.name
|
|
357
|
-
assert_equal @first_guy, page.versions.first.updated_by
|
|
358
|
-
assert_equal @new_guy, page.versions.last.updated_by
|
|
359
|
-
assert_equal 2, page.versions.count
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
end
|
|
363
|
-
|
|
364
|
-
class PageInSectionTest < ActiveSupport::TestCase
|
|
365
|
-
|
|
366
|
-
def setup
|
|
367
|
-
@root = Factory(:root_section, :name => "First Section")
|
|
368
|
-
@football_section = Factory :public_section, :name => "Football", :parent => @root
|
|
369
|
-
@baseball_section = Factory :public_section, :name => "Baseball", :parent => @root
|
|
370
|
-
|
|
371
|
-
@football_page = Factory :public_page, :section => @football_section
|
|
372
|
-
@baseball_page = Factory :public_page, :section => @baseball_section
|
|
373
|
-
end
|
|
374
|
-
|
|
375
|
-
test "in_section if immediate parent section is included" do
|
|
376
|
-
assert @football_page.in_section?("Football")
|
|
377
|
-
assert !@baseball_page.in_section?("Football")
|
|
378
|
-
end
|
|
379
|
-
|
|
380
|
-
test "in_section if immediate parent's name is included" do
|
|
381
|
-
assert @football_page.in_section?("Football")
|
|
382
|
-
assert !@baseball_page.in_section?("Football")
|
|
383
|
-
end
|
|
384
|
-
|
|
385
|
-
test "in_section if any ancestor is included" do
|
|
386
|
-
assert @football_page.in_section?(@root)
|
|
387
|
-
assert @baseball_page.in_section?(@root)
|
|
388
|
-
assert @football_page.in_section?("First Section")
|
|
389
|
-
assert @baseball_page.in_section?("First Section")
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
test "#top_level_section" do
|
|
393
|
-
assert_equal @football_section, @football_page.top_level_section
|
|
394
|
-
assert_equal @baseball_section, @baseball_page.top_level_section
|
|
395
|
-
|
|
396
|
-
second_level_section = Factory(:public_section, :parent => @football_section)
|
|
397
|
-
second_level_page = Factory(:public_page, :section => second_level_section)
|
|
398
|
-
assert_equal @football_section, second_level_page.top_level_section
|
|
399
|
-
end
|
|
400
|
-
|
|
401
|
-
test "#top_level_section caches result to avoid repeated requests" do
|
|
402
|
-
top = @football_page.top_level_section
|
|
403
|
-
assert_equal top.object_id, @football_page.top_level_section.object_id
|
|
404
|
-
end
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
class PageWithAssociatedBlocksTest < ActiveSupport::TestCase
|
|
408
|
-
def setup
|
|
409
|
-
super
|
|
410
|
-
@page = Factory(:page, :section => root_section, :name => "Bar")
|
|
411
|
-
@block = Factory(:html_block)
|
|
412
|
-
@other_connector = Factory(:connector, :connectable => @block, :connectable_version => @block.version)
|
|
413
|
-
@page_connector = Factory(:connector, :page => @page, :page_version => @page.version, :connectable => @block, :connectable_version => @block.version)
|
|
414
|
-
end
|
|
415
|
-
|
|
416
|
-
# It should create a new page version and a new connector
|
|
417
|
-
def test_updating_the_page_with_changes
|
|
418
|
-
Cms::Page.delete_all
|
|
419
|
-
connector_count = Cms::Connector.count
|
|
420
|
-
|
|
421
|
-
page_version = @page.version
|
|
422
|
-
@page.update_attributes(:name => "Foo")
|
|
423
|
-
|
|
424
|
-
assert_incremented connector_count, Cms::Connector.count
|
|
425
|
-
assert_equal page_version, @page.version
|
|
426
|
-
assert_incremented page_version, @page.draft.version
|
|
427
|
-
end
|
|
428
|
-
|
|
429
|
-
# It should not create a new page version or a new connector
|
|
430
|
-
def test_updating_the_page_without_changes
|
|
431
|
-
connector_count = Cms::Connector.count
|
|
432
|
-
page_version = @page.version
|
|
433
|
-
|
|
434
|
-
@page.update_attributes(:name => @page.name)
|
|
435
|
-
|
|
436
|
-
assert_equal connector_count, Cms::Connector.count
|
|
437
|
-
|
|
438
|
-
assert_equal page_version, @page.version
|
|
439
|
-
end
|
|
440
|
-
|
|
441
|
-
# Verifies that 'after_destroy' callbacks happen on Page/SoftDeleting objects, such that
|
|
442
|
-
# a deleted page is disassociated with any blocks it was connected to.
|
|
443
|
-
test "Destroying a page with a block should remove its connectors from the database completely." do
|
|
444
|
-
|
|
445
|
-
connector_count = Cms::Connector.count
|
|
446
|
-
assert Cms::Connector.exists?(@page_connector.id)
|
|
447
|
-
assert Cms::Connector.exists?(@other_connector.id)
|
|
448
|
-
|
|
449
|
-
@page.destroy
|
|
450
|
-
|
|
451
|
-
assert_decremented connector_count, Cms::Connector.count
|
|
452
|
-
assert !Cms::Connector.exists?(@page_connector.id)
|
|
453
|
-
assert Cms::Connector.exists?(@other_connector.id)
|
|
454
|
-
assert Cms::HtmlBlock.exists?(@block.id)
|
|
455
|
-
assert !@block.deleted?
|
|
456
|
-
end
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
end
|
|
460
|
-
|
|
461
|
-
class AddingBlocksTest < ActiveSupport::TestCase
|
|
462
|
-
|
|
463
|
-
def setup
|
|
464
|
-
@page = Factory(:page)
|
|
465
|
-
@block = Factory(:html_block)
|
|
466
|
-
@original_versions_count = @page.versions.count
|
|
467
|
-
@connector_count = Cms::Connector.count
|
|
468
|
-
|
|
469
|
-
@connector = @page.create_connector(@block, "main")
|
|
470
|
-
reset(:page, :block)
|
|
471
|
-
end
|
|
472
|
-
|
|
473
|
-
test "Adding a block to a page without publishing" do
|
|
474
|
-
assert_equal 1, @page.version, "The unpublished page should still be version 1"
|
|
475
|
-
assert_equal 2, @connector.page_version, "The connector should point to version 2 of the page"
|
|
476
|
-
assert_equal 1, @connector.connectable_version, "Connector should point to version 1 of the block"
|
|
477
|
-
assert_incremented @original_versions_count, @page.versions.count # "There should be a new version of the page"
|
|
478
|
-
assert_equal 1, @page.connectors.for_page_version(@page.draft.version).count
|
|
479
|
-
|
|
480
|
-
assert_equal @connector_count + 1, Cms::Connector.count, "Adding the first block to a page should add exactly one connector"
|
|
481
|
-
end
|
|
482
|
-
|
|
483
|
-
test "Adding additional blocks to a page" do
|
|
484
|
-
block2 = Factory(:html_block)
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
conn = @page.create_connector(block2, "main")
|
|
488
|
-
|
|
489
|
-
assert_equal 1, @page.version
|
|
490
|
-
assert_equal 1, conn.connectable_version
|
|
491
|
-
assert_equal 3, @page.versions.count, "Should be three versions of the page now"
|
|
492
|
-
assert_equal 3, @page.draft.version, "Latest draft of a page should be 3"
|
|
493
|
-
assert_equal 2, @page.connectors.for_page_version(@page.draft.version).count
|
|
494
|
-
assert_equal @connector_count + 3, Cms::Connector.count, "Adding a second block to an existing page should add 3 total connectors."
|
|
495
|
-
end
|
|
496
|
-
|
|
497
|
-
test "Creating a new block to a page should update all existing connectors to the new page version." do
|
|
498
|
-
Rails.logger.warn "Creating a new connector"
|
|
499
|
-
@page.create_connector(Factory(:html_block), "main")
|
|
500
|
-
expected_version = 3
|
|
501
|
-
Rails.logger.warn "Done"
|
|
502
|
-
connectors = @page.connectors.for_page_version(expected_version)
|
|
503
|
-
assert_equal expected_version, connectors[0].page_version, "There should be two connectors with the same version as the page"
|
|
504
|
-
assert_equal expected_version, connectors[1].page_version
|
|
505
|
-
assert_equal 2, connectors.count, "There should be two connectors total for the page for this version (3) of the page."
|
|
506
|
-
|
|
507
|
-
end
|
|
508
|
-
end
|
|
509
|
-
|
|
510
|
-
class AddingBlocksToPageTest < ActiveSupport::TestCase
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
def test_that_it_works
|
|
514
|
-
@page = Factory(:page, :section => root_section)
|
|
515
|
-
@block = Factory(:html_block)
|
|
516
|
-
@block2 = Factory(:html_block)
|
|
517
|
-
@first_conn = @page.create_connector(@block, "testing")
|
|
518
|
-
@second_conn = @page.create_connector(@block2, "testing")
|
|
519
|
-
|
|
520
|
-
page_version_count = @page.versions.count
|
|
521
|
-
connector_count = Cms::Connector.count
|
|
522
|
-
|
|
523
|
-
@conn = @page.create_connector(@block2, "testing")
|
|
524
|
-
|
|
525
|
-
assert_equal 1, @page.reload.version
|
|
526
|
-
assert_equal 4, @conn.page_version
|
|
527
|
-
assert_equal 1, @conn.connectable_version
|
|
528
|
-
assert_incremented page_version_count, @page.versions.count
|
|
529
|
-
assert_equal 3, @page.connectors.for_page_version(@page.draft.version).count
|
|
530
|
-
assert_equal connector_count + 3, Cms::Connector.count
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
# should leave the previous connectors untouched
|
|
534
|
-
@conns = @page.connectors.all(:conditions => ["page_version < 4"], :order => "id")
|
|
535
|
-
|
|
536
|
-
assert_equal 3, @conns.size
|
|
537
|
-
|
|
538
|
-
assert_properties @conns[0], {
|
|
539
|
-
:connectable => @block,
|
|
540
|
-
:page => @page,
|
|
541
|
-
:page_version => 2,
|
|
542
|
-
:connectable_version => 1
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
assert_properties @conns[1], {
|
|
546
|
-
:connectable => @block,
|
|
547
|
-
:page => @page,
|
|
548
|
-
:page_version => 3,
|
|
549
|
-
:connectable_version => 1
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
assert_properties @conns[2], {
|
|
553
|
-
:connectable => @block2,
|
|
554
|
-
:page => @page,
|
|
555
|
-
:page_version => 3,
|
|
556
|
-
:connectable_version => 1
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
@conns = @page.connectors.for_page_version(4).all(:order => "id")
|
|
560
|
-
assert_equal 3, @conns.size
|
|
561
|
-
|
|
562
|
-
assert_properties @conns[0], {
|
|
563
|
-
:connectable => @block,
|
|
564
|
-
:page => @page,
|
|
565
|
-
:page_version => 4,
|
|
566
|
-
:connectable_version => 1
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
assert_properties @conns[1], {
|
|
570
|
-
:connectable => @block2,
|
|
571
|
-
:page => @page,
|
|
572
|
-
:page_version => 4,
|
|
573
|
-
:connectable_version => 1
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
assert_properties @conns[2], {
|
|
577
|
-
:connectable => @block2,
|
|
578
|
-
:page => @page,
|
|
579
|
-
:page_version => 4,
|
|
580
|
-
:connectable_version => 1
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
end
|
|
584
|
-
end
|
|
585
|
-
|
|
586
|
-
class PageWithTwoBlocksTest < ActiveSupport::TestCase
|
|
587
|
-
def setup
|
|
588
|
-
super
|
|
589
|
-
@page = Factory(:page, :section => root_section)
|
|
590
|
-
@foo_block = Factory(:html_block, :name => "Foo Block")
|
|
591
|
-
@bar_block = Factory(:html_block, :name => "Bar Block")
|
|
592
|
-
@page.create_connector(@foo_block, "whatever")
|
|
593
|
-
@page.reload
|
|
594
|
-
@page.create_connector(@bar_block, "whatever")
|
|
595
|
-
@page.reload
|
|
596
|
-
end
|
|
597
|
-
|
|
598
|
-
def test_editing_one_of_the_blocks_creates_a_new_version_of_the_page
|
|
599
|
-
page_version = @page.draft.version
|
|
600
|
-
@foo_block.update_attributes(:name => "Something Else")
|
|
601
|
-
assert_incremented page_version, @page.draft.version
|
|
602
|
-
end
|
|
603
|
-
|
|
604
|
-
# A page that had 2 blocks added to it and then had them removed,
|
|
605
|
-
# when reverting to the previous version,
|
|
606
|
-
# should restore the connectors from the version being reverted to
|
|
607
|
-
def test_removing_and_reverting_to_previous_version
|
|
608
|
-
remove_both_connectors!
|
|
609
|
-
|
|
610
|
-
connector_count = Cms::Connector.count
|
|
611
|
-
|
|
612
|
-
@page.revert
|
|
613
|
-
|
|
614
|
-
assert_incremented connector_count, Cms::Connector.count
|
|
615
|
-
assert_properties @page.reload.connectors.for_page_version(@page.draft.version).first, {
|
|
616
|
-
:page => @page,
|
|
617
|
-
:page_version => 6,
|
|
618
|
-
:connectable => @bar_block,
|
|
619
|
-
:connectable_version => 1,
|
|
620
|
-
:container => "whatever"}
|
|
621
|
-
end
|
|
622
|
-
|
|
623
|
-
# A page that had 2 blocks added to it and then had then removed,
|
|
624
|
-
# when reverting to the version that had both connectors,
|
|
625
|
-
# should restore the connectors that version
|
|
626
|
-
def test_removing_and_reverting_to_version_with_both_connectors
|
|
627
|
-
remove_both_connectors!
|
|
628
|
-
|
|
629
|
-
connector_count = Cms::Connector.count
|
|
630
|
-
|
|
631
|
-
@page.revert_to(3)
|
|
632
|
-
|
|
633
|
-
assert_equal connector_count + 2, Cms::Connector.count
|
|
634
|
-
|
|
635
|
-
foo, bar = @page.reload.connectors.for_page_version(@page.draft.version).find(:all, :order => "#{Cms::Connector.table_name}.position")
|
|
636
|
-
|
|
637
|
-
assert_properties foo, {
|
|
638
|
-
:page => @page,
|
|
639
|
-
:page_version => 6,
|
|
640
|
-
:connectable => @foo_block,
|
|
641
|
-
:connectable_version => 1,
|
|
642
|
-
:container => "whatever"}
|
|
643
|
-
assert_properties bar, {
|
|
644
|
-
:page => @page,
|
|
645
|
-
:page_version => 6,
|
|
646
|
-
:connectable => @bar_block,
|
|
647
|
-
:connectable_version => 1,
|
|
648
|
-
:container => "whatever"}
|
|
649
|
-
|
|
650
|
-
end
|
|
651
|
-
|
|
652
|
-
def test_updating_one_of_the_blocks_and_reverting_to_version_before_the_update
|
|
653
|
-
target_version = @page.draft.version
|
|
654
|
-
@foo_block.update_attributes!(:name => "Foo V2")
|
|
655
|
-
@page.reload
|
|
656
|
-
|
|
657
|
-
page_version = @page.draft.version
|
|
658
|
-
foo_block_version = @foo_block.draft.version
|
|
659
|
-
|
|
660
|
-
@page.revert_to(target_version)
|
|
661
|
-
|
|
662
|
-
assert_incremented page_version, @page.draft.version
|
|
663
|
-
assert_incremented foo_block_version, @foo_block.draft.version
|
|
664
|
-
assert_equal "Foo Block", @page.connectors.for_page_version(@page.draft.version).reload.first.connectable.name
|
|
665
|
-
end
|
|
666
|
-
|
|
667
|
-
protected
|
|
668
|
-
def remove_both_connectors!
|
|
669
|
-
@page.remove_connector(@page.connectors.for_page_version(@page.draft.version).first(:order => "#{Cms::Connector.table_name}.position"))
|
|
670
|
-
@page.remove_connector(@page.connectors.for_page_version(@page.draft.version).first(:order => "#{Cms::Connector.table_name}.position"))
|
|
671
|
-
end
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
end
|
|
675
|
-
|
|
676
|
-
class PageWithBlockTest < ActiveSupport::TestCase
|
|
677
|
-
def setup
|
|
678
|
-
@page = Factory(:page, :section => root_section)
|
|
679
|
-
@block = Factory(:html_block)
|
|
680
|
-
@conn = @page.create_connector(@block, "bar")
|
|
681
|
-
@page.publish!
|
|
682
|
-
@conn = @page.connectors.for_page_version(@page.version).for_connectable(@block).first
|
|
683
|
-
end
|
|
684
|
-
|
|
685
|
-
def test_removing_connector
|
|
686
|
-
page_version = @page.draft.version
|
|
687
|
-
page_version_count = Cms::Page::Version.count
|
|
688
|
-
assert @page.published?
|
|
689
|
-
|
|
690
|
-
@page.remove_connector(@conn)
|
|
691
|
-
|
|
692
|
-
assert_incremented page_version_count, Cms::Page::Version.count
|
|
693
|
-
|
|
694
|
-
assert_incremented page_version, @page.draft.version
|
|
695
|
-
|
|
696
|
-
conns = @page.connectors.for_page_version(@page.draft.version-1).all
|
|
697
|
-
assert_equal 1, conns.size
|
|
698
|
-
|
|
699
|
-
assert_properties conns.first, {
|
|
700
|
-
:page => @page,
|
|
701
|
-
:page_version => page_version,
|
|
702
|
-
:connectable => @block,
|
|
703
|
-
:connectable_version => @block.version
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
assert @page.reload.connectors.for_page_version(@page.draft.version).empty?
|
|
707
|
-
assert !@page.live?
|
|
708
|
-
end
|
|
709
|
-
|
|
710
|
-
def test_removing_multiple_connectors
|
|
711
|
-
@block2 = Factory(:html_block)
|
|
712
|
-
@conn2 = @page.create_connector(@block2, "bar")
|
|
713
|
-
@conn3 = @page.create_connector(@block2, "foo")
|
|
714
|
-
#Need to get the new connector that matches @conn2, otherwise you will delete an older version, not the latest connector
|
|
715
|
-
@conn2 = Cms::Connector.first(:conditions => {:page_id => @page.reload.id, :page_version => @page.draft.version, :connectable_id => @block2.id, :connectable_version => @block2.version, :container => "bar"})
|
|
716
|
-
@page.remove_connector(@conn2)
|
|
717
|
-
|
|
718
|
-
page_version_count = Cms::Page::Version.count
|
|
719
|
-
page_version = @page.draft.version
|
|
720
|
-
page_connector_count = @page.connectors.for_page_version(@page.draft.version).count
|
|
721
|
-
|
|
722
|
-
@conn = Cms::Connector.first(:conditions => {:page_id => @page.reload.id, :page_version => @page.draft.version, :connectable_id => @block2.id, :connectable_version => @block2.version, :container => "foo"})
|
|
723
|
-
@page.remove_connector(@conn)
|
|
724
|
-
@page.reload
|
|
725
|
-
|
|
726
|
-
assert_incremented page_version_count, Cms::Page::Version.count
|
|
727
|
-
assert_incremented page_version, @page.draft.version
|
|
728
|
-
assert_decremented page_connector_count, @page.connectors.for_page_version(@page.draft.version).count
|
|
729
|
-
|
|
730
|
-
conns = Cms::Connector.where("page_id = ?", @page.id).order("id")
|
|
731
|
-
|
|
732
|
-
assert_equal 9, conns.size
|
|
733
|
-
|
|
734
|
-
assert_properties conns[0], {:page => @page, :page_version => 2, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
|
735
|
-
assert_properties conns[1], {:page => @page, :page_version => 3, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
|
736
|
-
assert_properties conns[2], {:page => @page, :page_version => 3, :connectable => @block2, :connectable_version => 1, :container => "bar", :position => 2}
|
|
737
|
-
assert_properties conns[3], {:page => @page, :page_version => 4, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
|
738
|
-
assert_properties conns[4], {:page => @page, :page_version => 4, :connectable => @block2, :connectable_version => 1, :container => "bar", :position => 2}
|
|
739
|
-
assert_properties conns[5], {:page => @page, :page_version => 4, :connectable => @block2, :connectable_version => 1, :container => "foo", :position => 1}
|
|
740
|
-
assert_properties conns[6], {:page => @page, :page_version => 5, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
|
741
|
-
assert_properties conns[7], {:page => @page, :page_version => 5, :connectable => @block2, :connectable_version => 1, :container => "foo", :position => 1}
|
|
742
|
-
assert_properties conns[8], {:page => @page, :page_version => 6, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
|
743
|
-
end
|
|
744
|
-
|
|
745
|
-
end
|
|
746
|
-
|
|
747
|
-
class UnpublishedPageWithOnePublishedAndOneUnpublishedBlockTest < ActiveSupport::TestCase
|
|
748
|
-
def setup
|
|
749
|
-
@page = Factory(:page, :section => root_section)
|
|
750
|
-
@published_block = Factory(:html_block, :name => "Published")
|
|
751
|
-
@unpublished_block = Factory(:html_block, :name => "Unpublished")
|
|
752
|
-
@page.create_connector(@published_block, "main")
|
|
753
|
-
@page.create_connector(@unpublished_block, "main")
|
|
754
|
-
@published_block.publish!
|
|
755
|
-
@page.reload
|
|
756
|
-
end
|
|
757
|
-
|
|
758
|
-
def test_publishing_the_block
|
|
759
|
-
@unpublished_block.publish!
|
|
760
|
-
assert @unpublished_block.reload.published?
|
|
761
|
-
@page.reload
|
|
762
|
-
assert !@page.live?
|
|
763
|
-
end
|
|
764
|
-
|
|
765
|
-
def test_publishing_the_page
|
|
766
|
-
page_version_count = Cms::Page::Version.count
|
|
767
|
-
unpublished_block_version_count = @unpublished_block.versions.count
|
|
768
|
-
published_block_version_count = @published_block.versions.count
|
|
769
|
-
|
|
770
|
-
@page.publish!
|
|
771
|
-
|
|
772
|
-
assert_equal page_version_count, Cms::Page::Version.count
|
|
773
|
-
assert_equal unpublished_block_version_count, @unpublished_block.versions.count
|
|
774
|
-
assert_equal published_block_version_count, @published_block.versions.count
|
|
775
|
-
assert @page.live?
|
|
776
|
-
assert @unpublished_block.reload.live?
|
|
777
|
-
assert @published_block.reload.live?
|
|
778
|
-
end
|
|
779
|
-
|
|
780
|
-
end
|
|
781
|
-
|
|
782
|
-
class RevertingABlockThatIsOnMultiplePagesTest < ActiveSupport::TestCase
|
|
783
|
-
def test_that_it_reverts_both_pages
|
|
784
|
-
Cms::Page.delete_all
|
|
785
|
-
|
|
786
|
-
# 1. Create a new page (Page 1, v1)
|
|
787
|
-
@page1 = Factory(:page, :name => "Page 1")
|
|
788
|
-
assert_equal 1, @page1.version
|
|
789
|
-
|
|
790
|
-
# 2. Create a new page (Page 2, v1)
|
|
791
|
-
@page2 = Factory(:page, :name => "Page 2")
|
|
792
|
-
|
|
793
|
-
# 3. Add a new html block to Page 1. Save, don't publish. (Page 1, v2)
|
|
794
|
-
@block = Factory(:html_block, :name => "Block v1",
|
|
795
|
-
:connect_to_page_id => @page1.id, :connect_to_container => "main")
|
|
796
|
-
reset(:page1, :page2, :block)
|
|
797
|
-
assert_equal 2, @page1.draft.version
|
|
798
|
-
assert_equal 1, @page2.draft.version
|
|
799
|
-
|
|
800
|
-
# 4. Goto page 2, and select that block. (Page 2, v2)
|
|
801
|
-
@page2.create_connector(@block, "main")
|
|
802
|
-
reset(:page1, :page2, :block)
|
|
803
|
-
assert_equal 2, @page1.draft.version
|
|
804
|
-
assert_equal 2, @page2.draft.version
|
|
805
|
-
|
|
806
|
-
# 5. Edit the block (Page 1, v3, Page 2, v3, Block v2)
|
|
807
|
-
@block.update_attributes!(:name => "Block v2")
|
|
808
|
-
reset(:page1, :page2, :block)
|
|
809
|
-
assert_equal 3, @page1.draft.version
|
|
810
|
-
assert_equal 3, @page2.draft.version
|
|
811
|
-
assert_equal 2, @block.draft.version
|
|
812
|
-
|
|
813
|
-
# 6. Revert page 1 to version 2. (Page 1, v4, Page 2, v4, Block v3)
|
|
814
|
-
@page1.revert_to(2)
|
|
815
|
-
reset(:page1, :page2, :block)
|
|
816
|
-
assert_equal 4, @page1.draft.version
|
|
817
|
-
assert_equal 3, @block.draft.version
|
|
818
|
-
assert_equal 4, @page2.draft.version
|
|
819
|
-
|
|
820
|
-
# Expected: Both page 1 and 2 will display the same version of the block (v1).
|
|
821
|
-
assert_equal "Block v1", @page1.connectors.first.connectable.name
|
|
822
|
-
assert_equal "Block v1", @page2.connectors.first.connectable.name
|
|
823
|
-
|
|
824
|
-
end
|
|
825
|
-
|
|
826
|
-
end
|
|
827
|
-
|
|
828
|
-
class ViewingAPreviousVersionOfAPageTest < ActiveSupport::TestCase
|
|
829
|
-
|
|
830
|
-
def test_that_it_shows_the_correct_version_of_the_blocks_it_is_connected_to
|
|
831
|
-
# 1. Create Page A (v1)
|
|
832
|
-
@page = Factory(:page, :section => root_section)
|
|
833
|
-
|
|
834
|
-
# 2. Add new Html Block A to Page A (Page A v2, Block A v1)
|
|
835
|
-
@block = Factory(:html_block, :name => "Block 1", :connect_to_page_id => @page.id, :connect_to_container => "main")
|
|
836
|
-
reset(:page, :block)
|
|
837
|
-
assert_equal 2, @page.draft.version
|
|
838
|
-
assert_equal 1, @block.draft.version
|
|
839
|
-
|
|
840
|
-
# 3. Publish Page A (Page A v3, Block A v2)
|
|
841
|
-
@page.publish!
|
|
842
|
-
reset(:page, :block)
|
|
843
|
-
assert_equal 2, @page.draft.version
|
|
844
|
-
assert_equal 1, @block.draft.version
|
|
845
|
-
|
|
846
|
-
# 4. Edit Block A (Page A v4, Block A v3)
|
|
847
|
-
@block.update_attributes!(:name => "Block 2")
|
|
848
|
-
reset(:page, :block)
|
|
849
|
-
assert_equal 2, @page.version
|
|
850
|
-
assert_equal 3, @page.draft.version
|
|
851
|
-
assert_equal 2, @block.draft.version
|
|
852
|
-
|
|
853
|
-
# Open Page A in a different browser (as guest)
|
|
854
|
-
@live_page = Cms::Page.find_live_by_path(@page.path)
|
|
855
|
-
assert_equal 2, @live_page.version
|
|
856
|
-
assert_equal "Block 1", @live_page.connectors.for_page_version(@live_page.version).first.connectable.live_version.name
|
|
857
|
-
|
|
858
|
-
end
|
|
859
|
-
end
|
|
860
|
-
|
|
861
|
-
class PortletsDontHaveDraftsTest < ActiveSupport::TestCase
|
|
862
|
-
|
|
863
|
-
def test_connectors_with_portlets_should_correctly_be_copied
|
|
864
|
-
@page = Factory(:page, :section => root_section)
|
|
865
|
-
@portlet = TagCloudPortlet.create(:name => "Portlet", :connect_to_page_id => @page.id, :connect_to_container => "main")
|
|
866
|
-
|
|
867
|
-
# Check some assumptions.
|
|
868
|
-
assert_equal 2, @page.draft.version, "Verifying that adding a portlet correctly increments page version."
|
|
869
|
-
connectors = Cms::Connector.for_connectable(@portlet)
|
|
870
|
-
assert_equal 1, connectors.size, "This portlet should have only 1 connector."
|
|
871
|
-
|
|
872
|
-
# Verifies that an exception is not thrown while removing connectors
|
|
873
|
-
@page.remove_connector(connectors[0])
|
|
874
|
-
|
|
875
|
-
assert_equal 3, @page.draft.version
|
|
876
|
-
assert @page.reload.connectors.for_page_version(@page.draft.version).empty?, "Verify that all connectors for the latest page are removed."
|
|
877
|
-
end
|
|
878
|
-
end
|
|
879
|
-
end
|