browsercms 3.1.4 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/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,12 @@
|
|
|
1
|
+
setup :fixtures => :all
|
|
2
|
+
include_partial 'login_as_cmsadmin'
|
|
3
|
+
open '/cms/page_templates'
|
|
4
|
+
assert_title 'View Page Templates'
|
|
5
|
+
click_and_wait "link=*New Page Template"
|
|
6
|
+
assert_title "New Page Template"
|
|
7
|
+
type "page_template_name", "Test"
|
|
8
|
+
type "page_template_file_name", "test"
|
|
9
|
+
type "page_template_body", "<html><body><%= yield %></body></html>"
|
|
10
|
+
click_and_wait "page_template_submit"
|
|
11
|
+
assert_title "View Page Templates"
|
|
12
|
+
assert_text "//table[@id='blocks']/tbody/tr[3]/td[1]", "Test"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
setup :fixtures => :all
|
|
2
|
+
include_partial 'login_as_cmsadmin'
|
|
3
|
+
open '/cms/sitemap'
|
|
4
|
+
verify_text_not_present "Page 'Home' was moved to 'About'."
|
|
5
|
+
assert_not_visible "//span[@class='page' and text()='About Us']"
|
|
6
|
+
#TODO: Figure out why selenium drag and drop doesn't work
|
|
7
|
+
#drag_and_drop_to_object "//span[@class='page' and text()='Home']", "//span[@class='section' and text()='About']"
|
|
8
|
+
#assert_visible "//span[@class='page' and text()='About Us']"
|
|
9
|
+
#verify_text_present "Page 'Home' was moved to 'About'."
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
setup :fixtures => :all
|
|
2
|
+
include_partial 'login_as_cmsadmin'
|
|
3
|
+
open '/cms/sitemap'
|
|
4
|
+
assert_not_visible "//span[@class='page' and text()='About Us']"
|
|
5
|
+
click "//span[@class='section' and text()='About']/../a"
|
|
6
|
+
assert_visible "//span[@class='page' and text()='About Us']"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
setup :fixtures => :all
|
|
2
|
+
@page = Page.find_by_name('Home')
|
|
3
|
+
include_partial 'login_as_cmsadmin'
|
|
4
|
+
open '/cms/sitemap'
|
|
5
|
+
assert_title 'Sitemap'
|
|
6
|
+
#assert_not_editable 'edit-button'
|
|
7
|
+
#assert_not_editable 'properties-button'
|
|
8
|
+
click "//span[@class='page' and text()='#{@page.name}']"
|
|
9
|
+
#assert_editable 'edit-button'
|
|
10
|
+
#assert_editable 'properties-button'
|
|
11
|
+
assert_attribute "//a[@id='edit-button']", 'href', "/cms/pages/show/#{@page.id}"
|
|
12
|
+
assert_attribute "//a[@id='properties-button']", 'href', "/cms/pages/edit/#{@page.id}"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
setup :fixtures => :all
|
|
2
|
+
@section = Section.find_by_name('About')
|
|
3
|
+
include_partial 'login_as_cmsadmin'
|
|
4
|
+
open '/cms/sitemap'
|
|
5
|
+
assert_title 'Sitemap'
|
|
6
|
+
# assert_not_editable 'edit-button'
|
|
7
|
+
# assert_not_editable 'properties-button'
|
|
8
|
+
# assert_not_editable 'add-page-button'
|
|
9
|
+
# assert_not_editable 'add-section-button'
|
|
10
|
+
click "//span[@class='section' and text()='#{@section.name}']"
|
|
11
|
+
# assert_not_editable 'edit-button'
|
|
12
|
+
# assert_editable 'properties-button'
|
|
13
|
+
# assert_editable 'add-page-button'
|
|
14
|
+
# assert_editable 'add-section-button'
|
|
15
|
+
assert_attribute "//a[@id='properties-button']", 'href', "/cms/sections/edit/#{@section.id}"
|
|
16
|
+
assert_attribute "//a[@id='add-page-button']", 'href', "/cms/pages/new?section_id=#{@section.id}"
|
|
17
|
+
assert_attribute "//a[@id='add-section-button']", 'href', "/cms/sections/new?section_id=#{@section.id}"
|
data/test/test_helper.rb
CHANGED
|
@@ -41,9 +41,9 @@ class ActiveSupport::TestCase
|
|
|
41
41
|
|
|
42
42
|
require File.dirname(__FILE__) + '/test_logging'
|
|
43
43
|
include TestLogging
|
|
44
|
-
require File.dirname(__FILE__) + '/custom_assertions'
|
|
44
|
+
require File.dirname(__FILE__) + '/custom_assertions'
|
|
45
45
|
include CustomAssertions
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
#----- Test Macros -----------------------------------------------------------
|
|
48
48
|
class << self
|
|
49
49
|
def should_validate_presence_of(*fields)
|
|
@@ -69,7 +69,7 @@ class ActiveSupport::TestCase
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
end
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
#----- Fixture/Data related helpers ------------------------------------------
|
|
74
74
|
|
|
75
75
|
def admin_user
|
|
@@ -87,7 +87,7 @@ class ActiveSupport::TestCase
|
|
|
87
87
|
group.permissions << create_or_find_permission_named("edit_content")
|
|
88
88
|
group.permissions << create_or_find_permission_named("publish_content")
|
|
89
89
|
user.groups << group
|
|
90
|
-
user
|
|
90
|
+
user
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def file_upload_object(options)
|
|
@@ -100,7 +100,7 @@ class ActiveSupport::TestCase
|
|
|
100
100
|
|
|
101
101
|
def guest_group
|
|
102
102
|
Group.guest || Factory(:group, :code => Group::GUEST_CODE)
|
|
103
|
-
end
|
|
103
|
+
end
|
|
104
104
|
|
|
105
105
|
def login_as(user)
|
|
106
106
|
@request.session[:user_id] = user ? user.id : nil
|
|
@@ -111,7 +111,7 @@ class ActiveSupport::TestCase
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
def mock_file(options = {})
|
|
114
|
-
file_upload_object({:original_filename => "test.jpg",
|
|
114
|
+
file_upload_object({:original_filename => "test.jpg",
|
|
115
115
|
:content_type => "image/jpeg", :rewind => true,
|
|
116
116
|
:size => "99", :read => "01010010101010101"}.merge(options))
|
|
117
117
|
end
|
|
@@ -127,20 +127,38 @@ class ActiveSupport::TestCase
|
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
def root_section
|
|
130
|
-
|
|
130
|
+
@root_section ||= Factory(:root_section)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Fixtures add incorrect Section/Section node data. We don't want to replace fixtures AGAIN (this is handled in CMS 3.3)
|
|
134
|
+
# so we can just clean it out using this method where needed to avoid test breakage.
|
|
135
|
+
def remove_all_sitemap_fixtures_to_avoid_bugs
|
|
136
|
+
Section.delete_all
|
|
137
|
+
SectionNode.delete_all
|
|
138
|
+
Page.delete_all
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Create a 'faux' sitemap which will work for tests (avoids need for fixtures)
|
|
142
|
+
def given_a_site_exists
|
|
143
|
+
remove_all_sitemap_fixtures_to_avoid_bugs
|
|
144
|
+
@root = root_section
|
|
145
|
+
@homepage = Factory(:public_page, :name=>"Home", :section=>@root, :path=>"/")
|
|
146
|
+
@system_section = Factory(:public_page, :name=>"System", :section=>@root, :path=>"/system")
|
|
147
|
+
@not_found_page = Factory(:public_page, :name=>"Not Found", :section=>@system_section, :path=>Cms::ErrorPages::NOT_FOUND_PATH)
|
|
148
|
+
@access_denied_page = Factory(:public_page, :name=>"Access Denied", :section=>@system_section, :path=>Cms::ErrorPages::FORBIDDEN_PATH)
|
|
149
|
+
@error_page = Factory(:public_page, :name=>"Server Error", :section=>@system_section, :path=>Cms::ErrorPages::SERVER_ERROR_PATH)
|
|
131
150
|
end
|
|
132
|
-
|
|
133
151
|
end
|
|
134
152
|
|
|
135
153
|
module Cms::ControllerTestHelper
|
|
136
154
|
def self.included(test_case)
|
|
137
155
|
test_case.send(:include, Cms::PathHelper)
|
|
138
156
|
end
|
|
139
|
-
|
|
157
|
+
|
|
140
158
|
def request
|
|
141
159
|
@request
|
|
142
160
|
end
|
|
143
|
-
|
|
161
|
+
|
|
144
162
|
def streaming_file_contents
|
|
145
163
|
#The body of a streaming response is a proc
|
|
146
164
|
streamer = @response.body
|
|
@@ -149,11 +167,11 @@ module Cms::ControllerTestHelper
|
|
|
149
167
|
#Create a dummy object for the proc to write to
|
|
150
168
|
output = Object.new
|
|
151
169
|
def output.write(contents)
|
|
152
|
-
(@contents ||= "") << contents
|
|
170
|
+
(@contents ||= "") << contents
|
|
153
171
|
end
|
|
154
172
|
|
|
155
173
|
#run the proc
|
|
156
|
-
streamer.call(@response, output)
|
|
174
|
+
streamer.call(@response, output)
|
|
157
175
|
|
|
158
176
|
#return what it wrote to the dummy object
|
|
159
177
|
output.instance_variable_get("@contents")
|
|
@@ -37,7 +37,7 @@ end
|
|
|
37
37
|
class VersionedAttachable < ActiveRecord::Base
|
|
38
38
|
acts_as_content_block :belongs_to_attachment => true
|
|
39
39
|
|
|
40
|
-
def
|
|
40
|
+
def use_default_attachment_path
|
|
41
41
|
if @attachment_file_path && @attachment_file_path != attachment.file_path
|
|
42
42
|
attachment.file_path = @attachment_file_path
|
|
43
43
|
end
|
|
@@ -52,6 +52,8 @@ end
|
|
|
52
52
|
|
|
53
53
|
class DefaultAttachableTest < ActiveSupport::TestCase
|
|
54
54
|
def setup
|
|
55
|
+
remove_all_sitemap_fixtures_to_avoid_bugs
|
|
56
|
+
|
|
55
57
|
#file is a mock of the object that Rails wraps file uploads in
|
|
56
58
|
@file = file_upload_object(:original_filename => "foo.jpg",
|
|
57
59
|
:content_type => "image/jpeg", :rewind => true,
|
|
@@ -61,12 +63,10 @@ class DefaultAttachableTest < ActiveSupport::TestCase
|
|
|
61
63
|
end
|
|
62
64
|
|
|
63
65
|
def test_create_with_attachment_file
|
|
64
|
-
@attachable = DefaultAttachable.new(:name => "File Name",
|
|
65
|
-
:attachment_file => @file, :publish_on_save => true)
|
|
66
|
+
@attachable = DefaultAttachable.new(:name => "File Name", :attachment_file => @file, :publish_on_save => true)
|
|
66
67
|
|
|
67
68
|
attachable_count = DefaultAttachable.count
|
|
68
69
|
|
|
69
|
-
assert_valid @attachable
|
|
70
70
|
@attachable.save!
|
|
71
71
|
|
|
72
72
|
assert_incremented attachable_count, DefaultAttachable.count
|
|
@@ -107,8 +107,6 @@ class DefaultAttachableTest < ActiveSupport::TestCase
|
|
|
107
107
|
assert_equal "/attachments/foo.jpg", @attachable.attachment_file_path
|
|
108
108
|
assert @attachable.attachment.published?
|
|
109
109
|
end
|
|
110
|
-
|
|
111
|
-
|
|
112
110
|
end
|
|
113
111
|
|
|
114
112
|
class AttachingTest < ActiveSupport::TestCase
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ConnectableTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
given_a_site_exists
|
|
7
|
+
@block = Factory(:html_block)
|
|
8
|
+
@connected_page = Factory(:public_page, :parent=>root_section)
|
|
9
|
+
@connected_page_2 = Factory(:public_page, :parent=>root_section)
|
|
10
|
+
@unconnected_page = Factory(:public_page, :parent=>root_section)
|
|
11
|
+
|
|
12
|
+
@connected_page.create_connector(@block, "main")
|
|
13
|
+
@connected_page_2.create_connector(@block, "main")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def teardown
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "#connected_pages" do
|
|
20
|
+
assert_equal [@connected_page, @connected_page_2], @block.connected_pages
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test "#connected_pages should return same list when called twice" do
|
|
24
|
+
expected = @block.connected_pages
|
|
25
|
+
assert_equal expected.object_id, @block.connected_pages.object_id
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -2,12 +2,18 @@ require File.join(File.dirname(__FILE__), '/../../test_helper')
|
|
|
2
2
|
|
|
3
3
|
ActiveRecord::Base.connection.instance_eval do
|
|
4
4
|
drop_table(:publishables) if table_exists?(:publishables)
|
|
5
|
-
create_table(:publishables) do |t|
|
|
5
|
+
create_table(:publishables) do |t|
|
|
6
6
|
t.string :name
|
|
7
7
|
t.boolean :published, :default => false
|
|
8
8
|
end
|
|
9
9
|
drop_table(:unpublishables) if table_exists?(:unpublishables)
|
|
10
|
-
create_table(:unpublishables) do |t|
|
|
10
|
+
create_table(:unpublishables) do |t|
|
|
11
|
+
t.string :name
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
drop_table(:publishable_blocks) if table_exists?(:publishable_blocks)
|
|
15
|
+
drop_table(:publishable_block_versions) if table_exists?(:publishable_block_versions)
|
|
16
|
+
create_content_table(:publishable_blocks) do |t|
|
|
11
17
|
t.string :name
|
|
12
18
|
end
|
|
13
19
|
end
|
|
@@ -19,23 +25,47 @@ end
|
|
|
19
25
|
class Unpublishable < ActiveRecord::Base
|
|
20
26
|
end
|
|
21
27
|
|
|
28
|
+
class PublishableBlock < ActiveRecord::Base
|
|
29
|
+
acts_as_content_block
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class PublishableBlockTestCase < ActiveSupport::TestCase
|
|
33
|
+
|
|
34
|
+
def setup
|
|
35
|
+
@object = PublishableBlock.create!(:name=>"v1", :publish_on_save=>true)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test "#live?" do
|
|
39
|
+
assert @object.live?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
test "#live? if there are draft versions" do
|
|
43
|
+
@object.name = "New Name"
|
|
44
|
+
@object.save!
|
|
45
|
+
|
|
46
|
+
assert_equal false, @object.live?
|
|
47
|
+
assert_equal :draft, @object.status
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
22
51
|
class PublishableTestCase < ActiveSupport::TestCase
|
|
23
|
-
|
|
52
|
+
|
|
53
|
+
def setup
|
|
24
54
|
@object = Publishable.new(:name => "New Record")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_publishable
|
|
25
58
|
assert @object.publishable?
|
|
26
59
|
end
|
|
27
|
-
|
|
60
|
+
|
|
28
61
|
def test_save
|
|
29
|
-
@object = Publishable.new(:name => "New Record")
|
|
30
62
|
assert @object.save
|
|
31
63
|
assert !@object.published?
|
|
32
64
|
end
|
|
33
65
|
|
|
34
66
|
def test_publish_on_save
|
|
35
|
-
@object = Publishable.new(:name => "New Record")
|
|
36
67
|
@object.publish_on_save = true
|
|
37
68
|
assert @object.save
|
|
38
|
-
log_table_without_stamps Publishable
|
|
39
69
|
assert @object.reload.published?
|
|
40
70
|
end
|
|
41
71
|
|
|
@@ -45,9 +75,10 @@ class PublishableTestCase < ActiveSupport::TestCase
|
|
|
45
75
|
assert @object.save
|
|
46
76
|
assert !@object.publishable?
|
|
47
77
|
end
|
|
48
|
-
|
|
78
|
+
|
|
49
79
|
def test_not_publishable_if_connect_to_page_id_is_blank
|
|
50
80
|
assert HtmlBlock.new(:connect_to_page_id => "").publishable?
|
|
51
81
|
end
|
|
52
|
-
|
|
82
|
+
|
|
83
|
+
|
|
53
84
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class VersioningTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@published_block = Factory(:html_block, :name=>"Version 1", :publish_on_save=>true)
|
|
7
|
+
@published_block.update_attributes(:name=>"Version 2")
|
|
8
|
+
@published_block.reload
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def teardown
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
test "#name matches original version's attributes'" do
|
|
16
|
+
assert_equal "Version 1", @published_block.name
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "#as_of_draft_version" do
|
|
20
|
+
v2 = @published_block.as_of_draft_version
|
|
21
|
+
assert_equal "Version 2", v2.name
|
|
22
|
+
assert_equal HtmlBlock, v2.class
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test "#draft returns the latest Version Object for a block" do
|
|
26
|
+
v2 = @published_block.draft
|
|
27
|
+
assert_equal "Version 2", v2.name
|
|
28
|
+
assert_equal HtmlBlock::Version, v2.class
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
test "#as_of_version" do
|
|
32
|
+
v1 = @published_block.as_of_version(1)
|
|
33
|
+
assert_equal "Version 1", v1.name
|
|
34
|
+
assert_equal @published_block.id, v1.id
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -2,8 +2,12 @@ require File.join(File.dirname(__FILE__), '/../../test_helper')
|
|
|
2
2
|
|
|
3
3
|
class Cms::MenuHelperTest < ActionView::TestCase
|
|
4
4
|
|
|
5
|
+
def setup
|
|
6
|
+
remove_all_sitemap_fixtures_to_avoid_bugs
|
|
7
|
+
root_section # Ensure this exists
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
def test_menu_items
|
|
6
|
-
Page.first.update_attributes(:hidden => true, :publish_on_save => true)
|
|
7
11
|
create_nfl_data
|
|
8
12
|
|
|
9
13
|
expected = [
|
|
@@ -108,7 +112,6 @@ class Cms::MenuHelperTest < ActionView::TestCase
|
|
|
108
112
|
end
|
|
109
113
|
|
|
110
114
|
def test_menu_with_links
|
|
111
|
-
Page.first.update_attributes(:hidden => true, :publish_on_save => true)
|
|
112
115
|
|
|
113
116
|
@news = Factory(:section, :parent => root_section, :name => "News", :path => "/whatever")
|
|
114
117
|
@press_releases = Factory(:page, :section => @news, :name => "Press Releases", :path => "/press_releases", :publish_on_save => true)
|
|
@@ -3,6 +3,8 @@ require File.join(File.dirname(__FILE__), '/../../test_helper')
|
|
|
3
3
|
class Cms::PageHelperTest < ActionView::TestCase
|
|
4
4
|
|
|
5
5
|
def setup
|
|
6
|
+
root_section.name = "My Site"
|
|
7
|
+
root_section.save!
|
|
6
8
|
@foo = Factory(:section, :name => "Foo", :parent => root_section, :path => "/foo")
|
|
7
9
|
Factory(:page, :name => "Overview", :section => @foo, :path => "/foo")
|
|
8
10
|
@bar = Factory(:section, :name => "Bar", :parent => @foo, :path => "/bar")
|