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,110 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
ActiveRecord::Base.connection.instance_eval do
|
4
|
-
drop_table(:taggable_articles) if table_exists?(:taggable_articles)
|
5
|
-
create_table(:taggable_articles) {|t| t.string :name }
|
6
|
-
|
7
|
-
drop_table(:versioned_taggable_articles) if table_exists?(:versioned_taggable_articles)
|
8
|
-
drop_table(:versioned_taggable_article_versions) if table_exists?(:versioned_taggable_article_versions)
|
9
|
-
create_versioned_table(:versioned_taggable_articles, :prefix=>false) do |t|
|
10
|
-
t.string :name
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class TaggableArticle < ActiveRecord::Base
|
15
|
-
is_taggable
|
16
|
-
end
|
17
|
-
|
18
|
-
class VersionedTaggableArticle < ActiveRecord::Base
|
19
|
-
acts_as_content_block :taggable => true
|
20
|
-
end
|
21
|
-
|
22
|
-
class TaggableBlockTest < ActiveSupport::TestCase
|
23
|
-
def test_tagging
|
24
|
-
article = TaggableArticle.create!(:name => "foo")
|
25
|
-
assert_equal 0, article.taggings.count
|
26
|
-
assert_equal 0, article.tags.count
|
27
|
-
assert_equal 0, Cms::Tag.count
|
28
|
-
assert_equal 0, Cms::Tagging.count
|
29
|
-
|
30
|
-
article.tag_list = "foo bar"
|
31
|
-
assert article.save
|
32
|
-
assert_equal 2, article.taggings.count
|
33
|
-
assert_equal 2, article.tags.count
|
34
|
-
assert_equal 2, Cms::Tag.count
|
35
|
-
assert_equal 2, Cms::Tagging.count
|
36
|
-
|
37
|
-
assert_equal [article], TaggableArticle.tagged_with("foo").all
|
38
|
-
assert_equal [article], TaggableArticle.tagged_with("bar").all
|
39
|
-
assert TaggableArticle.tagged_with("bang").all.empty?
|
40
|
-
|
41
|
-
article.tag_list = "foo bang"
|
42
|
-
assert article.save
|
43
|
-
assert_equal 2, article.taggings.count
|
44
|
-
assert_equal 2, article.tags.count
|
45
|
-
assert_equal 3, Cms::Tag.count
|
46
|
-
assert_equal 2, Cms::Tagging.count
|
47
|
-
|
48
|
-
assert_equal [article], TaggableArticle.tagged_with("foo").all
|
49
|
-
assert_equal [article], TaggableArticle.tagged_with("bang").all
|
50
|
-
assert TaggableArticle.tagged_with("bar").all.empty?
|
51
|
-
|
52
|
-
assert_equal "bang foo", article.tag_list
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_tag_cloud
|
56
|
-
25.times do |n|
|
57
|
-
tag_list = ["article"]
|
58
|
-
tag_list << "first" if n == 0
|
59
|
-
tag_list << "even" if n.even?
|
60
|
-
tag_list << "five" if n % 5 == 0
|
61
|
-
tag_list << "last" if n == 24
|
62
|
-
TaggableArticle.create!(:name => "Article ##{n}", :tag_list => tag_list.join(" ") )
|
63
|
-
end
|
64
|
-
|
65
|
-
tag_counts = Cms::Tag.counts(:limit => 4)
|
66
|
-
assert_equal 4, tag_counts.size
|
67
|
-
assert_equal Cms::Tag.find_by_name("article"), tag_counts[0]
|
68
|
-
assert_equal 25, tag_counts[0].count.to_i
|
69
|
-
assert_equal Cms::Tag.find_by_name("even"), tag_counts[1]
|
70
|
-
assert_equal 13, tag_counts[1].count.to_i
|
71
|
-
assert_equal Cms::Tag.find_by_name("five"), tag_counts[2]
|
72
|
-
assert_equal 5, tag_counts[2].count.to_i
|
73
|
-
assert_equal Cms::Tag.find_by_name("first"), tag_counts[3]
|
74
|
-
assert_equal 1, tag_counts[3].count.to_i
|
75
|
-
|
76
|
-
|
77
|
-
tag_cloud = Cms::Tag.cloud(:sizes => 9)
|
78
|
-
assert_equal 5, tag_cloud.size
|
79
|
-
assert_equal Cms::Tag.find_by_name("article"), tag_cloud[0]
|
80
|
-
assert_equal 6, tag_cloud[0].size
|
81
|
-
assert_equal Cms::Tag.find_by_name("even"), tag_cloud[1]
|
82
|
-
assert_equal 3, tag_cloud[1].size
|
83
|
-
assert_equal Cms::Tag.find_by_name("five"), tag_cloud[2]
|
84
|
-
assert_equal 1, tag_cloud[2].size
|
85
|
-
assert_equal Cms::Tag.find_by_name("first"), tag_cloud[3]
|
86
|
-
assert_equal 0, tag_cloud[3].size
|
87
|
-
assert_equal Cms::Tag.find_by_name("last"), tag_cloud[4]
|
88
|
-
assert_equal 0, tag_cloud[4].size
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
class VersionedTaggableBlockTest < ActiveSupport::TestCase
|
94
|
-
def test_tagging
|
95
|
-
article = VersionedTaggableArticle.create!(:name => "foo")
|
96
|
-
assert_equal 0, article.taggings.count
|
97
|
-
assert_equal 0, article.tags.count
|
98
|
-
assert_equal 0, Cms::Tag.count
|
99
|
-
assert_equal 0, Cms::Tagging.count
|
100
|
-
|
101
|
-
article.tag_list = "foo bar"
|
102
|
-
assert article.save
|
103
|
-
assert_equal 2, article.taggings.count
|
104
|
-
assert_equal 2, article.tags.count
|
105
|
-
assert_equal 2, Cms::Tag.count
|
106
|
-
assert_equal 2, Cms::Tagging.count
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class UserStampingTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def teardown
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
test "if no current user, then timestamp should be nil" do
|
14
|
-
Cms::User.expects(:current).returns(nil).at_least_once
|
15
|
-
block = Cms::HtmlBlock.create!(:name=>"A")
|
16
|
-
|
17
|
-
assert_nil block.created_by
|
18
|
-
assert_nil block.updated_by
|
19
|
-
end
|
20
|
-
|
21
|
-
test "if no current user is false, then timestamp should be nil" do
|
22
|
-
Cms::User.expects(:current).returns(false).twice
|
23
|
-
block = Cms::HtmlBlock.create!(:name=>"A")
|
24
|
-
assert_nil block.created_by
|
25
|
-
assert_nil block.updated_by
|
26
|
-
end
|
27
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Cms
|
4
|
-
class VersioningTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
test "version_foriegn_key is always the same" do
|
7
|
-
assert_equal :original_record_id, Cms::HtmlBlock.version_foreign_key
|
8
|
-
end
|
9
|
-
|
10
|
-
test "Non-versioned columns include 'original_record_id'" do
|
11
|
-
assert_equal true, Cms::HtmlBlock.non_versioned_columns.include?("original_record_id")
|
12
|
-
end
|
13
|
-
|
14
|
-
test "non_versioned_columns should be made into string" do
|
15
|
-
class ::Cms::SpecialBlock < ActiveRecord::Base
|
16
|
-
is_versioned
|
17
|
-
end
|
18
|
-
|
19
|
-
Cms::SpecialBlock.non_versioned_columns.each do |c|
|
20
|
-
assert_equal String, c.class, "Expected #{c} to be a String, but wasn't."
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
test "Saving a new record should create two rows, one in html_blocks, one in html_block_versions" do
|
25
|
-
block = Cms::HtmlBlock.new(:name => "Name is required.")
|
26
|
-
assert_equal true, block.save!
|
27
|
-
assert_equal 1, block.versions.size
|
28
|
-
end
|
29
|
-
|
30
|
-
test "Saving a new Versioned block should allow after_save callbacks to work" do
|
31
|
-
block = Cms::HtmlBlock.new(:name => "Testing")
|
32
|
-
assert block.save
|
33
|
-
assert_equal false, block.skip_callbacks
|
34
|
-
end
|
35
|
-
|
36
|
-
test "Saving a block without changing any attributes should skip after_save callbacks" do
|
37
|
-
block = Cms::HtmlBlock.new(:name => "Testing")
|
38
|
-
block.save
|
39
|
-
|
40
|
-
block.name = "Testing"
|
41
|
-
assert block.save
|
42
|
-
|
43
|
-
assert_equal true, block.skip_callbacks
|
44
|
-
end
|
45
|
-
|
46
|
-
test "Updating a block should increment the version on the new draft" do
|
47
|
-
block = Factory(:html_block)
|
48
|
-
assert_equal 1, block.version
|
49
|
-
block.name = "New Name"
|
50
|
-
assert block.save
|
51
|
-
|
52
|
-
assert_equal 2, block.versions.size
|
53
|
-
assert_equal 1, block.versions[0].version
|
54
|
-
assert_equal 2, block.versions[1].version
|
55
|
-
end
|
56
|
-
|
57
|
-
test "Build new version should create a new version with an incremented version from the primary object" do
|
58
|
-
block = Cms::HtmlBlock.new(:name => "ABC")
|
59
|
-
assert block.save
|
60
|
-
assert_equal 2, block.build_new_version_and_add_to_versions_list_for_saving.version
|
61
|
-
end
|
62
|
-
|
63
|
-
test "Updating an object should perform after_save callbacks" do
|
64
|
-
block = Factory(:html_block)
|
65
|
-
block.name = "New THing"
|
66
|
-
block.expects(:update_connected_pages).returns(true)
|
67
|
-
|
68
|
-
block.save
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
class VersionsTest < ActiveSupport::TestCase
|
73
|
-
|
74
|
-
def setup
|
75
|
-
@published_block = Factory(:html_block, :name => "Version 1", :publish_on_save => true)
|
76
|
-
@published_block.update_attributes(:name => "Version 2")
|
77
|
-
@published_block.reload
|
78
|
-
end
|
79
|
-
|
80
|
-
test "#name matches original version's attributes'" do
|
81
|
-
assert_equal "Version 1", @published_block.name
|
82
|
-
end
|
83
|
-
|
84
|
-
test "#as_of_draft_version" do
|
85
|
-
v2 = @published_block.as_of_draft_version
|
86
|
-
assert_equal "Version 2", v2.name
|
87
|
-
assert_equal HtmlBlock, v2.class
|
88
|
-
end
|
89
|
-
|
90
|
-
test "#draft returns the latest Version Object for a block" do
|
91
|
-
v2 = @published_block.draft
|
92
|
-
assert_equal "Version 2", v2.name
|
93
|
-
assert_equal HtmlBlock::Version, v2.class
|
94
|
-
end
|
95
|
-
|
96
|
-
test "#as_of_version" do
|
97
|
-
v1 = @published_block.as_of_version(1)
|
98
|
-
assert_equal "Version 1", v1.name
|
99
|
-
assert_equal @published_block.id, v1.id
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ActiveRecord::BaseTest < ActiveSupport::TestCase
|
4
|
-
def test_updated_on_string
|
5
|
-
base = Cms::HtmlBlock.new
|
6
|
-
assert_nil base.updated_on_string
|
7
|
-
base.updated_at = Time.zone.parse("1978-07-06")
|
8
|
-
assert_equal "Jul 6, 1978", base.updated_on_string
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# Must use vanilla TestCase to avoid ActiveRecord setup conflicts
|
13
|
-
class TestExtensions < Test::Unit::TestCase
|
14
|
-
|
15
|
-
#"If a connection throws an error when established, then we consider the database to not exist."
|
16
|
-
def test_throws_error
|
17
|
-
ActiveRecord::Base.expects(:connection).raises(StandardError)
|
18
|
-
assert_equal false, ActiveRecord::Base.database_exists?
|
19
|
-
end
|
20
|
-
|
21
|
-
# "If we can establish a connection, the database exists"
|
22
|
-
def test_exists
|
23
|
-
assert_equal true, ActiveRecord::Base.database_exists?
|
24
|
-
end
|
25
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class HashTest < ActiveSupport::TestCase
|
4
|
-
def test_except
|
5
|
-
x = {:a => 1, :b => 2}
|
6
|
-
assert_equal({:b => 2}, x.except(:a))
|
7
|
-
assert_equal({:a => 1, :b => 2}, x)
|
8
|
-
end
|
9
|
-
|
10
|
-
# Test the behavior of out extract_only! method
|
11
|
-
def test_extract_only!
|
12
|
-
x = {:a => 1, :b => 2}
|
13
|
-
y = x.extract_only!(:b, :c)
|
14
|
-
assert_equal({:a => 1}, x)
|
15
|
-
assert_equal({:b => 2}, y)
|
16
|
-
end
|
17
|
-
|
18
|
-
# This exists only to confirm the behavior of extract! (from ActiveSupport) is different then our extract_only!.
|
19
|
-
# If this ever changes, we can remove extract_only!
|
20
|
-
test "ActiveSupport Hash#extract! will add nil keys if they don't exist" do
|
21
|
-
x = {:a => 1, :b => 2}
|
22
|
-
y = x.extract!(:b, :c)
|
23
|
-
assert_equal({:b => 2, :c=>nil}, y, "Even though :c didn't exist in the original hash, ActiveSupport 3.0.0 adds it as a side effect.")
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class IntegerTest < ActiveSupport::TestCase
|
4
|
-
def test_round_bytes
|
5
|
-
assert_equal "99.44 MB", (99.megabytes + 450.kilobytes).round_bytes
|
6
|
-
assert_equal "12.04 KB", (12.kilobytes + 45).round_bytes
|
7
|
-
assert_equal "999 bytes", 999.round_bytes
|
8
|
-
assert_equal "0 bytes", nil.round_bytes
|
9
|
-
end
|
10
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
# Tests the BrowserCMS extentions to the String class
|
4
|
-
class StringTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
test "string should be pluralizes unless there is one" do
|
7
|
-
assert_equal "posts", "post".pluralize_unless_one(0)
|
8
|
-
assert_equal "posts", "post".pluralize_unless_one(2)
|
9
|
-
end
|
10
|
-
|
11
|
-
test "string shouldn't be pluralized if there is one" do
|
12
|
-
assert_equal "post", "post".pluralize_unless_one(1)
|
13
|
-
end
|
14
|
-
end
|
data/test/unit/factories_test.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class FactoriesTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def teardown
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
# Write tests to verify the basic Factories are being used correctly.
|
14
|
-
# Make :task work, such that a valid task is created with assignee/assigner that can edit.
|
15
|
-
# Use in tasks_controller rather than massive setup code.
|
16
|
-
#
|
17
|
-
# Bonus points...
|
18
|
-
# Refactor test_helper to get rid of adhoc setup code.
|
19
|
-
# Split factories into 'sharable' cms factories (that can be used in testing BrowserCMS projects).
|
20
|
-
# as well as 'core' CMS factories (needed only for core)
|
21
|
-
test "content_editor_group" do
|
22
|
-
group = Factory(:content_editor_group)
|
23
|
-
assert_equal Cms::Group, group.class
|
24
|
-
end
|
25
|
-
|
26
|
-
test ":content_editor factory has edit_permission" do
|
27
|
-
editor = Factory(:content_editor)
|
28
|
-
assert editor.able_to?(:edit_content)
|
29
|
-
assert editor.able_to?(:publish_content)
|
30
|
-
end
|
31
|
-
|
32
|
-
test "section" do
|
33
|
-
section = Factory(:section)
|
34
|
-
assert_equal "Test", section.name
|
35
|
-
assert_equal "/test", section.path
|
36
|
-
assert_not_nil section.parent
|
37
|
-
end
|
38
|
-
|
39
|
-
test "cms_admin_user" do
|
40
|
-
user = Factory(:cms_admin)
|
41
|
-
assert_equal 1, user.groups.size
|
42
|
-
assert_equal true, user.able_to?(:edit_content)
|
43
|
-
assert_equal true, user.able_to?(:administrate)
|
44
|
-
assert_equal true, user.able_to?(:publish_content)
|
45
|
-
end
|
46
|
-
|
47
|
-
test ":public_page is also published" do
|
48
|
-
assert_equal true, Factory(:public_page).published?
|
49
|
-
end
|
50
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require 'cms/installation_actions'
|
3
|
-
|
4
|
-
module BcmsWidget
|
5
|
-
end
|
6
|
-
|
7
|
-
class InstallGeneratorTest < ActiveSupport::TestCase
|
8
|
-
|
9
|
-
include Cms::InstallationActions
|
10
|
-
|
11
|
-
test "generate default name" do
|
12
|
-
assert_equal "/bcms_widget", default_engine_path(BcmsWidget)
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Cms::ApplicationHelperTest < ActionView::TestCase
|
4
|
-
|
5
|
-
def test_url_with_mode
|
6
|
-
[
|
7
|
-
[["http://localhost:3000", "edit"], "?mode=edit"],
|
8
|
-
[["http://localhost:3000/", "edit"], "/?mode=edit"],
|
9
|
-
[["http://localhost:3000/foo", "edit"], "/foo?mode=edit"],
|
10
|
-
[["http://localhost:3000/foo?bar=1", "edit"], "/foo?bar=1&mode=edit"],
|
11
|
-
[["http://localhost:3000/foo?mode=view", "edit"], "/foo?mode=edit"],
|
12
|
-
[["http://localhost:3000/foo?bar=1&mode=view", "edit"], "/foo?bar=1&mode=edit"],
|
13
|
-
[["http://localhost:3000/foo?other_mode=1&mode=view", "edit"], "/foo?other_mode=1&mode=edit"],
|
14
|
-
[["/foo?other_mode=1&mode=view", "edit"], "/foo?other_mode=1&mode=edit"]
|
15
|
-
].each do |args, expected|
|
16
|
-
assert_equal expected, url_with_mode(*args)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
test "url_with_mode should handle 'blank' referers as empty" do
|
21
|
-
assert_equal("?mode=edit", url_with_mode("", "edit"))
|
22
|
-
assert_equal("?mode=edit", url_with_mode(nil, "edit"))
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_determine_order
|
26
|
-
assert_equal "foo", determine_order("foo desc", "foo desc")
|
27
|
-
assert_equal "foo", determine_order("foo desc", "foo")
|
28
|
-
assert_equal "foo desc", determine_order("foo", "foo desc")
|
29
|
-
assert_equal "foo desc", determine_order("foo", "foo")
|
30
|
-
assert_equal "bar desc", determine_order("foo", "bar desc")
|
31
|
-
assert_equal "bar", determine_order("foo", "bar")
|
32
|
-
end
|
33
|
-
|
34
|
-
test "Convert jquery selector to dashs" do
|
35
|
-
s = "input.something"
|
36
|
-
assert_equal "input_something", s.gsub(".", "_")
|
37
|
-
|
38
|
-
assert_equal "input_something", send(:to_id, s)
|
39
|
-
assert_equal "input_something_uncheck", send(:to_id, s, "uncheck")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class Cms::ApplicationHelper::DeleteButtonTest < ActionView::TestCase
|
44
|
-
include Cms::ApplicationHelper
|
45
|
-
|
46
|
-
# Scenario: Delete Buttons should:
|
47
|
-
|
48
|
-
test "generate a button without an explicit title by default" do
|
49
|
-
expected_html = '<a href="#" class="button disabled delete_button" id="delete_button"><span><span class="delete_img"> </span>Delete</span></a>'
|
50
|
-
assert_equal expected_html, delete_button
|
51
|
-
end
|
52
|
-
|
53
|
-
test "use a standard Confirm link if :title option is specified" do
|
54
|
-
expected_html = '<a href="#" class="button disabled delete_button http_delete confirm_with_title" id="delete_button"><span><span class="delete_img"> </span>Delete</span></a>'
|
55
|
-
assert_equal expected_html, delete_button(:title=>true)
|
56
|
-
end
|
57
|
-
|
58
|
-
test "take :path attribute if specified" do
|
59
|
-
expected_html = '<a href="/cms/html_blocks/3" class="button disabled delete_button" id="delete_button"><span><span class="delete_img"> </span>Delete</span></a>'
|
60
|
-
assert_equal expected_html, delete_button(:path=>"/cms/html_blocks/3")
|
61
|
-
end
|
62
|
-
|
63
|
-
test "Writes out title if specified as a string" do
|
64
|
-
expected_html = '<a href="#" class="button disabled delete_button http_delete confirm_with_title" id="delete_button" title="Really delete \'Server Error\'?"><span><span class="delete_img"> </span>Delete</span></a>'
|
65
|
-
assert_equal expected_html, delete_button(:title=>"Really delete \'Server Error\'?")
|
66
|
-
end
|
67
|
-
|
68
|
-
test "default to disabled, but have an :enabled option" do
|
69
|
-
expected_html = '<a href="#" class="button disabled delete_button" id="delete_button"><span><span class="delete_img"> </span>Delete</span></a>'
|
70
|
-
assert_equal expected_html, delete_button
|
71
|
-
|
72
|
-
expected_html = '<a href="#" class="button disabled delete_button" id="delete_button"><span><span class="delete_img"> </span>Delete</span></a>'
|
73
|
-
assert_equal expected_html, delete_button(:enabled=>false)
|
74
|
-
|
75
|
-
expected_html = '<a href="#" class="button delete_button" id="delete_button"><span><span class="delete_img"> </span>Delete</span></a>'
|
76
|
-
assert_equal expected_html, delete_button(:enabled=>true)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class Cms::ApplicationHelper::EditButtonTest < ActionView::TestCase
|
81
|
-
include Cms::ApplicationHelper
|
82
|
-
|
83
|
-
# Scenario: Edit Buttons should:
|
84
|
-
|
85
|
-
test "generate a button without an explicit title by default" do
|
86
|
-
expected_html = '<a href="#" class="button disabled" id="edit_button"><span> Edit </span></a>'
|
87
|
-
assert_equal expected_html, edit_button
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
class Cms::ApplicationHelper::AddButtonTest < ActionView::TestCase
|
94
|
-
include Cms::ApplicationHelper
|
95
|
-
|
96
|
-
# Scenario: Add Buttons should:
|
97
|
-
|
98
|
-
test "generate a button without an explicit title by default" do
|
99
|
-
expected_html = '<a href="/cms/page_routes/new" class="button"><span> Add </span></a>'
|
100
|
-
assert_equal expected_html, add_button("/cms/page_routes/new")
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
end
|