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
@@ -1,8 +1,52 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '/../../test_helper')
|
2
2
|
|
3
3
|
class LinkTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@link = Factory(:link)
|
7
|
+
@another_link = Factory(:link)
|
8
|
+
end
|
9
|
+
|
4
10
|
def test_create
|
5
11
|
assert Factory.build(:link).valid?
|
6
12
|
assert !Factory.build(:link, :name => "").valid?
|
7
13
|
end
|
14
|
+
|
15
|
+
test "draft_version is stored on pages" do
|
16
|
+
assert_equal 1, @link.version
|
17
|
+
assert_equal 1, @link.latest_version
|
18
|
+
end
|
19
|
+
|
20
|
+
test "#update increments the latest_version" do
|
21
|
+
@link.name = "New"
|
22
|
+
@link.save!
|
23
|
+
@link.reload
|
24
|
+
|
25
|
+
assert_equal 1, @link.version
|
26
|
+
assert_equal 2, @link.latest_version
|
27
|
+
|
28
|
+
assert_equal 1, @another_link.reload.latest_version, "Should only update its own version, not other tables"
|
29
|
+
end
|
30
|
+
|
31
|
+
test "live?" do
|
32
|
+
assert @link.live?
|
33
|
+
end
|
34
|
+
|
35
|
+
test "updating makes it not live" do
|
36
|
+
@link.update_attributes(:name => "New")
|
37
|
+
@link.reload
|
38
|
+
refute @link.live?
|
39
|
+
|
40
|
+
@link.publish!
|
41
|
+
@link.reload
|
42
|
+
assert @link.live?
|
43
|
+
end
|
44
|
+
|
45
|
+
test "live? as_of_version" do
|
46
|
+
@link.update_attributes(:name => "New")
|
47
|
+
@link.publish!
|
48
|
+
|
49
|
+
v1 = @link.as_of_version(1)
|
50
|
+
assert v1.live?
|
51
|
+
end
|
8
52
|
end
|
@@ -1,46 +1,105 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '/../../test_helper')
|
2
2
|
|
3
3
|
class CreatingPageTest < ActiveRecord::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
def test_it
|
6
|
-
|
6
|
+
|
7
7
|
@page = Page.new(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
:name => "Test",
|
9
|
+
:path => "test",
|
10
|
+
:section => root_section,
|
11
|
+
:publish_on_save => true)
|
12
|
+
|
13
13
|
assert @page.save
|
14
14
|
assert_path_is_unique
|
15
|
-
|
15
|
+
|
16
16
|
@page.update_attributes(:name => "Test v2")
|
17
|
-
|
17
|
+
|
18
18
|
page = Page.find_live_by_path("/test")
|
19
19
|
assert_equal page.name, "Test"
|
20
20
|
assert_equal 1, page.version
|
21
|
-
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
test "Creating a page builds a section node" do
|
25
|
+
@page = Page.create!(:name=>"Hello", :path=>"/hello", :section => Factory(:root_section))
|
26
|
+
assert_not_nil @page.section_node
|
27
|
+
end
|
28
|
+
|
29
|
+
test "page with no parent" do
|
30
|
+
@page = Page.new
|
31
|
+
assert_nil @page.parent
|
22
32
|
end
|
23
33
|
|
34
|
+
test "#section is alias for #parent" do
|
35
|
+
@page = Page.new
|
36
|
+
assert_nil @page.section
|
37
|
+
end
|
38
|
+
|
39
|
+
|
24
40
|
protected
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
41
|
+
def assert_path_is_unique
|
42
|
+
page = Factory.build(:page, :path => @page.path)
|
43
|
+
assert_not_valid page
|
44
|
+
assert_has_error_on page, :path
|
45
|
+
end
|
46
|
+
|
31
47
|
end
|
32
48
|
|
49
|
+
class VersionTest < ActiveSupport::TestCase
|
50
|
+
|
51
|
+
def setup
|
52
|
+
@page = Factory(:public_page)
|
53
|
+
@another_page = Factory(:public_page)
|
54
|
+
end
|
55
|
+
|
56
|
+
test "draft_version is stored on pages" do
|
57
|
+
assert_equal 1, @page.version
|
58
|
+
assert_equal 1, @page.latest_version
|
59
|
+
end
|
60
|
+
|
61
|
+
test "#update increments the latest_version" do
|
62
|
+
@page.name = "New"
|
63
|
+
@page.save!
|
64
|
+
@page.reload
|
65
|
+
|
66
|
+
assert_equal 1, @page.version
|
67
|
+
assert_equal 2, @page.latest_version
|
68
|
+
|
69
|
+
assert_equal 1, @another_page.reload.latest_version, "Should only update its own version, not other tables"
|
70
|
+
end
|
71
|
+
|
72
|
+
test "live? using latest version" do
|
73
|
+
assert @page.live?
|
74
|
+
|
75
|
+
@page.update_attributes(:name => "New")
|
76
|
+
@page.reload
|
77
|
+
refute @page.live?
|
78
|
+
|
79
|
+
@page.publish!
|
80
|
+
@page.reload
|
81
|
+
assert @page.live?
|
82
|
+
end
|
83
|
+
|
84
|
+
test "live? as_of_version" do
|
85
|
+
@page.update_attributes(:name => "New")
|
86
|
+
@page.publish!
|
87
|
+
|
88
|
+
v1 = @page.as_of_version(1)
|
89
|
+
assert v1.live?
|
90
|
+
end
|
91
|
+
end
|
33
92
|
class PageTest < ActiveRecord::TestCase
|
34
93
|
|
35
94
|
def test_creating_page_with_reserved_path
|
36
95
|
@page = Page.new(:name => "FAIL", :path => "/cms")
|
37
96
|
assert_not_valid @page
|
38
97
|
assert_has_error_on(@page, :path, "is invalid, '/cms' a reserved path")
|
39
|
-
|
98
|
+
|
40
99
|
@page = Page.new(:name => "FAIL", :path => "/cache")
|
41
100
|
assert_not_valid @page
|
42
101
|
assert_has_error_on(@page, :path, "is invalid, '/cache' a reserved path")
|
43
|
-
|
102
|
+
|
44
103
|
@page = Page.new(:name => "FTW", :path => "/whatever")
|
45
104
|
assert_valid @page
|
46
105
|
end
|
@@ -48,15 +107,15 @@ class PageTest < ActiveRecord::TestCase
|
|
48
107
|
def test_find_live_by_path
|
49
108
|
@page = Factory.build(:page, :path => '/foo')
|
50
109
|
assert_nil Page.find_live_by_path('/foo')
|
51
|
-
|
110
|
+
|
52
111
|
@page.publish!
|
53
112
|
reset(:page)
|
54
113
|
assert_equal @page, Page.find_live_by_path('/foo')
|
55
|
-
|
114
|
+
|
56
115
|
@page.update_attributes(:path => '/bar')
|
57
116
|
assert_equal @page, Page.find_live_by_path('/foo')
|
58
117
|
assert_nil Page.find_live_by_path('/bar')
|
59
|
-
|
118
|
+
|
60
119
|
@page.publish!
|
61
120
|
reset(:page)
|
62
121
|
assert_nil Page.find_live_by_path('/foo')
|
@@ -79,17 +138,17 @@ class PageTest < ActiveRecord::TestCase
|
|
79
138
|
assert_equal @new_page, Page.find_live_by_path('/foo')
|
80
139
|
assert_not_equal @page, @new_page
|
81
140
|
end
|
82
|
-
|
141
|
+
|
83
142
|
def test_path_normalization
|
84
143
|
page = Factory.build(:page, :path => 'foo/bar')
|
85
144
|
assert_valid page
|
86
145
|
assert_equal "/foo/bar", page.path
|
87
|
-
|
146
|
+
|
88
147
|
page = Factory.build(:page, :path => '/foo/bar')
|
89
148
|
assert_valid page
|
90
|
-
assert_equal "/foo/bar", page.path
|
149
|
+
assert_equal "/foo/bar", page.path
|
91
150
|
end
|
92
|
-
|
151
|
+
|
93
152
|
def test_template
|
94
153
|
page_template = Factory(:page_template, :name => 'test')
|
95
154
|
page = Factory.build(:page, :template_file_name => 'test.html.erb')
|
@@ -97,23 +156,23 @@ class PageTest < ActiveRecord::TestCase
|
|
97
156
|
assert_equal 'Test (html/erb)', page.template_name
|
98
157
|
assert_equal page_template, page.template
|
99
158
|
assert_equal 'templates/test', page.layout
|
100
|
-
|
159
|
+
|
101
160
|
page = Factory.build(:page, :template_file_name => 'foo.html.erb')
|
102
161
|
assert_equal 'foo.html.erb', page.template_file_name
|
103
162
|
assert_equal 'Foo (html/erb)', page.template_name
|
104
163
|
assert_nil page.template
|
105
164
|
assert_equal 'templates/foo', page.layout
|
106
165
|
end
|
107
|
-
|
166
|
+
|
108
167
|
def test_revision_comments
|
109
168
|
page = Factory(:page, :section => root_section, :name => "V1")
|
110
|
-
|
169
|
+
|
111
170
|
assert_equal 'Created', page.live_version.version_comment
|
112
|
-
|
171
|
+
|
113
172
|
assert page.reload.save
|
114
173
|
assert_equal 'Created', page.reload.live_version.version_comment
|
115
174
|
assert_equal page.live_version.version_comment,
|
116
|
-
|
175
|
+
page.as_of_version(page.version).live_version.version_comment
|
117
176
|
|
118
177
|
page.update_attributes(:name => "V2")
|
119
178
|
assert_equal 'Changed name', page.draft.version_comment
|
@@ -122,7 +181,7 @@ class PageTest < ActiveRecord::TestCase
|
|
122
181
|
block = Factory(:html_block, :name => "Hello, World!")
|
123
182
|
page.create_connector(block, "main")
|
124
183
|
assert_equal "Html Block 'Hello, World!' was added to the 'main' container",
|
125
|
-
|
184
|
+
page.draft.version_comment
|
126
185
|
assert_equal 'Created', page.live_version.version_comment
|
127
186
|
assert_equal 3, page.reload.draft.version
|
128
187
|
|
@@ -131,30 +190,30 @@ class PageTest < ActiveRecord::TestCase
|
|
131
190
|
|
132
191
|
page.move_connector_down(page.connectors.for_page_version(page.reload.draft.version).for_connectable(block).first)
|
133
192
|
assert_equal "Html Block 'Hello, World!' was moved down within the 'main' container",
|
134
|
-
|
193
|
+
page.draft.version_comment
|
135
194
|
assert_equal 'Created', page.live_version.version_comment
|
136
195
|
|
137
196
|
page.move_connector_up(page.connectors.for_page_version(page.reload.draft.version).for_connectable(block).first)
|
138
197
|
assert_equal "Html Block 'Hello, World!' was moved up within the 'main' container",
|
139
|
-
|
198
|
+
page.draft.version_comment
|
140
199
|
assert_equal 'Created', page.live_version.version_comment
|
141
200
|
|
142
201
|
page.remove_connector(page.connectors.for_page_version(page.reload.draft.version).for_connectable(block).first)
|
143
202
|
assert_equal "Html Block 'Hello, World!' was removed from the 'main' container",
|
144
|
-
|
203
|
+
page.draft.version_comment
|
145
204
|
assert_equal 'Created', page.live_version.version_comment
|
146
205
|
|
147
206
|
page.revert_to(1)
|
148
207
|
assert_equal "Reverted to version 1",
|
149
|
-
|
208
|
+
page.reload.draft.version_comment
|
150
209
|
assert_equal 'Created', page.live_version.version_comment
|
151
210
|
|
152
211
|
assert_equal "Created", page.as_of_version(1).current_version.version_comment
|
153
212
|
assert_equal "Changed name", page.as_of_version(2).current_version.version_comment
|
154
213
|
assert_equal "Reverted to version 1", page.draft.version_comment
|
155
214
|
|
156
|
-
end
|
157
|
-
|
215
|
+
end
|
216
|
+
|
158
217
|
def test_container_live
|
159
218
|
page = Factory(:page)
|
160
219
|
published = Factory(:html_block, :publish_on_save => true)
|
@@ -165,31 +224,32 @@ class PageTest < ActiveRecord::TestCase
|
|
165
224
|
assert unpublished.publish
|
166
225
|
assert page.container_published?("main")
|
167
226
|
end
|
168
|
-
|
227
|
+
|
169
228
|
def test_move_page_to_another_section
|
170
|
-
page = Factory(:
|
171
|
-
|
172
|
-
|
173
|
-
page.section
|
229
|
+
page = Factory(:public_page)
|
230
|
+
new_section = Factory(:public_section)
|
231
|
+
|
232
|
+
assert_not_equal new_section, page.section
|
233
|
+
page.section = new_section
|
174
234
|
assert page.save
|
175
|
-
assert_equal
|
176
|
-
end
|
235
|
+
assert_equal new_section, page.section
|
236
|
+
end
|
177
237
|
|
178
238
|
def test_deleting_page
|
179
239
|
page = Factory(:page)
|
180
|
-
|
240
|
+
|
181
241
|
page_count = Page.count_with_deleted
|
182
242
|
page_version_count = page.versions.count
|
183
243
|
assert !page.deleted?
|
184
|
-
|
244
|
+
|
185
245
|
page.destroy
|
186
|
-
|
246
|
+
|
187
247
|
assert_equal page_count, Page.count_with_deleted
|
188
248
|
assert_incremented page_version_count, page.versions.count
|
189
249
|
assert page.deleted?
|
190
250
|
assert_raise ActiveRecord::RecordNotFound do
|
191
251
|
Page.find(page.id)
|
192
|
-
end
|
252
|
+
end
|
193
253
|
end
|
194
254
|
|
195
255
|
def test_adding_a_block_to_a_page_puts_page_in_draft_mode
|
@@ -205,61 +265,61 @@ class PageTest < ActiveRecord::TestCase
|
|
205
265
|
|
206
266
|
def test_reverting_and_then_publishing_a_page
|
207
267
|
@page = Factory(:page, :section => root_section, :publish_on_save => true)
|
208
|
-
|
209
|
-
@block = Factory(:html_block,
|
210
|
-
|
211
|
-
|
268
|
+
|
269
|
+
@block = Factory(:html_block,
|
270
|
+
:connect_to_page_id => @page.id,
|
271
|
+
:connect_to_container => "main")
|
212
272
|
@page.publish
|
213
|
-
|
273
|
+
|
214
274
|
reset(:page, :block)
|
215
|
-
|
275
|
+
|
216
276
|
assert_equal 2, @page.version
|
217
277
|
assert_equal 1, @page.connectors.for_page_version(@page.version).count
|
218
|
-
|
278
|
+
|
219
279
|
@block.update_attributes(:content => "Something else")
|
220
280
|
@page.publish!
|
221
281
|
reset(:page, :block)
|
222
|
-
|
282
|
+
|
223
283
|
assert_equal 1, @page.connectors.for_page_version(@page.version).count
|
224
284
|
assert_equal 2, @block.version
|
225
285
|
assert_equal 3, @page.version
|
226
286
|
assert @block.live?
|
227
287
|
assert @page.live?
|
228
|
-
|
288
|
+
|
229
289
|
@page.revert_to(2)
|
230
290
|
reset(:page, :block)
|
231
291
|
|
232
292
|
assert_equal 3, @page.version
|
233
293
|
assert_equal 4, @page.draft.version
|
234
294
|
assert_equal 2, @block.version
|
235
|
-
assert_equal 3, @block.draft.version
|
295
|
+
assert_equal 3, @block.draft.version
|
236
296
|
assert_equal 1, @page.connectors.for_page_version(@page.version).count
|
237
|
-
assert_equal 1, @page.connectors.for_page_version(@page.draft.version).count
|
297
|
+
assert_equal 1, @page.connectors.for_page_version(@page.draft.version).count
|
238
298
|
assert !@page.live?
|
239
299
|
assert !@block.live?
|
240
|
-
|
300
|
+
|
241
301
|
end
|
242
302
|
|
243
303
|
end
|
244
304
|
|
245
|
-
class
|
246
|
-
|
305
|
+
class UserStampingTest < ActiveRecord::TestCase
|
306
|
+
|
247
307
|
def setup
|
248
308
|
@first_guy = Factory(:user, :login => "first_guy")
|
249
309
|
@next_guy = Factory(:user, :login => "next_guy")
|
250
|
-
User.current = @first_guy
|
310
|
+
User.current = @first_guy
|
251
311
|
end
|
252
|
-
|
312
|
+
|
253
313
|
def teardown
|
254
314
|
User.current = nil
|
255
315
|
end
|
256
|
-
|
257
|
-
def
|
316
|
+
|
317
|
+
def test_user_stamps_are_applied_to_versions
|
258
318
|
page = Factory(:page, :name => "Original Value")
|
259
|
-
|
319
|
+
|
260
320
|
assert_equal page, page.draft.page
|
261
321
|
assert_equal @first_guy, page.updated_by
|
262
|
-
|
322
|
+
|
263
323
|
User.current = @new_guy
|
264
324
|
page.update_attributes(:name => "Something Different")
|
265
325
|
|
@@ -270,74 +330,80 @@ class PageVersioningTest < ActiveRecord::TestCase
|
|
270
330
|
assert_equal @new_guy, page.versions.last.updated_by
|
271
331
|
assert_equal 2, page.versions.count
|
272
332
|
end
|
273
|
-
|
333
|
+
|
274
334
|
end
|
275
335
|
|
276
336
|
class PageInSectionTest < ActiveRecord::TestCase
|
277
|
-
def test_that_it_returns_true_if_the_page_is_in_a_child_section_of_the_section
|
278
|
-
@sports = Factory(:section, :parent => root_section, :name => "Sports")
|
279
|
-
@nfl = Factory(:section, :parent => @sports, :name => "NFL")
|
280
|
-
@mlb = Factory(:section, :parent => @sports, :name => "MLB")
|
281
|
-
@afc = Factory(:section, :parent => @nfl, :name => "AFC")
|
282
|
-
@al = Factory(:section, :parent => @mlb, :name => "AL")
|
283
|
-
@afc_east = Factory(:section, :parent => @afc, :name => "AFC East")
|
284
|
-
@al_east = Factory(:section, :parent => @al, :name => "AL East")
|
285
|
-
@ravens = Factory(:section, :parent => @afc_east, :name => "Baltimore Ravens")
|
286
|
-
@yanks = Factory(:section, :parent => @al_east, :name => "New York Yankees")
|
287
|
-
@flacco = Factory(:page, :section => @ravens, :name => "Joe Flacco")
|
288
|
-
@jeter = Factory(:page, :section => @yanks, :name => "Derek Jeter")
|
289
|
-
|
290
|
-
[root_section, @sports].each do |s|
|
291
|
-
assert @flacco.in_section?(s)
|
292
|
-
assert @flacco.in_section?(s.name)
|
293
|
-
assert @jeter.in_section?(s)
|
294
|
-
assert @jeter.in_section?(s.name)
|
295
|
-
end
|
296
337
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
assert !@jeter.in_section?(s.name)
|
302
|
-
end
|
338
|
+
def setup
|
339
|
+
@root = Factory(:root_section, :name=>"First Section")
|
340
|
+
@football_section = Factory :public_section, :name=>"Football", :parent=>@root
|
341
|
+
@baseball_section = Factory :public_section, :name=>"Baseball", :parent=>@root
|
303
342
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
343
|
+
@football_page = Factory :public_page, :section=>@football_section
|
344
|
+
@baseball_page = Factory :public_page, :section=>@baseball_section
|
345
|
+
end
|
346
|
+
|
347
|
+
test "in_section if immediate parent section is included" do
|
348
|
+
assert @football_page.in_section?("Football")
|
349
|
+
assert !@baseball_page.in_section?("Football")
|
350
|
+
end
|
351
|
+
|
352
|
+
test "in_section if immediate parent's name is included" do
|
353
|
+
assert @football_page.in_section?("Football")
|
354
|
+
assert !@baseball_page.in_section?("Football")
|
355
|
+
end
|
356
|
+
|
357
|
+
test "in_section if any ancestor is included" do
|
358
|
+
assert @football_page.in_section?(@root)
|
359
|
+
assert @baseball_page.in_section?(@root)
|
360
|
+
assert @football_page.in_section?("First Section")
|
361
|
+
assert @baseball_page.in_section?("First Section")
|
362
|
+
end
|
363
|
+
|
364
|
+
test "#top_level_section" do
|
365
|
+
assert_equal @football_section, @football_page.top_level_section
|
366
|
+
assert_equal @baseball_section, @baseball_page.top_level_section
|
367
|
+
|
368
|
+
second_level_section = Factory(:public_section, :parent=>@football_section)
|
369
|
+
second_level_page = Factory(:public_page, :section=>second_level_section)
|
370
|
+
assert_equal @football_section, second_level_page.top_level_section
|
371
|
+
end
|
372
|
+
|
373
|
+
test "#top_level_section caches result to avoid repeated requests" do
|
374
|
+
top = @football_page.top_level_section
|
375
|
+
assert_equal top.object_id, @football_page.top_level_section.object_id
|
310
376
|
end
|
311
377
|
end
|
312
378
|
|
313
379
|
class PageWithAssociatedBlocksTest < ActiveRecord::TestCase
|
314
|
-
def setup
|
315
|
-
super
|
380
|
+
def setup
|
381
|
+
super
|
316
382
|
@page = Factory(:page, :section => root_section, :name => "Bar")
|
317
383
|
@block = Factory(:html_block)
|
318
384
|
@other_connector = Factory(:connector, :connectable => @block, :connectable_version => @block.version)
|
319
385
|
@page_connector = Factory(:connector, :page => @page, :page_version => @page.version, :connectable => @block, :connectable_version => @block.version)
|
320
386
|
end
|
321
|
-
|
387
|
+
|
322
388
|
# It should create a new page version and a new connector
|
323
389
|
def test_updating_the_page_with_changes
|
324
390
|
connector_count = Connector.count
|
325
391
|
page_version = @page.version
|
326
|
-
|
327
|
-
@page.update_attributes(:name => "Foo")
|
328
|
-
|
392
|
+
|
393
|
+
@page.update_attributes(:name => "Foo")
|
394
|
+
|
329
395
|
assert_incremented connector_count, Connector.count
|
330
396
|
assert_equal page_version, @page.version
|
331
397
|
assert_incremented page_version, @page.draft.version
|
332
398
|
end
|
333
|
-
|
399
|
+
|
334
400
|
# It should not create a new page version or a new connector
|
335
|
-
def test_updating_the_page_without_changes
|
401
|
+
def test_updating_the_page_without_changes
|
336
402
|
connector_count = Connector.count
|
337
403
|
page_version = @page.version
|
338
|
-
|
339
|
-
@page.update_attributes(:name => @page.name)
|
340
|
-
|
404
|
+
|
405
|
+
@page.update_attributes(:name => @page.name)
|
406
|
+
|
341
407
|
assert_equal connector_count, Connector.count
|
342
408
|
assert_equal page_version, @page.version
|
343
409
|
end
|
@@ -346,9 +412,9 @@ class PageWithAssociatedBlocksTest < ActiveRecord::TestCase
|
|
346
412
|
connector_count = Connector.count
|
347
413
|
assert Connector.exists?(@page_connector.id)
|
348
414
|
assert Connector.exists?(@other_connector.id)
|
349
|
-
|
415
|
+
|
350
416
|
@page.destroy
|
351
|
-
|
417
|
+
|
352
418
|
assert_decremented connector_count, Connector.count
|
353
419
|
assert !Connector.exists?(@page_connector.id)
|
354
420
|
assert Connector.exists?(@other_connector.id)
|
@@ -361,13 +427,13 @@ class AddingBlocksToPageTest < ActiveRecord::TestCase
|
|
361
427
|
def test_that_it_works
|
362
428
|
@page = Factory(:page, :section => root_section)
|
363
429
|
@block = Factory(:html_block)
|
364
|
-
@block2 = Factory(:html_block)
|
430
|
+
@block2 = Factory(:html_block)
|
365
431
|
@first_conn = @page.create_connector(@block, "testing")
|
366
432
|
@second_conn = @page.create_connector(@block2, "testing")
|
367
|
-
|
433
|
+
|
368
434
|
page_version_count = @page.versions.count
|
369
435
|
connector_count = Connector.count
|
370
|
-
|
436
|
+
|
371
437
|
@conn = @page.create_connector(@block2, "testing")
|
372
438
|
|
373
439
|
assert_equal 1, @page.reload.version
|
@@ -376,57 +442,57 @@ class AddingBlocksToPageTest < ActiveRecord::TestCase
|
|
376
442
|
assert_incremented page_version_count, @page.versions.count
|
377
443
|
assert_equal 3, @page.connectors.for_page_version(@page.draft.version).count
|
378
444
|
assert_equal connector_count + 3, Connector.count
|
379
|
-
|
445
|
+
|
380
446
|
# should leave the previous connectors untouched
|
381
447
|
@conns = @page.connectors.all(:conditions => ["page_version < 4"], :order => "id")
|
382
448
|
|
383
449
|
assert_equal 3, @conns.size
|
384
450
|
|
385
451
|
assert_properties @conns[0], {
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
452
|
+
:connectable => @block,
|
453
|
+
:page => @page,
|
454
|
+
:page_version => 2,
|
455
|
+
:connectable_version => 1
|
390
456
|
}
|
391
|
-
|
457
|
+
|
392
458
|
assert_properties @conns[1], {
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
459
|
+
:connectable => @block,
|
460
|
+
:page => @page,
|
461
|
+
:page_version => 3,
|
462
|
+
:connectable_version => 1
|
397
463
|
}
|
398
|
-
|
464
|
+
|
399
465
|
assert_properties @conns[2], {
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
466
|
+
:connectable => @block2,
|
467
|
+
:page => @page,
|
468
|
+
:page_version => 3,
|
469
|
+
:connectable_version => 1
|
404
470
|
}
|
405
471
|
|
406
472
|
@conns = @page.connectors.for_page_version(4).all(:order => "id")
|
407
473
|
assert_equal 3, @conns.size
|
408
|
-
|
474
|
+
|
409
475
|
assert_properties @conns[0], {
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
476
|
+
:connectable => @block,
|
477
|
+
:page => @page,
|
478
|
+
:page_version => 4,
|
479
|
+
:connectable_version => 1
|
414
480
|
}
|
415
|
-
|
481
|
+
|
416
482
|
assert_properties @conns[1], {
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
483
|
+
:connectable => @block2,
|
484
|
+
:page => @page,
|
485
|
+
:page_version => 4,
|
486
|
+
:connectable_version => 1
|
421
487
|
}
|
422
|
-
|
488
|
+
|
423
489
|
assert_properties @conns[2], {
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
490
|
+
:connectable => @block2,
|
491
|
+
:page => @page,
|
492
|
+
:page_version => 4,
|
493
|
+
:connectable_version => 1
|
428
494
|
}
|
429
|
-
|
495
|
+
|
430
496
|
end
|
431
497
|
end
|
432
498
|
|
@@ -441,31 +507,31 @@ class PageWithTwoBlocksTest < ActiveRecord::TestCase
|
|
441
507
|
@page.create_connector(@bar_block, "whatever")
|
442
508
|
@page.reload
|
443
509
|
end
|
444
|
-
|
510
|
+
|
445
511
|
def test_editing_one_of_the_blocks_creates_a_new_version_of_the_page
|
446
512
|
page_version = @page.draft.version
|
447
513
|
@foo_block.update_attributes(:name => "Something Else")
|
448
514
|
assert_incremented page_version, @page.draft.version
|
449
515
|
end
|
450
|
-
|
516
|
+
|
451
517
|
# A page that had 2 blocks added to it and then had them removed,
|
452
518
|
# when reverting to the previous version,
|
453
519
|
# should restore the connectors from the version being reverted to
|
454
520
|
def test_removing_and_reverting_to_previous_version
|
455
521
|
remove_both_connectors!
|
456
|
-
|
522
|
+
|
457
523
|
connector_count = Connector.count
|
458
|
-
|
524
|
+
|
459
525
|
@page.revert
|
460
|
-
|
526
|
+
|
461
527
|
assert_incremented connector_count, Connector.count
|
462
|
-
|
528
|
+
|
463
529
|
assert_properties @page.reload.connectors.for_page_version(@page.draft.version).first, {
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
530
|
+
:page => @page,
|
531
|
+
:page_version => 6,
|
532
|
+
:connectable => @bar_block,
|
533
|
+
:connectable_version => 1,
|
534
|
+
:container => "whatever"}
|
469
535
|
end
|
470
536
|
|
471
537
|
# A page that had 2 blocks added to it and then had then removed,
|
@@ -473,27 +539,27 @@ class PageWithTwoBlocksTest < ActiveRecord::TestCase
|
|
473
539
|
# should restore the connectors that version
|
474
540
|
def test_removing_and_reverting_to_version_with_both_connectors
|
475
541
|
remove_both_connectors!
|
476
|
-
|
542
|
+
|
477
543
|
connector_count = Connector.count
|
478
|
-
|
544
|
+
|
479
545
|
@page.revert_to(3)
|
480
|
-
|
546
|
+
|
481
547
|
assert_equal connector_count + 2, Connector.count
|
482
|
-
|
548
|
+
|
483
549
|
foo, bar = @page.reload.connectors.for_page_version(@page.draft.version).find(:all, :order => "connectors.position")
|
484
550
|
assert_properties foo, {
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
551
|
+
:page => @page,
|
552
|
+
:page_version => 6,
|
553
|
+
:connectable => @foo_block,
|
554
|
+
:connectable_version => 1,
|
555
|
+
:container => "whatever"}
|
490
556
|
assert_properties bar, {
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
557
|
+
:page => @page,
|
558
|
+
:page_version => 6,
|
559
|
+
:connectable => @bar_block,
|
560
|
+
:connectable_version => 1,
|
561
|
+
:container => "whatever"}
|
562
|
+
|
497
563
|
end
|
498
564
|
|
499
565
|
def test_updating_one_of_the_blocks_and_reverting_to_version_before_the_update
|
@@ -503,19 +569,19 @@ class PageWithTwoBlocksTest < ActiveRecord::TestCase
|
|
503
569
|
|
504
570
|
page_version = @page.draft.version
|
505
571
|
foo_block_version = @foo_block.draft.version
|
506
|
-
|
572
|
+
|
507
573
|
@page.revert_to(target_version)
|
508
|
-
|
574
|
+
|
509
575
|
assert_incremented page_version, @page.draft.version
|
510
576
|
assert_incremented foo_block_version, @foo_block.draft.version
|
511
577
|
assert_equal "Foo Block", @page.connectors.for_page_version(@page.draft.version).reload.first.connectable.name
|
512
578
|
end
|
513
579
|
|
514
580
|
protected
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
581
|
+
def remove_both_connectors!
|
582
|
+
@page.remove_connector(@page.connectors.for_page_version(@page.draft.version).first(:order => "connectors.position"))
|
583
|
+
@page.remove_connector(@page.connectors.for_page_version(@page.draft.version).first(:order => "connectors.position"))
|
584
|
+
end
|
519
585
|
|
520
586
|
end
|
521
587
|
|
@@ -523,35 +589,35 @@ class PageWithBlockTest < ActiveRecord::TestCase
|
|
523
589
|
def setup
|
524
590
|
@page = Factory(:page, :section => root_section)
|
525
591
|
@block = Factory(:html_block)
|
526
|
-
@conn = @page.create_connector(@block, "bar")
|
592
|
+
@conn = @page.create_connector(@block, "bar")
|
527
593
|
@page.publish!
|
528
594
|
@conn = @page.connectors.for_page_version(@page.version).for_connectable(@block).first
|
529
595
|
end
|
530
|
-
|
596
|
+
|
531
597
|
def test_removing_connector
|
532
598
|
page_version = @page.draft.version
|
533
599
|
page_version_count = Page::Version.count
|
534
600
|
assert @page.published?
|
535
|
-
|
536
|
-
@page.remove_connector(@conn)
|
537
|
-
|
601
|
+
|
602
|
+
@page.remove_connector(@conn)
|
603
|
+
|
538
604
|
assert_incremented page_version_count, Page::Version.count
|
539
605
|
assert_incremented page_version, @page.draft.version
|
540
|
-
|
606
|
+
|
541
607
|
conns = @page.connectors.for_page_version(@page.draft.version-1).all
|
542
608
|
assert_equal 1, conns.size
|
543
|
-
|
609
|
+
|
544
610
|
assert_properties conns.first, {
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
611
|
+
:page => @page,
|
612
|
+
:page_version => page_version,
|
613
|
+
:connectable => @block,
|
614
|
+
:connectable_version => @block.version
|
549
615
|
}
|
550
616
|
|
551
617
|
assert @page.reload.connectors.for_page_version(@page.draft.version).empty?
|
552
618
|
assert !@page.live?
|
553
619
|
end
|
554
|
-
|
620
|
+
|
555
621
|
def test_removing_multiple_connectors
|
556
622
|
@block2 = Factory(:html_block)
|
557
623
|
@conn2 = @page.create_connector(@block2, "bar")
|
@@ -559,37 +625,37 @@ class PageWithBlockTest < ActiveRecord::TestCase
|
|
559
625
|
#Need to get the new connector that matches @conn2, otherwise you will delete an older version, not the latest connector
|
560
626
|
@conn2 = Connector.first(:conditions => {:page_id => @page.reload.id, :page_version => @page.draft.version, :connectable_id => @block2.id, :connectable_version => @block2.version, :container => "bar"})
|
561
627
|
@page.remove_connector(@conn2)
|
562
|
-
|
628
|
+
|
563
629
|
page_version_count = Page::Version.count
|
564
630
|
page_version = @page.draft.version
|
565
631
|
page_connector_count = @page.connectors.for_page_version(@page.draft.version).count
|
566
|
-
|
632
|
+
|
567
633
|
@conn = Connector.first(:conditions => {:page_id => @page.reload.id, :page_version => @page.draft.version, :connectable_id => @block2.id, :connectable_version => @block2.version, :container => "foo"})
|
568
|
-
@page.remove_connector(@conn)
|
634
|
+
@page.remove_connector(@conn)
|
569
635
|
@page.reload
|
570
|
-
|
636
|
+
|
571
637
|
assert_incremented page_version_count, Page::Version.count
|
572
638
|
assert_incremented page_version, @page.draft.version
|
573
|
-
assert_decremented page_connector_count,
|
574
|
-
|
575
|
-
|
639
|
+
assert_decremented page_connector_count,
|
640
|
+
@page.connectors.for_page_version(@page.draft.version).count
|
641
|
+
|
576
642
|
conns = @page.connectors.all(:order => "id")
|
577
|
-
|
643
|
+
|
578
644
|
#log_array conns, :id, :page_id, :page_version, :connectable_id, :connectable_type, :connectable_version, :container, :position
|
579
645
|
|
580
646
|
assert_equal 9, conns.size
|
581
647
|
|
582
|
-
assert_properties conns[0], {:page => @page, :page_version => 2, :connectable => @block
|
583
|
-
assert_properties conns[1], {:page => @page, :page_version => 3, :connectable => @block
|
648
|
+
assert_properties conns[0], {:page => @page, :page_version => 2, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
649
|
+
assert_properties conns[1], {:page => @page, :page_version => 3, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
584
650
|
assert_properties conns[2], {:page => @page, :page_version => 3, :connectable => @block2, :connectable_version => 1, :container => "bar", :position => 2}
|
585
|
-
assert_properties conns[3], {:page => @page, :page_version => 4, :connectable => @block
|
651
|
+
assert_properties conns[3], {:page => @page, :page_version => 4, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
586
652
|
assert_properties conns[4], {:page => @page, :page_version => 4, :connectable => @block2, :connectable_version => 1, :container => "bar", :position => 2}
|
587
653
|
assert_properties conns[5], {:page => @page, :page_version => 4, :connectable => @block2, :connectable_version => 1, :container => "foo", :position => 1}
|
588
|
-
assert_properties conns[6], {:page => @page, :page_version => 5, :connectable => @block
|
654
|
+
assert_properties conns[6], {:page => @page, :page_version => 5, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
589
655
|
assert_properties conns[7], {:page => @page, :page_version => 5, :connectable => @block2, :connectable_version => 1, :container => "foo", :position => 1}
|
590
|
-
assert_properties conns[8], {:page => @page, :page_version => 6, :connectable => @block
|
656
|
+
assert_properties conns[8], {:page => @page, :page_version => 6, :connectable => @block, :connectable_version => 1, :container => "bar", :position => 1}
|
591
657
|
end
|
592
|
-
|
658
|
+
|
593
659
|
end
|
594
660
|
|
595
661
|
class UnpublishedPageWithOnePublishedAndOneUnpublishedBlockTest < ActiveRecord::TestCase
|
@@ -600,23 +666,23 @@ class UnpublishedPageWithOnePublishedAndOneUnpublishedBlockTest < ActiveRecord::
|
|
600
666
|
@page.create_connector(@published_block, "main")
|
601
667
|
@page.create_connector(@unpublished_block, "main")
|
602
668
|
@published_block.publish!
|
603
|
-
@page.reload
|
669
|
+
@page.reload
|
604
670
|
end
|
605
|
-
|
671
|
+
|
606
672
|
def test_publishing_the_block
|
607
673
|
@unpublished_block.publish!
|
608
674
|
assert @unpublished_block.reload.published?
|
609
675
|
@page.reload
|
610
676
|
assert !@page.live?
|
611
677
|
end
|
612
|
-
|
678
|
+
|
613
679
|
def test_publishing_the_page
|
614
680
|
page_version_count = Page::Version.count
|
615
681
|
unpublished_block_version_count = @unpublished_block.versions.count
|
616
682
|
published_block_version_count = @published_block.versions.count
|
617
|
-
|
683
|
+
|
618
684
|
@page.publish!
|
619
|
-
|
685
|
+
|
620
686
|
assert_equal page_version_count, Page::Version.count
|
621
687
|
assert_equal unpublished_block_version_count, @unpublished_block.versions.count
|
622
688
|
assert_equal published_block_version_count, @published_block.versions.count
|
@@ -624,12 +690,12 @@ class UnpublishedPageWithOnePublishedAndOneUnpublishedBlockTest < ActiveRecord::
|
|
624
690
|
assert @unpublished_block.reload.live?
|
625
691
|
assert @published_block.reload.live?
|
626
692
|
end
|
627
|
-
|
693
|
+
|
628
694
|
end
|
629
695
|
|
630
696
|
class RevertingABlockThatIsOnMultiplePagesTest < ActiveRecord::TestCase
|
631
697
|
def test_that_it_reverts_both_pages
|
632
|
-
|
698
|
+
|
633
699
|
# 1. Create a new page (Page 1, v1)
|
634
700
|
@page1 = Factory(:page, :name => "Page 1")
|
635
701
|
assert_equal 1, @page1.version
|
@@ -638,8 +704,8 @@ class RevertingABlockThatIsOnMultiplePagesTest < ActiveRecord::TestCase
|
|
638
704
|
@page2 = Factory(:page, :name => "Page 2")
|
639
705
|
|
640
706
|
# 3. Add a new html block to Page 1. Save, don't publish. (Page 1, v2)
|
641
|
-
@block = Factory(:html_block, :name => "Block v1",
|
642
|
-
|
707
|
+
@block = Factory(:html_block, :name => "Block v1",
|
708
|
+
:connect_to_page_id => @page1.id, :connect_to_container => "main")
|
643
709
|
reset(:page1, :page2, :block)
|
644
710
|
assert_equal 2, @page1.draft.version
|
645
711
|
assert_equal 1, @page2.draft.version
|
@@ -667,9 +733,9 @@ class RevertingABlockThatIsOnMultiplePagesTest < ActiveRecord::TestCase
|
|
667
733
|
# Expected: Both page 1 and 2 will display the same version of the block (v1).
|
668
734
|
assert_equal "Block v1", @page1.connectors.first.connectable.name
|
669
735
|
assert_equal "Block v1", @page2.connectors.first.connectable.name
|
670
|
-
|
736
|
+
|
671
737
|
end
|
672
|
-
|
738
|
+
|
673
739
|
end
|
674
740
|
|
675
741
|
class ViewingAPreviousVersionOfAPageTest < ActiveRecord::TestCase
|
@@ -677,31 +743,31 @@ class ViewingAPreviousVersionOfAPageTest < ActiveRecord::TestCase
|
|
677
743
|
def test_that_it_shows_the_correct_version_of_the_blocks_it_is_connected_to
|
678
744
|
# 1. Create Page A (v1)
|
679
745
|
@page = Factory(:page, :section => root_section)
|
680
|
-
|
746
|
+
|
681
747
|
# 2. Add new Html Block A to Page A (Page A v2, Block A v1)
|
682
748
|
@block = Factory(:html_block, :name => "Block 1", :connect_to_page_id => @page.id, :connect_to_container => "main")
|
683
749
|
reset(:page, :block)
|
684
750
|
assert_equal 2, @page.draft.version
|
685
|
-
assert_equal 1, @block.draft.version
|
686
|
-
|
751
|
+
assert_equal 1, @block.draft.version
|
752
|
+
|
687
753
|
# 3. Publish Page A (Page A v3, Block A v2)
|
688
754
|
@page.publish!
|
689
755
|
reset(:page, :block)
|
690
756
|
assert_equal 2, @page.draft.version
|
691
|
-
assert_equal 1, @block.draft.version
|
692
|
-
|
757
|
+
assert_equal 1, @block.draft.version
|
758
|
+
|
693
759
|
# 4. Edit Block A (Page A v4, Block A v3)
|
694
760
|
@block.update_attributes!(:name => "Block 2")
|
695
761
|
reset(:page, :block)
|
696
762
|
assert_equal 2, @page.version
|
697
763
|
assert_equal 3, @page.draft.version
|
698
|
-
assert_equal 2, @block.draft.version
|
699
|
-
|
764
|
+
assert_equal 2, @block.draft.version
|
765
|
+
|
700
766
|
# Open Page A in a different browser (as guest)
|
701
767
|
@live_page = Page.find_live_by_path(@page.path)
|
702
768
|
assert_equal 2, @live_page.version
|
703
769
|
assert_equal "Block 1", @live_page.connectors.for_page_version(@live_page.version).first.connectable.live_version.name
|
704
|
-
|
770
|
+
|
705
771
|
end
|
706
772
|
end
|
707
773
|
|