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,358 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Cms
|
4
|
-
class UserTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@need_at_least_one_enabled_user = Factory(:user)
|
8
|
-
@user = Factory(:user)
|
9
|
-
end
|
10
|
-
|
11
|
-
should_validate_presence_of :user => [:login, :password, :password_confirmation]
|
12
|
-
should_validate_uniqueness_of :user => [:login]
|
13
|
-
|
14
|
-
def test_authenticate
|
15
|
-
assert_equal @user, Cms::User.authenticate(@user.login, @user.password)
|
16
|
-
assert_nil Cms::User.authenticate(@user.login, 'FAIL')
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_authenticate_expired_user
|
20
|
-
@user.disable!
|
21
|
-
assert_nil Cms::User.authenticate(@user.login, @user.password)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_expiration
|
25
|
-
assert_nil @user.expires_at
|
26
|
-
assert_nil @user.expires_at_formatted
|
27
|
-
assert !@user.expired?
|
28
|
-
|
29
|
-
@user.expires_at = 1.day.from_now
|
30
|
-
assert !@user.expired?
|
31
|
-
|
32
|
-
@user.expires_at = Time.now
|
33
|
-
assert @user.expired?
|
34
|
-
|
35
|
-
@user.expires_at = 1.day.ago
|
36
|
-
assert @user.expired?
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_active
|
40
|
-
assert Cms::User.active.all.include?(@user)
|
41
|
-
|
42
|
-
@user.update_attribute(:expires_at, 1.year.from_now)
|
43
|
-
assert Cms::User.active.all.include?(@user)
|
44
|
-
end
|
45
|
-
|
46
|
-
test "Disable should work regardless of time zone" do
|
47
|
-
Time.zone = "UTC"
|
48
|
-
@user.disable!
|
49
|
-
assert !Cms::User.active.all.include?(@user)
|
50
|
-
|
51
|
-
user2 = Factory(:user)
|
52
|
-
Time.zone = "Eastern Time (US & Canada)"
|
53
|
-
user2.disable!
|
54
|
-
assert !Cms::User.active.all.include?(user2)
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_disable_enable
|
59
|
-
assert_nil @user.expires_at
|
60
|
-
assert !@user.expired?
|
61
|
-
|
62
|
-
assert Cms::User.active.all.include?(@user)
|
63
|
-
|
64
|
-
assert @user.disable!
|
65
|
-
|
66
|
-
assert @user.expires_at <= Time.now.utc
|
67
|
-
assert @user.expired?
|
68
|
-
assert !Cms::User.active.all.include?(@user)
|
69
|
-
|
70
|
-
@user.enable!
|
71
|
-
|
72
|
-
assert_nil @user.expires_at
|
73
|
-
assert !@user.expired?
|
74
|
-
assert Cms::User.active.all.include?(@user)
|
75
|
-
end
|
76
|
-
|
77
|
-
test "email validation" do
|
78
|
-
assert @user.valid?
|
79
|
-
|
80
|
-
valid_emails = ['t@test.com', 'T@test.com', 'test@somewhere.mobi', 'test@somewhere.tv', 'joe_blow@somewhere.co.nz', 'joe_blow@somewhere.com.au', 't@t-t.co']
|
81
|
-
valid_emails.each do |email|
|
82
|
-
@user.email = email
|
83
|
-
assert @user.valid?
|
84
|
-
end
|
85
|
-
|
86
|
-
invalid_emails = ['', '@test.com', '@test', 'test@test', 'test@somewhere', 'test@somewhere.', 'test@somewhere.x', 'test@somewhere..']
|
87
|
-
invalid_emails.each do |email|
|
88
|
-
@user.email = email
|
89
|
-
assert !@user.valid?
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
test "full name or login" do
|
94
|
-
login = 'robbo'
|
95
|
-
fn = 'Bob'
|
96
|
-
ln = 'Smith'
|
97
|
-
u = Factory.build(:user, :login => 'robbo', :first_name => nil, :last_name => nil)
|
98
|
-
assert_equal login, u.full_name_or_login
|
99
|
-
u.first_name = fn
|
100
|
-
assert_equal fn, u.full_name_or_login
|
101
|
-
u.last_name = ln
|
102
|
-
assert_equal fn + ' ' + ln, u.full_name_or_login
|
103
|
-
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
class UserAbleToViewTest < ActiveSupport::TestCase
|
108
|
-
|
109
|
-
test "Registered User able_to_view? with String path" do
|
110
|
-
registered_user = Cms::User.new
|
111
|
-
viewable_section = Cms::Section.new
|
112
|
-
Cms::Section.expects(:find_by_path).with("/members").returns(viewable_section)
|
113
|
-
registered_user.expects(:viewable_sections).returns([viewable_section])
|
114
|
-
|
115
|
-
assert registered_user.able_to_view?("/members")
|
116
|
-
end
|
117
|
-
|
118
|
-
test "User can't view a nil section" do
|
119
|
-
user = Cms::User.new
|
120
|
-
|
121
|
-
Cms::Section.expects(:find_by_path).with("/members").returns(nil)
|
122
|
-
user.expects(:able_to_view_without_paths?).never
|
123
|
-
|
124
|
-
assert_raise ActiveRecord::RecordNotFound do
|
125
|
-
user.able_to_view?("/members")
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
test "Users with cmsaccess?" do
|
131
|
-
@non_admin = Cms::GroupType.create!(:cms_access => true)
|
132
|
-
@group = Factory(:group, :group_type => @non_admin)
|
133
|
-
@public_user = Factory(:user)
|
134
|
-
@public_user.groups<< @group
|
135
|
-
@public_user.save!
|
136
|
-
|
137
|
-
assert(@public_user.cms_access?, "")
|
138
|
-
end
|
139
|
-
|
140
|
-
test "cms_access? determines if a user is considered to have cmsadmin privledges or not." do
|
141
|
-
user = Cms::User.new
|
142
|
-
assert(!user.cms_access?, "")
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
|
149
|
-
class PageEdittingPermissions < ActiveSupport::TestCase
|
150
|
-
def setup
|
151
|
-
@content_editor = Factory(:content_editor) # Create first, so it will have permission to edit root section
|
152
|
-
|
153
|
-
given_a_site_exists
|
154
|
-
@private_section = Factory(:section, :parent => root_section)
|
155
|
-
@private_page = Factory(:public_page, :section => @private_section)
|
156
|
-
@editable_page = Factory(:public_page, :section => root_section)
|
157
|
-
end
|
158
|
-
|
159
|
-
test "#modifiable_sections" do
|
160
|
-
assert @content_editor.modifiable_sections.include?(root_section)
|
161
|
-
refute @content_editor.modifiable_sections.include?(@private_section)
|
162
|
-
end
|
163
|
-
|
164
|
-
test "#able_to_modify?" do
|
165
|
-
assert_equal false, @content_editor.able_to_modify?(@private_page)
|
166
|
-
assert_equal true, @content_editor.able_to_modify?(@editable_page)
|
167
|
-
end
|
168
|
-
|
169
|
-
test "#able_to_edit" do
|
170
|
-
assert_equal false, @content_editor.able_to_edit?(@private_page)
|
171
|
-
assert_equal true, @content_editor.able_to_edit?(@editable_page)
|
172
|
-
end
|
173
|
-
|
174
|
-
test "#able_to_publish?" do
|
175
|
-
assert_equal false, @content_editor.able_to_publish?(@private_page)
|
176
|
-
assert_equal true, @content_editor.able_to_publish?(@editable_page)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
class UserPermissionsTest < ActiveSupport::TestCase
|
181
|
-
def setup
|
182
|
-
@user = Factory(:user)
|
183
|
-
@guest_group = Cms::Group.guest
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_user_permissions
|
187
|
-
@have = Factory(:permission, :name => "do something the group has permission to do")
|
188
|
-
@havenot = Factory(:permission, :name => "do something the group does not have permission to do")
|
189
|
-
@group_a = Factory(:group)
|
190
|
-
@group_b = Factory(:group)
|
191
|
-
|
192
|
-
@group_a.permissions << @have
|
193
|
-
@group_b.permissions << @havenot
|
194
|
-
|
195
|
-
@user.groups << @group_a
|
196
|
-
|
197
|
-
assert @user.able_to?("do something the group has permission to do")
|
198
|
-
assert !@user.able_to?("do something the group does not have permission to do")
|
199
|
-
end
|
200
|
-
|
201
|
-
test "cms user access to nodes" do
|
202
|
-
@group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
|
203
|
-
@user.groups << @group
|
204
|
-
|
205
|
-
@modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
|
206
|
-
@non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
|
207
|
-
|
208
|
-
@group.sections << @modifiable_section
|
209
|
-
|
210
|
-
@modifiable_page = Factory(:page, :section => @modifiable_section)
|
211
|
-
@non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
|
212
|
-
|
213
|
-
@modifiable_link = Factory(:link, :section => @modifiable_section)
|
214
|
-
@non_modifiable_link = Factory(:link, :section => @non_modifiable_section)
|
215
|
-
|
216
|
-
assert @user.able_to_modify?(@modifiable_section)
|
217
|
-
assert !@user.able_to_modify?(@non_modifiable_section)
|
218
|
-
|
219
|
-
assert @user.able_to_modify?(@modifiable_page)
|
220
|
-
assert !@user.able_to_modify?(@non_modifiable_page)
|
221
|
-
|
222
|
-
assert @user.able_to_modify?(@modifiable_link)
|
223
|
-
assert !@user.able_to_modify?(@non_modifiable_link)
|
224
|
-
end
|
225
|
-
|
226
|
-
test "cms user access to connectables" do
|
227
|
-
@group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
|
228
|
-
@user.groups << @group
|
229
|
-
|
230
|
-
@modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
|
231
|
-
@non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
|
232
|
-
|
233
|
-
@group.sections << @modifiable_section
|
234
|
-
|
235
|
-
@modifiable_page = Factory(:page, :section => @modifiable_section)
|
236
|
-
@non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
|
237
|
-
|
238
|
-
@all_modifiable_connectable = stub(
|
239
|
-
:class => stub(:content_block? => true, :connectable? => true),
|
240
|
-
:connected_pages => [@modifiable_page])
|
241
|
-
@some_modifiable_connectable = stub(
|
242
|
-
:class => stub(:content_block? => true, :connectable? => true),
|
243
|
-
:connected_pages => [@modifiable_page, @non_modifiable_page])
|
244
|
-
@none_modifiable_connectable = stub(
|
245
|
-
:class => stub(:content_block? => true, :connectable? => true),
|
246
|
-
:connected_pages => [@non_modifiable_page])
|
247
|
-
|
248
|
-
assert @user.able_to_modify?(@all_modifiable_connectable)
|
249
|
-
assert !@user.able_to_modify?(@some_modifiable_connectable)
|
250
|
-
assert !@user.able_to_modify?(@none_modifiable_connectable)
|
251
|
-
end
|
252
|
-
|
253
|
-
test "cms user access to non-connectable content blocks" do
|
254
|
-
@content_block = stub(:class => stub(:content_block? => true))
|
255
|
-
assert @user.able_to_modify?(@content_block)
|
256
|
-
end
|
257
|
-
|
258
|
-
test "non cms user access to nodes" do
|
259
|
-
@group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "Registered User"))
|
260
|
-
@user.groups << @group
|
261
|
-
|
262
|
-
@modifiable_section = Factory(:section, :parent => root_section, :name => "Modifiable")
|
263
|
-
@group.sections << @modifiable_section
|
264
|
-
@non_modifiable_section = Factory(:section, :parent => root_section, :name => "Not Modifiable")
|
265
|
-
|
266
|
-
@modifiable_page = Factory(:page, :section => @modifiable_section)
|
267
|
-
@non_modifiable_page = Factory(:page, :section => @non_modifiable_section)
|
268
|
-
|
269
|
-
assert !@user.able_to_modify?(@modifiable_section)
|
270
|
-
assert !@user.able_to_modify?(@non_modifiable_section)
|
271
|
-
|
272
|
-
assert @user.able_to_view?(@modifiable_page)
|
273
|
-
assert !@user.able_to_view?(@non_modifiable_page)
|
274
|
-
end
|
275
|
-
|
276
|
-
test "cms user with no permissions should still be able to view pages" do
|
277
|
-
@group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
|
278
|
-
@user.groups << @group
|
279
|
-
|
280
|
-
@page = Factory(:page)
|
281
|
-
assert @user.able_to_view?(@page)
|
282
|
-
end
|
283
|
-
|
284
|
-
test "cms user who can publish content" do
|
285
|
-
@group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
|
286
|
-
@group.permissions << create_or_find_permission_named("publish_content")
|
287
|
-
@user.groups << @group
|
288
|
-
|
289
|
-
node = stub
|
290
|
-
|
291
|
-
@user.stubs(:able_to_modify?).with(node).returns(true)
|
292
|
-
assert !@user.able_to_edit?(node)
|
293
|
-
assert @user.able_to_publish?(node)
|
294
|
-
|
295
|
-
@user.stubs(:able_to_modify?).with(node).returns(false)
|
296
|
-
assert !@user.able_to_edit?(node)
|
297
|
-
assert !@user.able_to_publish?(node)
|
298
|
-
end
|
299
|
-
|
300
|
-
end
|
301
|
-
|
302
|
-
class GuestUserTest < ActiveSupport::TestCase
|
303
|
-
def setup
|
304
|
-
@guest_group = given_there_is_a_guest_group
|
305
|
-
@guest_user = Cms::User.guest
|
306
|
-
@public_page = Factory(:page, :section => root_section)
|
307
|
-
@protected_section = Factory(:section, :parent => root_section)
|
308
|
-
@protected_page = Factory(:page, :section => @protected_section)
|
309
|
-
end
|
310
|
-
|
311
|
-
def test_guest
|
312
|
-
assert @guest_user.guest?
|
313
|
-
assert_equal @guest_group, @guest_user.group
|
314
|
-
assert @guest_user.groups.include?(@guest_group)
|
315
|
-
assert !@guest_user.able_to?("do anything global")
|
316
|
-
assert !@guest_user.able_to_view?(@protected_page)
|
317
|
-
assert !@guest_user.cms_access?
|
318
|
-
end
|
319
|
-
|
320
|
-
test "guest users should be able to see pages in public sections" do
|
321
|
-
root_section.allow_groups = :all
|
322
|
-
assert @guest_user.able_to_view?(@public_page)
|
323
|
-
end
|
324
|
-
|
325
|
-
test "override viewable sections for the guest group" do
|
326
|
-
@guest_user.expects(:viewable_sections).returns([@protected_section])
|
327
|
-
assert_equal Cms::Section, @protected_section.class
|
328
|
-
assert(@protected_section.is_a?(Cms::Section), "")
|
329
|
-
assert @guest_user.able_to_view?(@protected_section)
|
330
|
-
end
|
331
|
-
|
332
|
-
test "GuestUser can't view a nil section" do
|
333
|
-
user = Cms::GuestUser.new
|
334
|
-
|
335
|
-
Cms::Section.expects(:find_by_path).with("/members").returns(nil)
|
336
|
-
|
337
|
-
assert_raise ActiveRecord::RecordNotFound do
|
338
|
-
user.able_to_view?("/members")
|
339
|
-
end
|
340
|
-
|
341
|
-
end
|
342
|
-
|
343
|
-
test "Guest User able_to_view? with String path" do
|
344
|
-
expected_section = Cms::Section.new
|
345
|
-
|
346
|
-
Cms::Section.expects(:find_by_path).with("/members").returns(expected_section)
|
347
|
-
@guest_user.expects(:viewable_sections).returns([expected_section])
|
348
|
-
|
349
|
-
assert @guest_user.able_to_view?("/members")
|
350
|
-
|
351
|
-
end
|
352
|
-
|
353
|
-
test "Group.guest should be created during setup." do
|
354
|
-
assert_not_nil Cms::Group.guest, "Expected to be in the database for tests in this class."
|
355
|
-
end
|
356
|
-
|
357
|
-
end
|
358
|
-
end
|
@@ -1,137 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SchemaStatementsTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def ensure_no_prefix
|
6
|
-
Cms.expects(:table_prefix).returns("").at_least(0)
|
7
|
-
end
|
8
|
-
|
9
|
-
def setup
|
10
|
-
ensure_no_prefix()
|
11
|
-
%w(fake_contents).each do |t|
|
12
|
-
ActiveRecord::Base.connection.drop_content_table(t) rescue nil
|
13
|
-
ActiveRecord::Base.connection.drop_table(t) rescue nil
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
test "Removed ability to explicitly set :version_foreign_key in bcms 3.4. Should silently do nothing" do
|
19
|
-
class ::Cms::ExplictColumnBlock < ActiveRecord::Base
|
20
|
-
acts_as_content_block :versioned=>{:version_foreign_key => :something_id }
|
21
|
-
end
|
22
|
-
connection.drop_content_table :explict_column_blocks rescue nil
|
23
|
-
connection.create_content_table :explict_column_blocks, :prefix=>false do |t| ; end
|
24
|
-
|
25
|
-
assert_column_exists :explict_column_block_versions, :original_record_id
|
26
|
-
assert_column_does_not_exist :explict_column_block_versions, :something_id
|
27
|
-
end
|
28
|
-
|
29
|
-
test "Nonversioned blocks shouldn't create versions table" do
|
30
|
-
ensure_no_prefix()
|
31
|
-
|
32
|
-
class ::Cms::NonVersionedBlock < ActiveRecord::Base
|
33
|
-
acts_as_content_block :versioned=>false
|
34
|
-
end
|
35
|
-
connection.drop_table :non_versioned_blocks rescue nil
|
36
|
-
connection.drop_table :non_versioned_block_versions rescue nil
|
37
|
-
connection.create_content_table :non_versioned_blocks, :prefix=>false, :versioned=>false do |t| ; end
|
38
|
-
|
39
|
-
assert_equal false, ActiveRecord::Base.connection.table_exists?(:non_versioned_block_versions)
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
test "Create default versioned column, even if the record isn't marked versions (handles subclasses)" do
|
44
|
-
class ::Cms::PossiblyVersionedBlock < ActiveRecord::Base
|
45
|
-
end
|
46
|
-
connection.drop_table :possibly_versioned_blocks rescue nil
|
47
|
-
connection.drop_table :possibly_versioned_block_versions rescue nil
|
48
|
-
connection.create_content_table :possibly_versioned_blocks, :prefix=>false do |t| ; end
|
49
|
-
|
50
|
-
assert_column_exists :possibly_versioned_block_versions, :original_record_id
|
51
|
-
end
|
52
|
-
|
53
|
-
test "non-existant models should create default versions table." do
|
54
|
-
ensure_no_prefix()
|
55
|
-
|
56
|
-
connection.drop_table :non_existant_blocks rescue nil
|
57
|
-
connection.drop_table :non_existant_block_versions rescue nil
|
58
|
-
connection.create_content_table :non_existant_blocks, :prefix=>false do |t| ; end
|
59
|
-
|
60
|
-
assert_column_exists :non_existant_block_versions, :original_record_id
|
61
|
-
end
|
62
|
-
|
63
|
-
test "prefixed" do
|
64
|
-
Cms.expects(:table_prefix).returns("abc_")
|
65
|
-
|
66
|
-
result = ""
|
67
|
-
ActiveRecord::Base.connection.instance_eval do
|
68
|
-
result = prefix("stuff")
|
69
|
-
end
|
70
|
-
|
71
|
-
assert_equal "abc_stuff", result
|
72
|
-
end
|
73
|
-
|
74
|
-
test "create_content_table should make two tables" do
|
75
|
-
conn = ActiveRecord::Base.connection
|
76
|
-
conn.create_content_table :fake_contents, :prefix=>false do |t|
|
77
|
-
t.string :name
|
78
|
-
end
|
79
|
-
|
80
|
-
expected_columns = %w(archived created_at created_by_id deleted id lock_version name published updated_at updated_by_id version)
|
81
|
-
expected_columns_v = %w(archived created_at created_by_id deleted id name original_record_id published updated_at updated_by_id version version_comment)
|
82
|
-
assert_equal expected_columns, conn.columns(:fake_contents).map { |c| c.name }.sort
|
83
|
-
assert_equal expected_columns_v, conn.columns(:fake_content_versions).map { |c| c.name }.sort
|
84
|
-
end
|
85
|
-
|
86
|
-
test "add_content_column should add columns to both primary and versions table" do
|
87
|
-
|
88
|
-
connection.create_content_table :fake_contents, :prefix=>false do |t|; end
|
89
|
-
|
90
|
-
connection.add_content_column :fake_contents, :foo, :string
|
91
|
-
|
92
|
-
found_c = connection.columns(:fake_contents).map { |c| c.name }
|
93
|
-
assert found_c.include?("foo")
|
94
|
-
|
95
|
-
found_c = connection.columns(:fake_content_versions).map { |c| c.name }
|
96
|
-
assert found_c.include?("foo")
|
97
|
-
end
|
98
|
-
|
99
|
-
test "create_content_table should automatically add prefix" do
|
100
|
-
Cms.expects(:table_prefix).returns("abc_").at_least_once
|
101
|
-
|
102
|
-
ActiveRecord::Base.connection.instance_eval do
|
103
|
-
drop_table('abc_add_prefix') rescue nil
|
104
|
-
drop_table('abc_add_prefix_versions') rescue nil
|
105
|
-
create_content_table 'add_prefix' do |t| ; end
|
106
|
-
end
|
107
|
-
|
108
|
-
assert_table_was_created('abc_add_prefix')
|
109
|
-
end
|
110
|
-
|
111
|
-
test "Can optionally not create prefixed table" do
|
112
|
-
Cms.expects(:table_prefix).never
|
113
|
-
|
114
|
-
name = 'stuff'
|
115
|
-
ActiveRecord::Base.connection.instance_eval do
|
116
|
-
drop_table("stuff_versions") if table_exists?("stuff_versions")
|
117
|
-
drop_table("stuff") if table_exists?("stuff")
|
118
|
-
create_content_table name, :prefix=>false do |t|
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
assert_table_was_created('stuff')
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
def connection
|
128
|
-
ActiveRecord::Base.connection
|
129
|
-
end
|
130
|
-
|
131
|
-
def assert_table_was_created(table_name)
|
132
|
-
result = connection.execute("show tables like '#{table_name}'")
|
133
|
-
assert_equal 1, result.count, "Ensure the table was crated. (Might fail when running unit tests with drivers other than mysql2)"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
|