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,26 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SitemapPerformanceTest < ActionController::IntegrationTest
|
4
|
-
include Cms::IntegrationTestHelper
|
5
|
-
|
6
|
-
def setup
|
7
|
-
given_a_site_exists
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_homepage
|
11
|
-
r = Benchmark.measure do
|
12
|
-
get '/'
|
13
|
-
end
|
14
|
-
assert r.real < 1, "Should complete in under 1 sec. Was #{r.real}"
|
15
|
-
end
|
16
|
-
|
17
|
-
test "sitemap" do
|
18
|
-
# Make me work someday
|
19
|
-
|
20
|
-
#login_as_cms_admin
|
21
|
-
#
|
22
|
-
#puts Benchmark.measure do
|
23
|
-
# get '/cms/sitemap'
|
24
|
-
#end
|
25
|
-
end
|
26
|
-
end
|
data/test/mock_file.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Cms
|
2
|
-
|
3
|
-
# Simplified handling for creating files for writing tests around multipart uploads.
|
4
|
-
module MockFile
|
5
|
-
FILES_DIR = File.dirname(__FILE__) + '/fixtures/multipart'
|
6
|
-
|
7
|
-
# Creates a file to test uploading to a sample file.
|
8
|
-
def self.new_file(file_name='foo.jpg', content_type="image/jpeg")
|
9
|
-
Rack::Test::UploadedFile.new("#{FILES_DIR}/#{file_name}", content_type, false)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# For activating logging on the console
|
14
|
-
def self.activate_logging
|
15
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module Extensions
|
20
|
-
module Rack
|
21
|
-
module Test
|
22
|
-
# Extensions to make Rack::Test::UploadedFile function like ActionDispatch::Http::UploadedFile during unit/functional tests.
|
23
|
-
module UploadedFile
|
24
|
-
|
25
|
-
# Attachment relies on this being there
|
26
|
-
def tempfile
|
27
|
-
@tempfile
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
Rack::Test::UploadedFile.send(:include, Extensions::Rack::Test::UploadedFile)
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module EngineControllerHacks
|
2
|
-
def get(action, parameters = nil, session = nil, flash = nil)
|
3
|
-
process_action(action, parameters, session, flash, "GET")
|
4
|
-
end
|
5
|
-
|
6
|
-
# Executes a request simulating POST HTTP method and set/volley the response
|
7
|
-
def post(action, parameters = nil, session = nil, flash = nil)
|
8
|
-
process_action(action, parameters, session, flash, "POST")
|
9
|
-
end
|
10
|
-
|
11
|
-
# Executes a request simulating PUT HTTP method and set/volley the response
|
12
|
-
def put(action, parameters = nil, session = nil, flash = nil)
|
13
|
-
process_action(action, parameters, session, flash, "PUT")
|
14
|
-
end
|
15
|
-
|
16
|
-
# Executes a request simulating DELETE HTTP method and set/volley the response
|
17
|
-
def delete(action, parameters = nil, session = nil, flash = nil)
|
18
|
-
process_action(action, parameters, session, flash, "DELETE")
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def process_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
|
24
|
-
parameters ||= {}
|
25
|
-
merge = { :use_route => :cms }
|
26
|
-
if parameters[:use_route] == false
|
27
|
-
parameters.delete(:use_route)
|
28
|
-
merge = {}
|
29
|
-
end
|
30
|
-
process(action, parameters.merge!(merge), session, flash, method)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
ActionController::TestCase.send(:include, EngineControllerHacks)
|
@@ -1,57 +0,0 @@
|
|
1
|
-
|
2
|
-
module FactoryHelpers
|
3
|
-
|
4
|
-
def find_or_create_root_section
|
5
|
-
root = Cms::Section.root.first
|
6
|
-
unless root
|
7
|
-
# This constructor matches how seed data is set up.
|
8
|
-
root = Factory(:root_section)
|
9
|
-
end
|
10
|
-
root
|
11
|
-
end
|
12
|
-
|
13
|
-
def root_section
|
14
|
-
find_or_create_root_section
|
15
|
-
end
|
16
|
-
|
17
|
-
def given_there_is_a_sitemap
|
18
|
-
root = find_or_create_root_section
|
19
|
-
root.allow_groups = :all
|
20
|
-
end
|
21
|
-
|
22
|
-
def given_there_is_a_guest_group
|
23
|
-
group_type = Cms::GroupType.guest.first
|
24
|
-
unless group_type
|
25
|
-
group_type = Cms::GroupType.create!(:name => "Guest", :guest => true)
|
26
|
-
end
|
27
|
-
|
28
|
-
guest_group = Cms::Group.guest
|
29
|
-
unless guest_group
|
30
|
-
guest_group = Cms::Group.create!(:name => 'Guest', :code => Cms::Group::GUEST_CODE, :group_type => group_type)
|
31
|
-
end
|
32
|
-
guest_group
|
33
|
-
end
|
34
|
-
alias :given_a_guest_group_exists :given_there_is_a_guest_group
|
35
|
-
|
36
|
-
# Creates a sample uploaded JPG file with binary data.
|
37
|
-
def mock_file(options = {})
|
38
|
-
file_upload_object({:original_filename => "foo.jpg", :content_type => "image/jpeg"}.merge(options))
|
39
|
-
end
|
40
|
-
|
41
|
-
# Creates a TempFile attached to an uploaded file. Used to test attachments
|
42
|
-
def file_upload_object(options)
|
43
|
-
Cms::MockFile.new_file(options[:original_filename], options[:content_type])
|
44
|
-
end
|
45
|
-
|
46
|
-
def given_there_is_a_content_type(model_class)
|
47
|
-
Factory(:content_type, :name => model_class.to_s)
|
48
|
-
end
|
49
|
-
|
50
|
-
def create_admin_user(attrs={})
|
51
|
-
Factory(:cms_admin, {:login => "cmsadmin"}.merge(attrs))
|
52
|
-
end
|
53
|
-
|
54
|
-
def given_there_is_a_cmsadmin
|
55
|
-
create_admin_user
|
56
|
-
end
|
57
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
module Magic
|
2
|
-
module Rails
|
3
|
-
module Engine
|
4
|
-
##
|
5
|
-
# Automatically append all of the current engine's routes to the main
|
6
|
-
# application's route set. This needs to be done for ALL functional tests that
|
7
|
-
# use engine routes, since the mounted routes don't work during tests.
|
8
|
-
#
|
9
|
-
# @param [Symbol] engine_symbol Optional; if provided, uses this symbol to
|
10
|
-
# locate the engine class by name, otherwise uses the module of the calling
|
11
|
-
# test case as the presumed name of the engine.
|
12
|
-
#
|
13
|
-
# @author Jason Hamilton (jhamilton@greatherorift.com)
|
14
|
-
# @author Matthew Ratzloff (matt@urbaninfluence.com)
|
15
|
-
def load_engine_routes(engine_symbol = nil)
|
16
|
-
if engine_symbol
|
17
|
-
engine_name = engine_symbol.to_s.camelize
|
18
|
-
else
|
19
|
-
# No engine provided, so presume the current engine is the one to load
|
20
|
-
engine_name = self.class.name.split("::").first.split("(").last
|
21
|
-
end
|
22
|
-
engine = ("#{engine_name}::Engine").constantize
|
23
|
-
|
24
|
-
# Append the routes for this module to the existing routes
|
25
|
-
::Rails.application.routes.disable_clear_and_finalize = true
|
26
|
-
::Rails.application.routes.clear!
|
27
|
-
::Rails.application.routes_reloader.paths.each { |path| load(path) }
|
28
|
-
::Rails.application.routes.draw do
|
29
|
-
resourced_routes = []
|
30
|
-
|
31
|
-
named_routes = engine.routes.named_routes.routes
|
32
|
-
unnamed_routes = engine.routes.routes - named_routes.values
|
33
|
-
|
34
|
-
engine.routes.routes.each do |route|
|
35
|
-
# Call the method by hand based on the symbol
|
36
|
-
path = "/#{engine_name.underscore}#{route.path}"
|
37
|
-
verb = route.verb.to_s.downcase.to_sym
|
38
|
-
requirements = route.requirements
|
39
|
-
if path_helper = named_routes.key(route)
|
40
|
-
requirements[:as] = path_helper
|
41
|
-
elsif route.requirements[:controller].present?
|
42
|
-
# Presume that all controllers referenced in routes should also be
|
43
|
-
# resources and append that routing on the end so that *_path helpers
|
44
|
-
# will still work
|
45
|
-
resourced_routes << route.requirements[:controller].gsub("#{engine_name.downcase}/", "").to_sym
|
46
|
-
end
|
47
|
-
send(verb, path, requirements) if respond_to?(verb)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Add each route, once, to the end under a scope to trick path helpers.
|
51
|
-
# This will probably break as soon as there is route name overlap, but
|
52
|
-
# we'll cross that bridge when we get to it.
|
53
|
-
resourced_routes.uniq!
|
54
|
-
scope engine_name.downcase do
|
55
|
-
resourced_routes.each do |resource|
|
56
|
-
resources resource
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Finalize the routes
|
62
|
-
::Rails.application.routes.finalize!
|
63
|
-
::Rails.application.routes.disable_clear_and_finalize = false
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
Rails::Engine.send(:include, Magic::Rails::Engine)
|
data/test/test_helper.rb
DELETED
@@ -1,199 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
2
|
-
|
3
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
|
-
require "rails/test_help"
|
5
|
-
|
6
|
-
Rails.backtrace_cleaner.remove_silencers!
|
7
|
-
|
8
|
-
# Load support files
|
9
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
10
|
-
|
11
|
-
require 'action_view/test_case'
|
12
|
-
|
13
|
-
# Allows Generators to be unit tested
|
14
|
-
require "rails/generators/test_case"
|
15
|
-
|
16
|
-
# I'm not sure why ANY of these FactoryGirl requires are necessary at all.
|
17
|
-
require 'factory_girl'
|
18
|
-
require 'factories'
|
19
|
-
|
20
|
-
require 'mock_file'
|
21
|
-
require 'support/factory_helpers'
|
22
|
-
require 'support/engine_controller_hacks'
|
23
|
-
|
24
|
-
class ActiveSupport::TestCase
|
25
|
-
|
26
|
-
include FactoryHelpers
|
27
|
-
|
28
|
-
# Add more helper methods to be used by all tests here...
|
29
|
-
require File.dirname(__FILE__) + '/test_logging'
|
30
|
-
include TestLogging
|
31
|
-
require File.dirname(__FILE__) + '/custom_assertions'
|
32
|
-
include CustomAssertions
|
33
|
-
|
34
|
-
#----- Test Macros -----------------------------------------------------------
|
35
|
-
class << self
|
36
|
-
def should_validate_presence_of(options)
|
37
|
-
factory_name = options.keys.first
|
38
|
-
fields = options[factory_name]
|
39
|
-
fields.each do |f|
|
40
|
-
define_method("test_validates_presence_of_#{f}") do
|
41
|
-
model = Factory.build(factory_name, f => nil)
|
42
|
-
assert !model.valid?
|
43
|
-
assert_has_error_on model, f, "can't be blank"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def should_validate_uniqueness_of(options)
|
49
|
-
class_name = options.keys.first
|
50
|
-
fields = options[class_name]
|
51
|
-
fields.each do |f|
|
52
|
-
define_method("test_validates_uniqueness_of_#{f}") do
|
53
|
-
existing_model = Factory(class_name)
|
54
|
-
model = Factory.build(class_name, f => existing_model.send(f))
|
55
|
-
assert !model.valid?
|
56
|
-
assert_has_error_on model, f, "has already been taken"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.subclasses_from_module(module_name)
|
63
|
-
subclasses = []
|
64
|
-
mod = module_name.constantize
|
65
|
-
if mod.class == Module
|
66
|
-
mod.constants.each do |module_const_name|
|
67
|
-
begin
|
68
|
-
klass_name = "#{module_name}::#{module_const_name}"
|
69
|
-
klass = klass_name.constantize
|
70
|
-
if klass.class == Class
|
71
|
-
subclasses << klass
|
72
|
-
subclasses += klass.send(:descendants).collect { |x| x.respond_to?(:constantize) ? x.constantize : x }
|
73
|
-
else
|
74
|
-
subclasses += subclasses_from_module(klass_name)
|
75
|
-
end
|
76
|
-
rescue NameError
|
77
|
-
raise $!
|
78
|
-
puts $!.inspect
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
return subclasses
|
83
|
-
end
|
84
|
-
|
85
|
-
#----- Fixture/Data related helpers ------------------------------------------
|
86
|
-
|
87
|
-
def admin_user
|
88
|
-
cms_users(:user_1)
|
89
|
-
end
|
90
|
-
|
91
|
-
def create_or_find_permission_named(name)
|
92
|
-
Cms::Permission.named(name).first || Factory(:permission, :name => name)
|
93
|
-
end
|
94
|
-
|
95
|
-
def guest_group
|
96
|
-
Cms::Group.guest || Factory(:group, :code => Group::GUEST_CODE)
|
97
|
-
end
|
98
|
-
|
99
|
-
def login_as(user)
|
100
|
-
@request.session[:user_id] = user ? user.id : nil
|
101
|
-
end
|
102
|
-
|
103
|
-
def login_as_cms_admin
|
104
|
-
given_there_is_a_cmsadmin if Cms::User.count == 0
|
105
|
-
admin = Cms::User.first
|
106
|
-
login_as(admin)
|
107
|
-
admin
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
# Takes a list of the names of instance variables to "reset"
|
112
|
-
# Each instance variable will be set to a new instance
|
113
|
-
# That is found by looking that object by id
|
114
|
-
def reset(*args)
|
115
|
-
args.each do |v|
|
116
|
-
val = instance_variable_get("@#{v}")
|
117
|
-
instance_variable_set("@#{v}", val.class.find(val.id))
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# @3.4.x-merge Remove me once Cucumber coverage is added
|
122
|
-
|
123
|
-
# Fixtures add incorrect Section/Section node data. We don't want to replace fixtures AGAIN (this is handled in CMS 3.3)
|
124
|
-
# so we can just clean it out using this method where needed to avoid test breakage.
|
125
|
-
def remove_all_sitemap_fixtures_to_avoid_bugs
|
126
|
-
#Section.delete_all
|
127
|
-
#SectionNode.delete_all
|
128
|
-
#Page.delete_all
|
129
|
-
end
|
130
|
-
|
131
|
-
# @3.4.x-merge Remove me once Cucumber coverage is added
|
132
|
-
|
133
|
-
# Create a 'faux' sitemap which will work for tests (avoids need for fixtures)
|
134
|
-
def given_a_site_exists
|
135
|
-
@root = root_section
|
136
|
-
@homepage = Factory(:public_page, :name => "Home", :section => @root, :path => "/")
|
137
|
-
@system_section = Factory(:public_section, :name => "System", :parent => @root, :path => "/system")
|
138
|
-
@not_found_page = Factory(:public_page, :name => "Not Found", :section => @system_section, :path => Cms::ErrorPages::NOT_FOUND_PATH)
|
139
|
-
@access_denied_page = Factory(:public_page, :name => "Access Denied", :section => @system_section, :path => Cms::ErrorPages::FORBIDDEN_PATH)
|
140
|
-
@error_page = Factory(:public_page, :name => "Server Error", :section => @system_section, :path => Cms::ErrorPages::SERVER_ERROR_PATH)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
ActionController::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
145
|
-
|
146
|
-
# This might be removable in later versions of Rails 3.1.x which correctly add the routes to functional controllers
|
147
|
-
require 'support/rails_3_1_routes_hack'
|
148
|
-
Cms::Engine.load_engine_routes
|
149
|
-
|
150
|
-
module Cms::ControllerTestHelper
|
151
|
-
def self.included(test_case)
|
152
|
-
test_case.send(:include, Cms::PathHelper)
|
153
|
-
end
|
154
|
-
|
155
|
-
def request
|
156
|
-
@request
|
157
|
-
end
|
158
|
-
|
159
|
-
def streaming_file_contents
|
160
|
-
#The body of a streaming response is a proc
|
161
|
-
streamer = @response.body
|
162
|
-
# assert_equal Proc, streamer.class
|
163
|
-
|
164
|
-
#Create a dummy object for the proc to write to
|
165
|
-
output = Object.new
|
166
|
-
|
167
|
-
def output.write(contents)
|
168
|
-
(@contents ||= "") << contents
|
169
|
-
end
|
170
|
-
|
171
|
-
#run the proc
|
172
|
-
streamer.call(@response, output)
|
173
|
-
|
174
|
-
#return what it wrote to the dummy object
|
175
|
-
output.instance_variable_get("@contents")
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
module Cms::IntegrationTestHelper
|
180
|
-
def login_as(user, password = "password")
|
181
|
-
get login_url
|
182
|
-
assert_response :success
|
183
|
-
post login_url, :login => user.login, :password => password
|
184
|
-
assert_response :redirect
|
185
|
-
assert flash[:notice]
|
186
|
-
end
|
187
|
-
|
188
|
-
def login_as_cms_admin
|
189
|
-
login_as(Cms::User.first, "cmsadmin")
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
def create_testing_table(name)
|
194
|
-
ActiveRecord::Base.connection.instance_eval do
|
195
|
-
drop_table(name) if table_exists?(name)
|
196
|
-
create_table(name)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
data/test/test_logging.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
module TestLogging
|
2
|
-
def log(msg)
|
3
|
-
Rails.logger.info(msg)
|
4
|
-
end
|
5
|
-
|
6
|
-
def log_array(obj, *columns)
|
7
|
-
lengths = columns.map{|m| m.to_s.length }
|
8
|
-
|
9
|
-
obj.each do |r|
|
10
|
-
columns.each_with_index do |m, i|
|
11
|
-
v = r.send(m)
|
12
|
-
if v.to_s.length > lengths[i]
|
13
|
-
lengths[i] = v.to_s.length
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
str = " "
|
19
|
-
columns.each_with_index do |m, i|
|
20
|
-
str << "%#{lengths[i]}s" % m
|
21
|
-
str << " "
|
22
|
-
end
|
23
|
-
str << "\n "
|
24
|
-
|
25
|
-
columns.each_with_index do |m, i|
|
26
|
-
str << ("-"*lengths[i])
|
27
|
-
str << " "
|
28
|
-
end
|
29
|
-
str << "\n "
|
30
|
-
|
31
|
-
obj.each do |r|
|
32
|
-
columns.each_with_index do |m, i|
|
33
|
-
str << "%#{lengths[i]}s" % r.send(m)
|
34
|
-
str << " "
|
35
|
-
end
|
36
|
-
str << "\n "
|
37
|
-
end
|
38
|
-
|
39
|
-
log str
|
40
|
-
end
|
41
|
-
|
42
|
-
def log_table(cls, options={})
|
43
|
-
if options[:include_columns]
|
44
|
-
columns = options[:include_columns]
|
45
|
-
elsif options[:exclude_columns]
|
46
|
-
columns = cls.column_names - options[:exclude_columns].map(&:to_s)
|
47
|
-
else
|
48
|
-
columns = cls.column_names
|
49
|
-
end
|
50
|
-
log_array (cls.uses_soft_delete? ? cls.find_with_deleted(:all) : cls.all), *columns
|
51
|
-
end
|
52
|
-
|
53
|
-
def log_table_with(cls, *columns)
|
54
|
-
log_table(cls, :include_columns => columns)
|
55
|
-
end
|
56
|
-
|
57
|
-
def log_table_without(cls, *columns)
|
58
|
-
log_table(cls, :exclude_columns => columns)
|
59
|
-
end
|
60
|
-
|
61
|
-
def log_table_without_stamps(cls, *columns)
|
62
|
-
log_table(cls, :exclude_columns => %w[created_at updated_at created_by_id updated_by_id] + columns)
|
63
|
-
end
|
64
|
-
|
65
|
-
extend self
|
66
|
-
|
67
|
-
end
|