browsercms 3.1.4 → 3.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/cms/content_block_controller.rb +2 -2
- data/app/controllers/cms/section_nodes_controller.rb +6 -1
- data/app/controllers/cms/sections_controller.rb +1 -1
- data/app/helpers/cms/application_helper.rb +1 -1
- data/app/helpers/cms/content_block_helper.rb +27 -0
- data/app/helpers/cms/section_nodes_helper.rb +43 -5
- data/app/models/abstract_file_block.rb +16 -1
- data/app/models/attachment.rb +17 -35
- data/app/models/file_block.rb +0 -12
- data/app/models/image_block.rb +0 -12
- data/app/models/link.rb +4 -21
- data/app/models/page.rb +31 -34
- data/app/models/section.rb +82 -44
- data/app/models/section_node.rb +39 -24
- data/app/models/user.rb +5 -0
- data/app/views/cms/blocks/index.html.erb +4 -4
- data/app/views/cms/file_blocks/_form.html.erb +1 -1
- data/app/views/cms/image_blocks/_form.html.erb +1 -1
- data/app/views/cms/section_nodes/_link.html.erb +6 -3
- data/app/views/cms/section_nodes/_node.html.erb +11 -1
- data/app/views/cms/section_nodes/_page.html.erb +13 -7
- data/app/views/cms/section_nodes/_section.html.erb +24 -8
- data/app/views/cms/section_nodes/index.html.erb +28 -16
- data/app/views/layouts/templates/default.html.erb +17 -0
- data/browsercms.gemspec +28 -1413
- data/db/migrate/20120117144039_browsercms315.rb +94 -0
- data/db/migrate/{20081114172307_load_seed_data.rb → 20121114172307_load_seeds.rb} +8 -1
- data/lib/acts_as_list.rb +1 -1
- data/lib/browsercms.rb +2 -0
- data/lib/cms/addressable.rb +83 -0
- data/lib/cms/behaviors/attaching.rb +44 -24
- data/lib/cms/behaviors/connecting.rb +2 -1
- data/lib/cms/behaviors/publishing.rb +12 -3
- data/lib/cms/behaviors/versioning.rb +83 -53
- data/lib/cms/content_rendering_support.rb +3 -3
- data/lib/cms/error_pages.rb +8 -0
- data/lib/cms/init.rb +5 -3
- data/lib/cms/version.rb +1 -1
- data/templates/blank.rb +2 -0
- data/templates/demo.rb +2 -0
- data/templates/module.rb +2 -0
- data/test/custom_assertions.rb +7 -1
- data/test/factories.rb +3 -1
- data/test/factories/sitemap_factories.rb +28 -0
- data/test/fixtures/connectors.yml +97 -0
- data/test/fixtures/content_type_groups.yml +13 -0
- data/test/fixtures/content_types.yml +50 -0
- data/test/fixtures/dynamic_view_versions.yml +26 -0
- data/test/fixtures/dynamic_views.yml +26 -0
- data/test/fixtures/group_permissions.yml +16 -0
- data/test/fixtures/group_sections.yml +31 -0
- data/test/fixtures/group_type_permissions.yml +11 -0
- data/test/fixtures/group_types.yml +25 -0
- data/test/fixtures/groups.yml +25 -0
- data/test/fixtures/html_block_versions.yml +67 -0
- data/test/fixtures/html_blocks.yml +63 -0
- data/test/fixtures/page_versions.yml +265 -0
- data/test/fixtures/pages.yml +85 -0
- data/test/fixtures/permissions.yml +28 -0
- data/test/fixtures/section_nodes.yml +46 -0
- data/test/fixtures/sections.yml +19 -0
- data/test/fixtures/sites.yml +9 -0
- data/test/fixtures/user_group_memberships.yml +11 -0
- data/test/fixtures/users.yml +15 -0
- data/test/functional/cms/content_controller_test.rb +6 -1
- data/test/functional/cms/file_blocks_controller_test.rb +1 -0
- data/test/functional/cms/html_blocks_controller_test.rb +1 -0
- data/test/functional/cms/image_blocks_controller_test.rb +39 -32
- data/test/functional/cms/section_nodes_controller_test.rb +48 -20
- data/test/functional/cms/sections_controller_test.rb +3 -1
- data/test/functional/tests/pretend_controller_test.rb +6 -3
- data/test/integration/cms/ckeditor_test.rb +5 -2
- data/test/integration/sitemap_performance_test.rb +26 -0
- data/test/selenium-core/Blank.html +7 -0
- data/test/selenium-core/InjectedRemoteRunner.html +8 -0
- data/test/selenium-core/RemoteRunner.html +110 -0
- data/test/selenium-core/SeleniumLog.html +109 -0
- data/test/selenium-core/TestPrompt.html +145 -0
- data/test/selenium-core/TestRunner-splash.html +55 -0
- data/test/selenium-core/TestRunner.hta +176 -0
- data/test/selenium-core/TestRunner.html +176 -0
- data/test/selenium-core/domviewer/butmin.gif +0 -0
- data/test/selenium-core/domviewer/butplus.gif +0 -0
- data/test/selenium-core/domviewer/domviewer.css +298 -0
- data/test/selenium-core/domviewer/domviewer.html +16 -0
- data/test/selenium-core/domviewer/selenium-domviewer.js +205 -0
- data/test/selenium-core/icons/all.png +0 -0
- data/test/selenium-core/icons/continue.png +0 -0
- data/test/selenium-core/icons/continue_disabled.png +0 -0
- data/test/selenium-core/icons/pause.png +0 -0
- data/test/selenium-core/icons/pause_disabled.png +0 -0
- data/test/selenium-core/icons/selected.png +0 -0
- data/test/selenium-core/icons/step.png +0 -0
- data/test/selenium-core/icons/step_disabled.png +0 -0
- data/test/selenium-core/iedoc-core.xml +1515 -0
- data/test/selenium-core/iedoc.xml +1469 -0
- data/test/selenium-core/lib/cssQuery/cssQuery-p.js +6 -0
- data/test/selenium-core/lib/cssQuery/src/cssQuery-level2.js +142 -0
- data/test/selenium-core/lib/cssQuery/src/cssQuery-level3.js +150 -0
- data/test/selenium-core/lib/cssQuery/src/cssQuery-standard.js +53 -0
- data/test/selenium-core/lib/cssQuery/src/cssQuery.js +356 -0
- data/test/selenium-core/lib/prototype.js +2006 -0
- data/test/selenium-core/lib/scriptaculous/builder.js +101 -0
- data/test/selenium-core/lib/scriptaculous/controls.js +815 -0
- data/test/selenium-core/lib/scriptaculous/dragdrop.js +915 -0
- data/test/selenium-core/lib/scriptaculous/effects.js +958 -0
- data/test/selenium-core/lib/scriptaculous/scriptaculous.js +47 -0
- data/test/selenium-core/lib/scriptaculous/slider.js +283 -0
- data/test/selenium-core/lib/scriptaculous/unittest.js +383 -0
- data/test/selenium-core/scripts/find_matching_child.js +69 -0
- data/test/selenium-core/scripts/htmlutils.js +894 -0
- data/test/selenium-core/scripts/injection.html +72 -0
- data/test/selenium-core/scripts/js2html.js +70 -0
- data/test/selenium-core/scripts/narcissus-defs.js +175 -0
- data/test/selenium-core/scripts/narcissus-exec.js +1054 -0
- data/test/selenium-core/scripts/narcissus-parse.js +1003 -0
- data/test/selenium-core/scripts/se2html.js +63 -0
- data/test/selenium-core/scripts/selenium-api.js +2409 -0
- data/test/selenium-core/scripts/selenium-browserbot.js +2203 -0
- data/test/selenium-core/scripts/selenium-browserdetect.js +150 -0
- data/test/selenium-core/scripts/selenium-commandhandlers.js +377 -0
- data/test/selenium-core/scripts/selenium-executionloop.js +175 -0
- data/test/selenium-core/scripts/selenium-logging.js +147 -0
- data/test/selenium-core/scripts/selenium-remoterunner.js +571 -0
- data/test/selenium-core/scripts/selenium-testrunner.js +1333 -0
- data/test/selenium-core/scripts/selenium-version.js +5 -0
- data/test/selenium-core/scripts/user-extensions.js +3 -0
- data/test/selenium-core/scripts/user-extensions.js.sample +75 -0
- data/test/selenium-core/scripts/xmlextras.js +153 -0
- data/test/selenium-core/selenium-logo.png +0 -0
- data/test/selenium-core/selenium-test.css +43 -0
- data/test/selenium-core/selenium.css +299 -0
- data/test/selenium-core/xpath/dom.js +428 -0
- data/test/selenium-core/xpath/misc.js +252 -0
- data/test/selenium-core/xpath/xpath.js +2223 -0
- data/test/selenium/_login_as_cmsadmin.rsel +4 -0
- data/test/selenium/dashboard.rsel +5 -0
- data/test/selenium/html_blocks.rsel +4 -0
- data/test/selenium/login/failed_login.rsel +8 -0
- data/test/selenium/login/successful_login.rsel +9 -0
- data/test/selenium/page_templates.rsel +12 -0
- data/test/selenium/pages/edit_properties.rsel +5 -0
- data/test/selenium/site/view_home_page.rsel +4 -0
- data/test/selenium/sitemap/move_page.rsel +9 -0
- data/test/selenium/sitemap/open_section.rsel +6 -0
- data/test/selenium/sitemap/select_page.rsel +12 -0
- data/test/selenium/sitemap/select_section.rsel +17 -0
- data/test/test_helper.rb +30 -12
- data/test/unit/behaviors/attaching_test.rb +4 -6
- data/test/unit/behaviors/connectable_test.rb +29 -0
- data/test/unit/behaviors/publishable_test.rb +40 -9
- data/test/unit/behaviors/versioning_test.rb +36 -0
- data/test/unit/helpers/menu_helper_test.rb +5 -2
- data/test/unit/helpers/page_helper_test.rb +2 -0
- data/test/unit/lib/cms/sitemap_test.rb +206 -0
- data/test/unit/models/attachment_test.rb +51 -31
- data/test/unit/models/file_block_test.rb +74 -55
- data/test/unit/models/link_test.rb +44 -0
- data/test/unit/models/page_test.rb +290 -224
- data/test/unit/models/sections_test.rb +144 -44
- data/test/unit/models/user_test.rb +28 -18
- metadata +581 -350
- data/app/views/cms/section_nodes/_section_node.html.erb +0 -10
- data/test/unit/models/section_node_test.rb +0 -92
@@ -0,0 +1,85 @@
|
|
1
|
+
# auto-generated by rake db:fixtures:dump, DO NOT EDIT BY HAND!
|
2
|
+
page_1:
|
3
|
+
name: Home
|
4
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
5
|
+
updated_by_id: 1
|
6
|
+
title:
|
7
|
+
language:
|
8
|
+
published: true
|
9
|
+
template_file_name: default
|
10
|
+
lock_version: 2
|
11
|
+
id: 1
|
12
|
+
created_by_id: 1
|
13
|
+
version: 3
|
14
|
+
description:
|
15
|
+
archived: false
|
16
|
+
deleted: false
|
17
|
+
path: /
|
18
|
+
keywords:
|
19
|
+
hidden: false
|
20
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
21
|
+
cacheable: true
|
22
|
+
|
23
|
+
page_2:
|
24
|
+
name: Not Found
|
25
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
26
|
+
updated_by_id: 1
|
27
|
+
title:
|
28
|
+
language:
|
29
|
+
published: true
|
30
|
+
template_file_name: default.html.erb
|
31
|
+
lock_version: 2
|
32
|
+
id: 2
|
33
|
+
created_by_id: 1
|
34
|
+
version: 3
|
35
|
+
description:
|
36
|
+
archived: false
|
37
|
+
deleted: false
|
38
|
+
path: /system/not_found
|
39
|
+
keywords:
|
40
|
+
hidden: true
|
41
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
42
|
+
cacheable: true
|
43
|
+
|
44
|
+
page_3:
|
45
|
+
name: Access Denied
|
46
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
47
|
+
updated_by_id: 1
|
48
|
+
title:
|
49
|
+
language:
|
50
|
+
published: true
|
51
|
+
template_file_name: default.html.erb
|
52
|
+
lock_version: 2
|
53
|
+
id: 3
|
54
|
+
created_by_id: 1
|
55
|
+
version: 3
|
56
|
+
description:
|
57
|
+
archived: false
|
58
|
+
deleted: false
|
59
|
+
path: /system/access_denied
|
60
|
+
keywords:
|
61
|
+
hidden: true
|
62
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
63
|
+
cacheable: true
|
64
|
+
|
65
|
+
page_4:
|
66
|
+
name: Server Error
|
67
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
68
|
+
updated_by_id: 1
|
69
|
+
title:
|
70
|
+
language:
|
71
|
+
published: true
|
72
|
+
template_file_name: default.html.erb
|
73
|
+
lock_version: 2
|
74
|
+
id: 4
|
75
|
+
created_by_id: 1
|
76
|
+
version: 3
|
77
|
+
description:
|
78
|
+
archived: false
|
79
|
+
deleted: false
|
80
|
+
path: /system/server_error
|
81
|
+
keywords:
|
82
|
+
hidden: true
|
83
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
84
|
+
cacheable: true
|
85
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# auto-generated by rake db:fixtures:dump, DO NOT EDIT BY HAND!
|
2
|
+
permission_1:
|
3
|
+
name: administrate
|
4
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
5
|
+
id: 1
|
6
|
+
for_module:
|
7
|
+
description: Allows users to administer the CMS, including adding users and groups.
|
8
|
+
full_name: Administrate CMS
|
9
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
10
|
+
|
11
|
+
permission_2:
|
12
|
+
name: edit_content
|
13
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
14
|
+
id: 2
|
15
|
+
for_module:
|
16
|
+
description: Allows users to Add, Edit and Delete both Pages and Blocks. Can Save (but not Publish) and Assign them as well.
|
17
|
+
full_name: Edit Content
|
18
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
19
|
+
|
20
|
+
permission_3:
|
21
|
+
name: publish_content
|
22
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
23
|
+
id: 3
|
24
|
+
for_module:
|
25
|
+
description: Allows users to Save and Publish, Hide and Archive both Pages and Blocks.
|
26
|
+
full_name: Publish Content
|
27
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
28
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# auto-generated by rake db:fixtures:dump, DO NOT EDIT BY HAND!
|
2
|
+
section_node_1:
|
3
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
4
|
+
node_type: Section
|
5
|
+
id: 1
|
6
|
+
ancestry: 1
|
7
|
+
node_id: 2
|
8
|
+
position: 1
|
9
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
10
|
+
|
11
|
+
section_node_2:
|
12
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
13
|
+
node_type: Page
|
14
|
+
ancestry: 1
|
15
|
+
id: 2
|
16
|
+
node_id: 1
|
17
|
+
position: 2
|
18
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
19
|
+
|
20
|
+
section_node_3:
|
21
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
22
|
+
node_type: Page
|
23
|
+
ancestry: 1/2
|
24
|
+
id: 3
|
25
|
+
node_id: 2
|
26
|
+
position: 1
|
27
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
28
|
+
|
29
|
+
section_node_4:
|
30
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
31
|
+
node_type: Page
|
32
|
+
ancestry: 1/2
|
33
|
+
id: 4
|
34
|
+
node_id: 3
|
35
|
+
position: 2
|
36
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
37
|
+
|
38
|
+
section_node_5:
|
39
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
40
|
+
node_type: Page
|
41
|
+
ancestry: 1/2
|
42
|
+
id: 5
|
43
|
+
node_id: 4
|
44
|
+
position: 3
|
45
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
46
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# auto-generated by rake db:fixtures:dump, DO NOT EDIT BY HAND!
|
2
|
+
section_1:
|
3
|
+
name: My Site
|
4
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
5
|
+
id: 1
|
6
|
+
root: true
|
7
|
+
path: /
|
8
|
+
hidden: false
|
9
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
10
|
+
|
11
|
+
section_2:
|
12
|
+
name: system
|
13
|
+
updated_at: Wed Mar 04 22:55:28 UTC 2009
|
14
|
+
id: 2
|
15
|
+
root: false
|
16
|
+
path: /system
|
17
|
+
hidden: true
|
18
|
+
created_at: Wed Mar 04 22:55:28 UTC 2009
|
19
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# auto-generated by rake db:fixtures:dump, DO NOT EDIT BY HAND!
|
2
|
+
user_1:
|
3
|
+
salt: d193b3629a4805ec6a9cabf2d5336aed56ec4533
|
4
|
+
updated_at: Wed Mar 04 22:55:27 UTC 2009
|
5
|
+
expires_at:
|
6
|
+
crypted_password: 763ef0d40c98bff03ab3762e0865c12bd76f4607
|
7
|
+
remember_token_expires_at:
|
8
|
+
id: 1
|
9
|
+
remember_token:
|
10
|
+
first_name: CMS
|
11
|
+
login: cmsadmin
|
12
|
+
last_name: Administrator
|
13
|
+
email: cmsadmin@example.com
|
14
|
+
created_at: Wed Mar 04 22:55:27 UTC 2009
|
15
|
+
|
@@ -3,6 +3,10 @@ require File.join(File.dirname(__FILE__), '/../../test_helper')
|
|
3
3
|
class Cms::ContentControllerTest < ActionController::TestCase
|
4
4
|
include Cms::ControllerTestHelper
|
5
5
|
|
6
|
+
def setup
|
7
|
+
given_a_site_exists
|
8
|
+
end
|
9
|
+
|
6
10
|
def test_show_home_page
|
7
11
|
get :show
|
8
12
|
assert_response :success
|
@@ -19,7 +23,6 @@ class Cms::ContentControllerTest < ActionController::TestCase
|
|
19
23
|
get :show, :path => ["foo"]
|
20
24
|
assert_response :not_found
|
21
25
|
assert_select "title", "Not Found"
|
22
|
-
assert_select "h1", "Page Not Found"
|
23
26
|
end
|
24
27
|
|
25
28
|
def test_page_not_found_to_cms_admin
|
@@ -312,6 +315,8 @@ class Cms::ContentCachingDisabledControllerTest < ActionController::TestCase
|
|
312
315
|
include Cms::ControllerTestHelper
|
313
316
|
|
314
317
|
def setup
|
318
|
+
given_a_site_exists
|
319
|
+
|
315
320
|
ActionController::Base.perform_caching = false
|
316
321
|
@page = Factory(:page, :section => root_section, :name => "Test Page", :path => "/page", :publish_on_save => true)
|
317
322
|
@registered_user = Factory(:user)
|
@@ -4,6 +4,7 @@ class Cms::ImageBlocksControllerTest < ActionController::TestCase
|
|
4
4
|
include Cms::ControllerTestHelper
|
5
5
|
|
6
6
|
def setup
|
7
|
+
given_a_site_exists
|
7
8
|
login_as_cms_admin
|
8
9
|
end
|
9
10
|
|
@@ -12,38 +13,7 @@ class Cms::ImageBlocksControllerTest < ActionController::TestCase
|
|
12
13
|
assert_response :success
|
13
14
|
assert_select "title", "Content Library / Add New Image"
|
14
15
|
end
|
15
|
-
|
16
|
-
def test_edit
|
17
|
-
@image = Factory(:image_block,
|
18
|
-
:attachment_section => root_section,
|
19
|
-
:attachment_file => mock_file,
|
20
|
-
:attachment_file_path => "test.jpg")
|
21
|
-
|
22
|
-
get :edit, :id => @image.id
|
23
|
-
|
24
|
-
assert_response :success
|
25
|
-
assert_equal root_section.id, assigns(:block).attachment_section_id
|
26
|
-
assert_select "title", "Content Library / Edit Image"
|
27
|
-
assert_select "h1", "Edit Image '#{@image.name}'"
|
28
|
-
assert_select "select[name=?]", "image_block[attachment_section_id]" do
|
29
|
-
assert_select "option[value=?][selected=?]", root_section.id, "selected"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_update_image
|
34
|
-
@image = Factory(:image_block,
|
35
|
-
:attachment_section => root_section,
|
36
|
-
:attachment_file => mock_file,
|
37
|
-
:attachment_file_path => "test.jpg")
|
38
|
-
@other_section = Factory(:section, :parent => root_section, :name => "Other")
|
39
|
-
|
40
|
-
put :update, :id => @image.id, :image_block => {:attachment_section_id => @other_section.id}
|
41
|
-
reset(:image)
|
42
16
|
|
43
|
-
assert_redirected_to [:cms, @image]
|
44
|
-
assert_equal @other_section, @image.attachment_section
|
45
|
-
end
|
46
|
-
|
47
17
|
def test_revert_to
|
48
18
|
@image = Factory(:image_block,
|
49
19
|
:attachment_section => root_section,
|
@@ -71,5 +41,42 @@ class Cms::ImageBlocksControllerTest < ActionController::TestCase
|
|
71
41
|
assert_equal "22222", File.read(@image.attachment.full_file_location)
|
72
42
|
assert_equal "11111", File.read(@draft_image.attachment.full_file_location)
|
73
43
|
end
|
74
|
-
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class Cms::MoveImageBlocks < ActionController::TestCase
|
48
|
+
include Cms::ControllerTestHelper
|
49
|
+
tests Cms::ImageBlocksController
|
50
|
+
|
51
|
+
def setup
|
52
|
+
given_a_site_exists
|
53
|
+
login_as_cms_admin
|
54
|
+
|
55
|
+
@image = Factory(:image_block,
|
56
|
+
:attachment_section => root_section,
|
57
|
+
:attachment_file => mock_file,
|
58
|
+
:attachment_file_path => "test.jpg")
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_edit
|
62
|
+
get :edit, :id => @image.id
|
63
|
+
|
64
|
+
assert_response :success
|
65
|
+
assert_equal root_section.id, assigns(:block).attachment_section_id
|
66
|
+
assert_select "title", "Content Library / Edit Image"
|
67
|
+
assert_select "h1", "Edit Image '#{@image.name}'"
|
68
|
+
assert_select "select[name=?]", "image_block[attachment_section_id]" do
|
69
|
+
assert_select "option[value=?][selected=?]", root_section.id, "selected"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_update_image
|
74
|
+
@other_section = Factory(:public_section, :parent => root_section, :name => "Other")
|
75
|
+
|
76
|
+
put :update, :id => @image.id, :image_block => {:attachment_section_id => @other_section.id}
|
77
|
+
reset(:image)
|
78
|
+
|
79
|
+
assert_redirected_to [:cms, @image]
|
80
|
+
assert_equal @other_section, @image.attachment.section
|
81
|
+
end
|
75
82
|
end
|
@@ -2,7 +2,12 @@ require File.join(File.dirname(__FILE__), '/../../test_helper')
|
|
2
2
|
|
3
3
|
class Cms::SectionNodesControllerTest < ActionController::TestCase
|
4
4
|
include Cms::ControllerTestHelper
|
5
|
-
|
5
|
+
|
6
|
+
def setup
|
7
|
+
remove_all_sitemap_fixtures_to_avoid_bugs
|
8
|
+
given_a_site_exists
|
9
|
+
end
|
10
|
+
|
6
11
|
def test_index_as_admin
|
7
12
|
login_as_cms_admin
|
8
13
|
@foo = Factory(:section, :name => "Foo", :parent => root_section)
|
@@ -13,7 +18,7 @@ class Cms::SectionNodesControllerTest < ActionController::TestCase
|
|
13
18
|
assert_select "title", "Sitemap"
|
14
19
|
assert_select "h1", "Sitemap"
|
15
20
|
assert_select "#sitemap" do
|
16
|
-
assert_select "ul#
|
21
|
+
assert_select "ul#root_#{root_section.id}" do
|
17
22
|
assert_select "#section_#{root_section.id}" do
|
18
23
|
assert_select "div", "My Site"
|
19
24
|
end
|
@@ -32,52 +37,75 @@ class Cms::SectionNodesControllerTest < ActionController::TestCase
|
|
32
37
|
assert_select "div", "Test Page"
|
33
38
|
end
|
34
39
|
end
|
35
|
-
end
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
|
-
|
43
|
+
|
39
44
|
end
|
40
45
|
|
41
46
|
class Cms::SectionNodesControllerPermissionsTest < ActionController::TestCase
|
42
47
|
tests Cms::SectionNodesController
|
43
48
|
include Cms::ControllerTestHelper
|
44
|
-
|
49
|
+
|
45
50
|
def setup
|
51
|
+
given_a_site_exists
|
52
|
+
|
53
|
+
@user = Factory(:content_editor)
|
46
54
|
# DRYME copypaste from UserPermissionTest
|
47
|
-
@user = Factory(:user)
|
48
55
|
login_as(@user)
|
49
56
|
@group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
|
50
57
|
@group.permissions << create_or_find_permission_named("edit_content")
|
51
58
|
@group.permissions << create_or_find_permission_named("publish_content")
|
52
59
|
@user.groups << @group
|
53
|
-
|
60
|
+
|
54
61
|
@editable_section = Factory(:section, :parent => root_section, :name => "Editable")
|
55
|
-
@group.sections << @editable_section
|
62
|
+
@group.sections << @editable_section << root_section
|
56
63
|
@editable_page = Factory(:page, :section => @editable_section, :name => "Editable Page")
|
57
64
|
@editable_link = Factory(:link, :section => @editable_section, :name => "Editable Link")
|
58
|
-
|
65
|
+
|
59
66
|
@noneditable_section = Factory(:section, :parent => root_section, :name => "Not Editable")
|
60
67
|
@noneditable_page = Factory(:page, :section => @noneditable_section, :name => "Non-Editable Page")
|
61
68
|
@noneditable_link = Factory(:link, :section => @noneditable_section, :name => "Non-Editable Link")
|
62
|
-
|
69
|
+
|
63
70
|
@noneditables = [@noneditable_section, @noneditable_page, @noneditable_link]
|
64
|
-
@editables = [@editable_section,
|
65
|
-
|
66
|
-
|
71
|
+
@editables = [@editable_section, @editable_page, @editable_link]
|
72
|
+
verify_user_cannot_edit
|
73
|
+
verify_user_can_edit
|
67
74
|
end
|
68
|
-
|
75
|
+
|
69
76
|
def test_index_as_contributor_with_subsections
|
70
77
|
get :index
|
78
|
+
|
71
79
|
assert_response :success
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
80
|
+
|
81
|
+
user_shouldnt_not_be_able_to_edit(@noneditables)
|
82
|
+
user_should_be_able_to_edit(@editables)
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def user_shouldnt_not_be_able_to_edit(sections)
|
88
|
+
sections.each do |ne|
|
76
89
|
assert_select "td.node.non-editable div", ne.name
|
77
90
|
end
|
78
|
-
|
91
|
+
end
|
92
|
+
|
93
|
+
def user_should_be_able_to_edit(user_should_be_able_to_edit)
|
94
|
+
user_should_be_able_to_edit.each do |e|
|
79
95
|
td = css_select("td##{e.class.to_s.underscore}_#{e.id}", e.name).first
|
80
|
-
assert !td.attributes["class"].include?("non-editable")
|
96
|
+
assert !td.attributes["class"].include?("non-editable"), "Looking at #{td}, was editable."
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def verify_user_can_edit
|
101
|
+
@editables.each do |node|
|
102
|
+
assert_equal true, @user.able_to_modify?(node), "Should be able to edit #{node}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def verify_user_cannot_edit
|
107
|
+
@noneditables.each do |node|
|
108
|
+
assert_equal false, @user.able_to_modify?(node), "Shouldnt be able to edit #{node}"
|
81
109
|
end
|
82
110
|
end
|
83
111
|
end
|