comfypress 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +22 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +175 -0
- data/LICENSE +20 -0
- data/README.md +79 -0
- data/Rakefile +5 -0
- data/app/assets/images/comfypress/arrow_bottom.gif +0 -0
- data/app/assets/images/comfypress/arrow_right.gif +0 -0
- data/app/assets/images/comfypress/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/comfypress/bootstrap/glyphicons-halflings.png +0 -0
- data/app/assets/images/comfypress/checkerboard.gif +0 -0
- data/app/assets/images/comfypress/icon_draft.gif +0 -0
- data/app/assets/images/comfypress/icon_file.gif +0 -0
- data/app/assets/images/comfypress/icon_layout.gif +0 -0
- data/app/assets/images/comfypress/icon_move.gif +0 -0
- data/app/assets/images/comfypress/icon_page.gif +0 -0
- data/app/assets/images/comfypress/icon_site.gif +0 -0
- data/app/assets/images/comfypress/icon_snippet.gif +0 -0
- data/app/assets/images/comfypress/nav_arrow.png +0 -0
- data/app/assets/javascripts/comfypress/admin/application.js +1 -0
- data/app/assets/javascripts/comfypress/application.js.coffee +175 -0
- data/app/assets/javascripts/comfypress/lib/bootstrap-datetimepicker.js +21 -0
- data/app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js +492 -0
- data/app/assets/javascripts/comfypress/lib/bootstrap.js +6 -0
- data/app/assets/javascripts/comfypress/lib/codemirror.js +10 -0
- data/app/assets/javascripts/comfypress/lib/wysihtml5.js +261 -0
- data/app/assets/stylesheets/comfypress/admin/application.css +1 -0
- data/app/assets/stylesheets/comfypress/application.css.sass +8 -0
- data/app/assets/stylesheets/comfypress/base.css.sass +333 -0
- data/app/assets/stylesheets/comfypress/bootstrap_overrides.css.sass +45 -0
- data/app/assets/stylesheets/comfypress/codemirror_overrides.css.sass +27 -0
- data/app/assets/stylesheets/comfypress/lib/bootstrap-datetimepicker.css +9 -0
- data/app/assets/stylesheets/comfypress/lib/bootstrap-wysihtml5.css +102 -0
- data/app/assets/stylesheets/comfypress/lib/bootstrap.css +9 -0
- data/app/assets/stylesheets/comfypress/lib/codemirror.css +240 -0
- data/app/assets/stylesheets/comfypress/wysihtml5_overrides.css.sass +5 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/cms_admin/base_controller.rb +51 -0
- data/app/controllers/cms_admin/categories_controller.rb +35 -0
- data/app/controllers/cms_admin/files_controller.rb +108 -0
- data/app/controllers/cms_admin/layouts_controller.rb +67 -0
- data/app/controllers/cms_admin/menu_items_controller.rb +65 -0
- data/app/controllers/cms_admin/menus_controller.rb +60 -0
- data/app/controllers/cms_admin/pages_controller.rb +112 -0
- data/app/controllers/cms_admin/revisions_controller.rb +57 -0
- data/app/controllers/cms_admin/sites_controller.rb +64 -0
- data/app/controllers/cms_admin/snippets_controller.rb +64 -0
- data/app/controllers/cms_content_controller.rb +79 -0
- data/app/helpers/application_helper.rb +16 -0
- data/app/models/cms/block.rb +48 -0
- data/app/models/cms/categorization.rb +21 -0
- data/app/models/cms/category.rb +30 -0
- data/app/models/cms/file.rb +75 -0
- data/app/models/cms/layout.rb +99 -0
- data/app/models/cms/menu.rb +26 -0
- data/app/models/cms/menu_item.rb +14 -0
- data/app/models/cms/page.rb +202 -0
- data/app/models/cms/revision.rb +17 -0
- data/app/models/cms/site.rb +113 -0
- data/app/models/cms/snippet.rb +58 -0
- data/app/models/cms.rb +5 -0
- data/app/views/cms_admin/categories/_categories.html.haml +3 -0
- data/app/views/cms_admin/categories/_edit.html.haml +6 -0
- data/app/views/cms_admin/categories/_form.html.haml +8 -0
- data/app/views/cms_admin/categories/_index.html.haml +24 -0
- data/app/views/cms_admin/categories/_show.html.haml +13 -0
- data/app/views/cms_admin/categories/create.js.erb +7 -0
- data/app/views/cms_admin/categories/destroy.js.erb +3 -0
- data/app/views/cms_admin/categories/edit.js.erb +3 -0
- data/app/views/cms_admin/categories/update.js.erb +6 -0
- data/app/views/cms_admin/files/_file.html.haml +13 -0
- data/app/views/cms_admin/files/_form.html.haml +14 -0
- data/app/views/cms_admin/files/_index.html.haml +14 -0
- data/app/views/cms_admin/files/_page_form.html.haml +9 -0
- data/app/views/cms_admin/files/destroy.js.coffee +2 -0
- data/app/views/cms_admin/files/edit.html.haml +5 -0
- data/app/views/cms_admin/files/index.html.haml +28 -0
- data/app/views/cms_admin/files/new.html.haml +5 -0
- data/app/views/cms_admin/layouts/_form.html.haml +17 -0
- data/app/views/cms_admin/layouts/_index_branch.html.haml +23 -0
- data/app/views/cms_admin/layouts/edit.html.haml +9 -0
- data/app/views/cms_admin/layouts/index.html.haml +9 -0
- data/app/views/cms_admin/layouts/new.html.haml +5 -0
- data/app/views/cms_admin/menu_items/_form.html.haml +22 -0
- data/app/views/cms_admin/menu_items/edit.html.haml +8 -0
- data/app/views/cms_admin/menu_items/index.html.haml +24 -0
- data/app/views/cms_admin/menu_items/new.html.haml +5 -0
- data/app/views/cms_admin/menus/_form.html.haml +8 -0
- data/app/views/cms_admin/menus/edit.html.haml +8 -0
- data/app/views/cms_admin/menus/index.html.haml +24 -0
- data/app/views/cms_admin/menus/new.html.haml +5 -0
- data/app/views/cms_admin/pages/_form.html.haml +38 -0
- data/app/views/cms_admin/pages/_form_blocks.html.haml +28 -0
- data/app/views/cms_admin/pages/_index_branch.html.haml +35 -0
- data/app/views/cms_admin/pages/edit.html.haml +9 -0
- data/app/views/cms_admin/pages/form_blocks.js.erb +2 -0
- data/app/views/cms_admin/pages/index.html.haml +11 -0
- data/app/views/cms_admin/pages/new.html.haml +5 -0
- data/app/views/cms_admin/pages/toggle_branch.js.erb +11 -0
- data/app/views/cms_admin/revisions/show.html.haml +28 -0
- data/app/views/cms_admin/sites/_form.html.haml +14 -0
- data/app/views/cms_admin/sites/_mirrors.html.haml +17 -0
- data/app/views/cms_admin/sites/edit.html.haml +5 -0
- data/app/views/cms_admin/sites/index.html.haml +24 -0
- data/app/views/cms_admin/sites/new.html.haml +5 -0
- data/app/views/cms_admin/snippets/_form.html.haml +11 -0
- data/app/views/cms_admin/snippets/edit.html.haml +9 -0
- data/app/views/cms_admin/snippets/index.html.haml +28 -0
- data/app/views/cms_admin/snippets/new.html.haml +5 -0
- data/app/views/cms_content/_menu.html.haml +5 -0
- data/app/views/cms_content/render_sitemap.xml.builder +15 -0
- data/app/views/layouts/cms_admin/_body.html.haml +16 -0
- data/app/views/layouts/cms_admin/_center.html.haml +7 -0
- data/app/views/layouts/cms_admin/_footer.html.haml +3 -0
- data/app/views/layouts/cms_admin/_footer_js.html.haml +7 -0
- data/app/views/layouts/cms_admin/_head.html.haml +12 -0
- data/app/views/layouts/cms_admin/_left.html.haml +11 -0
- data/app/views/layouts/cms_admin/_right.html.haml +1 -0
- data/app/views/layouts/cms_admin.html.haml +4 -0
- data/comfypress.gemspec +28 -0
- data/config/application.rb +69 -0
- data/config/boot.rb +6 -0
- data/config/database.sqlite.yml +47 -0
- data/config/database.yml +47 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +39 -0
- data/config/environments/production.rb +67 -0
- data/config/environments/test.rb +39 -0
- data/config/initializers/comfypress.rb +100 -0
- data/config/initializers/paperclip.rb +3 -0
- data/config/locales/de.yml +236 -0
- data/config/locales/en.yml +285 -0
- data/config/locales/es.yml +236 -0
- data/config/locales/fr.yml +236 -0
- data/config/locales/ja.yml +237 -0
- data/config/locales/pl.yml +236 -0
- data/config/locales/pt-BR.yml +236 -0
- data/config/locales/ru.yml +236 -0
- data/config/locales/sv.yml +236 -0
- data/config/locales/zh-CN.yml +236 -0
- data/config/routes.rb +10 -0
- data/config.ru +4 -0
- data/db/cms_fixtures/sample-site/layouts/default/_default.yml +1 -0
- data/db/cms_fixtures/sample-site/layouts/default/content.html +5 -0
- data/db/cms_fixtures/sample-site/layouts/default/css.css +1 -0
- data/db/cms_fixtures/sample-site/layouts/default/js.js +1 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/_nested.yml +2 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/content.html +2 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/css.css +1 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/js.js +1 -0
- data/db/cms_fixtures/sample-site/pages/index/_index.yml +2 -0
- data/db/cms_fixtures/sample-site/pages/index/child/_child.yml +3 -0
- data/db/cms_fixtures/sample-site/pages/index/child/left.html +1 -0
- data/db/cms_fixtures/sample-site/pages/index/child/right.html +1 -0
- data/db/cms_fixtures/sample-site/pages/index/content.html +2 -0
- data/db/cms_fixtures/sample-site/snippets/default/_default.yml +1 -0
- data/db/cms_fixtures/sample-site/snippets/default/content.html +1 -0
- data/db/migrate/01_create_cms.rb +163 -0
- data/db/seeds.rb +9 -0
- data/db/upgrade_migrations/02_upgrade_to_1_1_0.rb +19 -0
- data/db/upgrade_migrations/03_upgrade_to_1_2_0.rb +15 -0
- data/db/upgrade_migrations/04_upgrade_to_1_3_0.rb +23 -0
- data/db/upgrade_migrations/05_upgrade_to_1_4_0.rb +33 -0
- data/db/upgrade_migrations/06_upgrade_to_1_5_0.rb +21 -0
- data/db/upgrade_migrations/07_upgrade_to_1_6_0.rb +25 -0
- data/doc/preview.png +0 -0
- data/doc/sofa.png +0 -0
- data/lib/comfypress/authentication/dummy_auth.rb +8 -0
- data/lib/comfypress/authentication/http_auth.rb +18 -0
- data/lib/comfypress/configuration.rb +99 -0
- data/lib/comfypress/engine.rb +18 -0
- data/lib/comfypress/error.rb +24 -0
- data/lib/comfypress/extensions/acts_as_tree.rb +102 -0
- data/lib/comfypress/extensions/has_revisions.rb +64 -0
- data/lib/comfypress/extensions/is_categorized.rb +49 -0
- data/lib/comfypress/extensions/is_mirrored.rb +85 -0
- data/lib/comfypress/extensions/rails.rb +24 -0
- data/lib/comfypress/fixtures.rb +289 -0
- data/lib/comfypress/form_builder.rb +97 -0
- data/lib/comfypress/render_methods.rb +85 -0
- data/lib/comfypress/routing.rb +62 -0
- data/lib/comfypress/sitemap.rb +27 -0
- data/lib/comfypress/tag.rb +154 -0
- data/lib/comfypress/tags/asset.rb +25 -0
- data/lib/comfypress/tags/collection.rb +64 -0
- data/lib/comfypress/tags/field_datetime.rb +17 -0
- data/lib/comfypress/tags/field_integer.rb +17 -0
- data/lib/comfypress/tags/field_rich_text.rb +17 -0
- data/lib/comfypress/tags/field_string.rb +17 -0
- data/lib/comfypress/tags/field_text.rb +17 -0
- data/lib/comfypress/tags/file.rb +29 -0
- data/lib/comfypress/tags/helper.rb +24 -0
- data/lib/comfypress/tags/menu.rb +27 -0
- data/lib/comfypress/tags/page_datetime.rb +13 -0
- data/lib/comfypress/tags/page_file.rb +51 -0
- data/lib/comfypress/tags/page_files.rb +52 -0
- data/lib/comfypress/tags/page_integer.rb +13 -0
- data/lib/comfypress/tags/page_markdown.rb +22 -0
- data/lib/comfypress/tags/page_rich_text.rb +13 -0
- data/lib/comfypress/tags/page_string.rb +13 -0
- data/lib/comfypress/tags/page_text.rb +13 -0
- data/lib/comfypress/tags/partial.rb +23 -0
- data/lib/comfypress/tags/snippet.rb +19 -0
- data/lib/comfypress/version.rb +3 -0
- data/lib/comfypress/view_hooks.rb +32 -0
- data/lib/comfypress/view_methods.rb +52 -0
- data/lib/comfypress.rb +66 -0
- data/lib/generators/comfy/cms/README +10 -0
- data/lib/generators/comfy/cms/cms_generator.rb +57 -0
- data/lib/tasks/comfypress.rake +45 -0
- data/script/rails +6 -0
- data/test/fixtures/cms/blocks.yml +12 -0
- data/test/fixtures/cms/categories.yml +4 -0
- data/test/fixtures/cms/categorizations.yml +3 -0
- data/test/fixtures/cms/files.yml +9 -0
- data/test/fixtures/cms/layouts.yml +40 -0
- data/test/fixtures/cms/menu_items.yml +15 -0
- data/test/fixtures/cms/menus.yml +9 -0
- data/test/fixtures/cms/pages.yml +39 -0
- data/test/fixtures/cms/revisions.yml +21 -0
- data/test/fixtures/cms/sites.yml +6 -0
- data/test/fixtures/cms/snippets.yml +6 -0
- data/test/fixtures/files/data.zip +0 -0
- data/test/fixtures/files/document.pdf +0 -0
- data/test/fixtures/files/image.gif +0 -0
- data/test/fixtures/files/image.jpg +0 -0
- data/test/fixtures/views/_nav_hook.html.erb +1 -0
- data/test/fixtures/views/_nav_hook_2.html.erb +1 -0
- data/test/fixtures/views/render_test/_test.html.erb +1 -0
- data/test/fixtures/views/render_test/new.html.erb +1 -0
- data/test/fixtures/views/render_test/render_layout.html.erb +1 -0
- data/test/functional/cms_admin/base_controller_test.rb +18 -0
- data/test/functional/cms_admin/categories_controller_test.rb +70 -0
- data/test/functional/cms_admin/files_controller_test.rb +216 -0
- data/test/functional/cms_admin/layouts_controller_test.rb +123 -0
- data/test/functional/cms_admin/pages_controller_test.rb +450 -0
- data/test/functional/cms_admin/revisions_controller_test.rb +138 -0
- data/test/functional/cms_admin/sites_controller_test.rb +105 -0
- data/test/functional/cms_admin/snippets_controller_test.rb +140 -0
- data/test/functional/cms_content_controller_test.rb +205 -0
- data/test/gemfiles/Gemfile.rails.3.1 +16 -0
- data/test/gemfiles/Gemfile.rails.3.2 +16 -0
- data/test/gemfiles/Gemfile.rails.4.0 +16 -0
- data/test/integration/authentication_test.rb +48 -0
- data/test/integration/fixtures_test.rb +61 -0
- data/test/integration/mirrors_test.rb +72 -0
- data/test/integration/render_cms_test.rb +233 -0
- data/test/integration/sites_test.rb +120 -0
- data/test/integration/view_hooks_test.rb +43 -0
- data/test/test_helper.rb +124 -0
- data/test/unit/cms/menu_item_test.rb +7 -0
- data/test/unit/cms/menu_test.rb +7 -0
- data/test/unit/configuration_test.rb +42 -0
- data/test/unit/fixtures_test.rb +357 -0
- data/test/unit/mirrors_test.rb +242 -0
- data/test/unit/models/block_test.rb +199 -0
- data/test/unit/models/categorization_test.rb +76 -0
- data/test/unit/models/category_test.rb +39 -0
- data/test/unit/models/file_test.rb +89 -0
- data/test/unit/models/layout_test.rb +125 -0
- data/test/unit/models/page_test.rb +255 -0
- data/test/unit/models/site_test.rb +152 -0
- data/test/unit/models/snippet_test.rb +49 -0
- data/test/unit/revisions_test.rb +185 -0
- data/test/unit/sitemap_test.rb +20 -0
- data/test/unit/tag_test.rb +308 -0
- data/test/unit/tags/asset_test.rb +56 -0
- data/test/unit/tags/collection_test.rb +116 -0
- data/test/unit/tags/field_datetime_test.rb +50 -0
- data/test/unit/tags/field_integer_test.rb +49 -0
- data/test/unit/tags/field_rich_text_test.rb +49 -0
- data/test/unit/tags/field_string_test.rb +52 -0
- data/test/unit/tags/field_text_test.rb +48 -0
- data/test/unit/tags/file_test.rb +67 -0
- data/test/unit/tags/helper_test.rb +86 -0
- data/test/unit/tags/page_datetime_test.rb +50 -0
- data/test/unit/tags/page_file_test.rb +119 -0
- data/test/unit/tags/page_files_test.rb +113 -0
- data/test/unit/tags/page_integer_test.rb +49 -0
- data/test/unit/tags/page_markdown_test.rb +48 -0
- data/test/unit/tags/page_rich_text_test.rb +49 -0
- data/test/unit/tags/page_string_test.rb +49 -0
- data/test/unit/tags/page_text_test.rb +52 -0
- data/test/unit/tags/partial_test.rb +76 -0
- data/test/unit/tags/snippet_test.rb +45 -0
- data/test/unit/view_methods_test.rb +80 -0
- metadata +457 -0
@@ -0,0 +1,357 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
4
|
+
|
5
|
+
class FixturesTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
def test_import_layouts_creating
|
8
|
+
Cms::Layout.delete_all
|
9
|
+
|
10
|
+
assert_difference 'Cms::Layout.count', 2 do
|
11
|
+
ComfyPress::Fixtures.import_layouts('default-site', 'sample-site')
|
12
|
+
|
13
|
+
assert layout = Cms::Layout.find_by_identifier('default')
|
14
|
+
assert_equal 'Default Fixture Layout', layout.label
|
15
|
+
assert_equal "<html>\n <body>\n {{ cms:page:content }}\n </body>\n</html>", layout.content
|
16
|
+
assert_equal 'body{color: red}', layout.css
|
17
|
+
assert_equal '// default js', layout.js
|
18
|
+
|
19
|
+
assert nested_layout = Cms::Layout.find_by_identifier('nested')
|
20
|
+
assert_equal layout, nested_layout.parent
|
21
|
+
assert_equal 'Default Fixture Nested Layout', nested_layout.label
|
22
|
+
assert_equal "<div class='left'> {{ cms:page:left }} </div>\n<div class='right'> {{ cms:page:right }} </div>", nested_layout.content
|
23
|
+
assert_equal 'div{float:left}', nested_layout.css
|
24
|
+
assert_equal '// nested js', nested_layout.js
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_import_layouts_updating_and_deleting
|
29
|
+
layout = cms_layouts(:default)
|
30
|
+
nested_layout = cms_layouts(:nested)
|
31
|
+
child_layout = cms_layouts(:child)
|
32
|
+
layout.update_column(:updated_at, 10.years.ago)
|
33
|
+
nested_layout.update_column(:updated_at, 10.years.ago)
|
34
|
+
child_layout.update_column(:updated_at, 10.years.ago)
|
35
|
+
|
36
|
+
assert_difference 'Cms::Layout.count', -1 do
|
37
|
+
ComfyPress::Fixtures.import_layouts('default-site', 'sample-site')
|
38
|
+
|
39
|
+
layout.reload
|
40
|
+
assert_equal 'Default Fixture Layout', layout.label
|
41
|
+
assert_equal "<html>\n <body>\n {{ cms:page:content }}\n </body>\n</html>", layout.content
|
42
|
+
assert_equal 'body{color: red}', layout.css
|
43
|
+
assert_equal '// default js', layout.js
|
44
|
+
assert_equal 0, layout.position
|
45
|
+
|
46
|
+
nested_layout.reload
|
47
|
+
assert_equal layout, nested_layout.parent
|
48
|
+
assert_equal 'Default Fixture Nested Layout', nested_layout.label
|
49
|
+
assert_equal "<div class='left'> {{ cms:page:left }} </div>\n<div class='right'> {{ cms:page:right }} </div>", nested_layout.content
|
50
|
+
assert_equal 'div{float:left}', nested_layout.css
|
51
|
+
assert_equal '// nested js', nested_layout.js
|
52
|
+
assert_equal 42, nested_layout.position
|
53
|
+
|
54
|
+
assert_nil Cms::Layout.find_by_identifier('child')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_import_layouts_ignoring
|
59
|
+
layout = cms_layouts(:default)
|
60
|
+
layout_path = File.join(ComfyPress.config.fixtures_path, 'sample-site', 'layouts', 'default')
|
61
|
+
attr_file_path = File.join(layout_path, '_default.yml')
|
62
|
+
content_file_path = File.join(layout_path, 'content.html')
|
63
|
+
css_file_path = File.join(layout_path, 'css.css')
|
64
|
+
js_file_path = File.join(layout_path, 'js.js')
|
65
|
+
|
66
|
+
assert layout.updated_at >= File.mtime(attr_file_path)
|
67
|
+
assert layout.updated_at >= File.mtime(content_file_path)
|
68
|
+
assert layout.updated_at >= File.mtime(css_file_path)
|
69
|
+
assert layout.updated_at >= File.mtime(js_file_path)
|
70
|
+
|
71
|
+
ComfyPress::Fixtures.import_layouts('default-site', 'sample-site')
|
72
|
+
layout.reload
|
73
|
+
assert_equal 'default', layout.identifier
|
74
|
+
assert_equal 'Default Layout', layout.label
|
75
|
+
assert_equal "{{cms:field:default_field_text:text}}\nlayout_content_a\n{{cms:page:default_page_text:text}}\nlayout_content_b\n{{cms:snippet:default}}\nlayout_content_c", layout.content
|
76
|
+
assert_equal 'default_css', layout.css
|
77
|
+
assert_equal 'default_js', layout.js
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_import_pages_creating
|
81
|
+
Cms::Page.delete_all
|
82
|
+
|
83
|
+
layout = cms_layouts(:default)
|
84
|
+
layout.update_column(:content, '<html>{{cms:page:content}}</html>')
|
85
|
+
|
86
|
+
nested = cms_layouts(:nested)
|
87
|
+
nested.update_column(:content, '<html>{{cms:page:left}}<br/>{{cms:page:right}}</html>')
|
88
|
+
|
89
|
+
assert_difference 'Cms::Page.count', 2 do
|
90
|
+
ComfyPress::Fixtures.import_pages('default-site', 'sample-site')
|
91
|
+
|
92
|
+
assert page = Cms::Page.find_by_full_path('/')
|
93
|
+
assert_equal layout, page.layout
|
94
|
+
assert_equal 'index', page.slug
|
95
|
+
assert_equal "<html>Home Page Fixture Contént\ndefault_snippet_content</html>", page.content
|
96
|
+
assert_equal 0, page.position
|
97
|
+
assert page.is_published?
|
98
|
+
|
99
|
+
assert child_page = Cms::Page.find_by_full_path('/child')
|
100
|
+
assert_equal page, child_page.parent
|
101
|
+
assert_equal nested, child_page.layout
|
102
|
+
assert_equal 'child', child_page.slug
|
103
|
+
assert_equal '<html>Child Page Left Fixture Content<br/>Child Page Right Fixture Content</html>', child_page.content
|
104
|
+
assert_equal 42, child_page.position
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_import_pages_updating_and_deleting
|
109
|
+
page = cms_pages(:default)
|
110
|
+
page.update_column(:updated_at, 10.years.ago)
|
111
|
+
assert_equal 'Default Page', page.label
|
112
|
+
|
113
|
+
child = cms_pages(:child)
|
114
|
+
child.update_column(:slug, 'old')
|
115
|
+
|
116
|
+
assert_no_difference 'Cms::Page.count' do
|
117
|
+
ComfyPress::Fixtures.import_pages('default-site', 'sample-site')
|
118
|
+
|
119
|
+
page.reload
|
120
|
+
assert_equal 'Home Fixture Page', page.label
|
121
|
+
|
122
|
+
assert_nil Cms::Page.find_by_slug('old')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_import_pages_ignoring
|
127
|
+
Cms::Page.destroy_all
|
128
|
+
|
129
|
+
page = cms_sites(:default).pages.create!(
|
130
|
+
:label => 'Test',
|
131
|
+
:layout => cms_layouts(:default),
|
132
|
+
:blocks_attributes => [ { :identifier => 'content', :content => 'test content' } ]
|
133
|
+
)
|
134
|
+
|
135
|
+
page_path = File.join(ComfyPress.config.fixtures_path, 'sample-site', 'pages', 'index')
|
136
|
+
attr_file_path = File.join(page_path, '_index.yml')
|
137
|
+
content_file_path = File.join(page_path, 'content.html')
|
138
|
+
|
139
|
+
assert page.updated_at >= File.mtime(attr_file_path)
|
140
|
+
assert page.updated_at >= File.mtime(content_file_path)
|
141
|
+
|
142
|
+
ComfyPress::Fixtures.import_pages('default-site', 'sample-site')
|
143
|
+
page.reload
|
144
|
+
|
145
|
+
assert_equal nil, page.slug
|
146
|
+
assert_equal 'Test', page.label
|
147
|
+
block = page.blocks.where(:identifier => 'content').first
|
148
|
+
assert_equal 'test content', block.content
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_import_pages_removing_deleted_blocks
|
152
|
+
Cms::Page.destroy_all
|
153
|
+
|
154
|
+
page = cms_sites(:default).pages.create!(
|
155
|
+
:label => 'Test',
|
156
|
+
:layout => cms_layouts(:default),
|
157
|
+
:blocks_attributes => [ { :identifier => 'to_delete', :content => 'test content' } ]
|
158
|
+
)
|
159
|
+
page.update_column(:updated_at, 10.years.ago)
|
160
|
+
|
161
|
+
ComfyPress::Fixtures.import_pages('default-site', 'sample-site')
|
162
|
+
page.reload
|
163
|
+
|
164
|
+
block = page.blocks.where(:identifier => 'content').first
|
165
|
+
assert_equal "Home Page Fixture Contént\n{{ cms:snippet:default }}", block.content
|
166
|
+
|
167
|
+
block = page.blocks.where(:identifier => 'to_delete').first
|
168
|
+
assert_equal nil, block.content
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_import_snippets_creating
|
172
|
+
Cms::Snippet.delete_all
|
173
|
+
|
174
|
+
assert_difference 'Cms::Snippet.count' do
|
175
|
+
ComfyPress::Fixtures.import_snippets('default-site', 'sample-site')
|
176
|
+
assert snippet = Cms::Snippet.last
|
177
|
+
assert_equal 'default', snippet.identifier
|
178
|
+
assert_equal 'Default Fixture Snippet', snippet.label
|
179
|
+
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_import_snippets_updating
|
184
|
+
snippet = cms_snippets(:default)
|
185
|
+
snippet.update_column(:updated_at, 10.years.ago)
|
186
|
+
assert_equal 'default', snippet.identifier
|
187
|
+
assert_equal 'Default Snippet', snippet.label
|
188
|
+
assert_equal 'default_snippet_content', snippet.content
|
189
|
+
|
190
|
+
assert_no_difference 'Cms::Snippet.count' do
|
191
|
+
ComfyPress::Fixtures.import_snippets('default-site', 'sample-site')
|
192
|
+
snippet.reload
|
193
|
+
assert_equal 'default', snippet.identifier
|
194
|
+
assert_equal 'Default Fixture Snippet', snippet.label
|
195
|
+
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_import_snippets_deleting
|
200
|
+
snippet = cms_snippets(:default)
|
201
|
+
snippet.update_column(:identifier, 'old')
|
202
|
+
|
203
|
+
assert_no_difference 'Cms::Snippet.count' do
|
204
|
+
ComfyPress::Fixtures.import_snippets('default-site', 'sample-site')
|
205
|
+
assert snippet = Cms::Snippet.last
|
206
|
+
assert_equal 'default', snippet.identifier
|
207
|
+
assert_equal 'Default Fixture Snippet', snippet.label
|
208
|
+
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
209
|
+
|
210
|
+
assert_nil Cms::Snippet.find_by_identifier('old')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_import_snippets_ignoring
|
215
|
+
snippet = cms_snippets(:default)
|
216
|
+
snippet_path = File.join(ComfyPress.config.fixtures_path, 'sample-site', 'snippets', 'default')
|
217
|
+
attr_file_path = File.join(snippet_path, '_default.yml')
|
218
|
+
content_file_path = File.join(snippet_path, 'content.html')
|
219
|
+
|
220
|
+
assert snippet.updated_at >= File.mtime(attr_file_path)
|
221
|
+
assert snippet.updated_at >= File.mtime(content_file_path)
|
222
|
+
|
223
|
+
ComfyPress::Fixtures.import_snippets('default-site', 'sample-site')
|
224
|
+
snippet.reload
|
225
|
+
assert_equal 'default', snippet.identifier
|
226
|
+
assert_equal 'Default Snippet', snippet.label
|
227
|
+
assert_equal 'default_snippet_content', snippet.content
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_import_all
|
231
|
+
Cms::Page.destroy_all
|
232
|
+
Cms::Layout.destroy_all
|
233
|
+
Cms::Snippet.destroy_all
|
234
|
+
|
235
|
+
assert_difference 'Cms::Layout.count', 2 do
|
236
|
+
assert_difference 'Cms::Page.count', 2 do
|
237
|
+
assert_difference 'Cms::Snippet.count', 1 do
|
238
|
+
ComfyPress::Fixtures.import_all('default-site', 'sample-site')
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_import_all_with_no_site
|
245
|
+
cms_sites(:default).destroy
|
246
|
+
|
247
|
+
assert_difference 'Cms::Site.count', 1 do
|
248
|
+
assert_difference 'Cms::Layout.count', 2 do
|
249
|
+
assert_difference 'Cms::Page.count', 2 do
|
250
|
+
assert_difference 'Cms::Snippet.count', 1 do
|
251
|
+
ComfyPress::Fixtures.import_all('default-site', 'sample-site')
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_export_layouts
|
259
|
+
host_path = File.join(ComfyPress.config.fixtures_path, 'test-site')
|
260
|
+
layout_1_attr_path = File.join(host_path, 'layouts/nested/_nested.yml')
|
261
|
+
layout_1_content_path = File.join(host_path, 'layouts/nested/content.html')
|
262
|
+
layout_1_css_path = File.join(host_path, 'layouts/nested/css.css')
|
263
|
+
layout_1_js_path = File.join(host_path, 'layouts/nested/js.js')
|
264
|
+
layout_2_attr_path = File.join(host_path, 'layouts/nested/child/_child.yml')
|
265
|
+
layout_2_content_path = File.join(host_path, 'layouts/nested/child/content.html')
|
266
|
+
layout_2_css_path = File.join(host_path, 'layouts/nested/child/css.css')
|
267
|
+
layout_2_js_path = File.join(host_path, 'layouts/nested/child/js.js')
|
268
|
+
|
269
|
+
ComfyPress::Fixtures.export_layouts('default-site', 'test-site')
|
270
|
+
|
271
|
+
assert File.exists?(layout_1_attr_path)
|
272
|
+
assert File.exists?(layout_1_content_path)
|
273
|
+
assert File.exists?(layout_1_css_path)
|
274
|
+
assert File.exists?(layout_1_js_path)
|
275
|
+
|
276
|
+
assert File.exists?(layout_2_attr_path)
|
277
|
+
assert File.exists?(layout_2_content_path)
|
278
|
+
assert File.exists?(layout_2_css_path)
|
279
|
+
assert File.exists?(layout_2_js_path)
|
280
|
+
|
281
|
+
assert_equal ({
|
282
|
+
'label' => 'Nested Layout',
|
283
|
+
'app_layout' => nil,
|
284
|
+
'parent' => nil,
|
285
|
+
'position' => 0
|
286
|
+
}), YAML.load_file(layout_1_attr_path)
|
287
|
+
assert_equal cms_layouts(:nested).content, IO.read(layout_1_content_path)
|
288
|
+
assert_equal cms_layouts(:nested).css, IO.read(layout_1_css_path)
|
289
|
+
assert_equal cms_layouts(:nested).js, IO.read(layout_1_js_path)
|
290
|
+
|
291
|
+
assert_equal ({
|
292
|
+
'label' => 'Child Layout',
|
293
|
+
'app_layout' => nil,
|
294
|
+
'parent' => 'nested',
|
295
|
+
'position' => 0
|
296
|
+
}), YAML.load_file(layout_2_attr_path)
|
297
|
+
assert_equal cms_layouts(:child).content, IO.read(layout_2_content_path)
|
298
|
+
assert_equal cms_layouts(:child).css, IO.read(layout_2_css_path)
|
299
|
+
assert_equal cms_layouts(:child).js, IO.read(layout_2_js_path)
|
300
|
+
|
301
|
+
FileUtils.rm_rf(host_path)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_export_pages
|
305
|
+
host_path = File.join(ComfyPress.config.fixtures_path, 'test-site')
|
306
|
+
page_1_attr_path = File.join(host_path, 'pages/index/_index.yml')
|
307
|
+
page_1_block_a_path = File.join(host_path, 'pages/index/default_field_text.html')
|
308
|
+
page_1_block_b_path = File.join(host_path, 'pages/index/default_page_text.html')
|
309
|
+
page_2_attr_path = File.join(host_path, 'pages/index/child-page/_child-page.yml')
|
310
|
+
|
311
|
+
ComfyPress::Fixtures.export_pages('default-site', 'test-site')
|
312
|
+
|
313
|
+
assert_equal ({
|
314
|
+
'label' => 'Default Page',
|
315
|
+
'layout' => 'default',
|
316
|
+
'parent' => nil,
|
317
|
+
'target_page' => nil,
|
318
|
+
'is_published' => true,
|
319
|
+
'position' => 0
|
320
|
+
}), YAML.load_file(page_1_attr_path)
|
321
|
+
assert_equal cms_blocks(:default_field_text).content, IO.read(page_1_block_a_path)
|
322
|
+
assert_equal cms_blocks(:default_page_text).content, IO.read(page_1_block_b_path)
|
323
|
+
|
324
|
+
assert_equal ({
|
325
|
+
'label' => 'Child Page',
|
326
|
+
'layout' => 'default',
|
327
|
+
'parent' => 'index',
|
328
|
+
'target_page' => nil,
|
329
|
+
'is_published' => true,
|
330
|
+
'position' => 0
|
331
|
+
}), YAML.load_file(page_2_attr_path)
|
332
|
+
|
333
|
+
FileUtils.rm_rf(host_path)
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_export_snippets
|
337
|
+
host_path = File.join(ComfyPress.config.fixtures_path, 'test-site')
|
338
|
+
attr_path = File.join(host_path, 'snippets/default/_default.yml')
|
339
|
+
content_path = File.join(host_path, 'snippets/default/content.html')
|
340
|
+
|
341
|
+
ComfyPress::Fixtures.export_snippets('default-site', 'test-site')
|
342
|
+
|
343
|
+
assert File.exists?(attr_path)
|
344
|
+
assert File.exists?(content_path)
|
345
|
+
assert_equal ({'label' => 'Default Snippet'}), YAML.load_file(attr_path)
|
346
|
+
assert_equal cms_snippets(:default).content, IO.read(content_path)
|
347
|
+
|
348
|
+
FileUtils.rm_rf(host_path)
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_export_all
|
352
|
+
host_path = File.join(ComfyPress.config.fixtures_path, 'test-site')
|
353
|
+
ComfyPress::Fixtures.export_all('default-site', 'test-site')
|
354
|
+
FileUtils.rm_rf(host_path)
|
355
|
+
end
|
356
|
+
|
357
|
+
end
|
@@ -0,0 +1,242 @@
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class MirrorsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_layout_creation
|
6
|
+
setup_sites
|
7
|
+
assert_difference 'Cms::Layout.count', 2 do
|
8
|
+
layout = @site_a.layouts.create!(:identifier => 'test')
|
9
|
+
assert_equal 1, layout.mirrors.size
|
10
|
+
assert_equal 'test', layout.mirrors.first.identifier
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_page_creation
|
15
|
+
setup_sites
|
16
|
+
layout = @site_a.layouts.create!(:identifier => 'test')
|
17
|
+
|
18
|
+
assert_difference 'Cms::Page.count', 2 do
|
19
|
+
page = @site_a.pages.create!(
|
20
|
+
:layout => layout,
|
21
|
+
:label => 'Root'
|
22
|
+
)
|
23
|
+
assert_equal 1, page.mirrors.size
|
24
|
+
assert_equal '/', page.mirrors.first.full_path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_snippet_creation
|
29
|
+
setup_sites
|
30
|
+
assert_difference 'Cms::Snippet.count', 2 do
|
31
|
+
snippet = @site_a.snippets.create(:identifier => 'test')
|
32
|
+
assert_equal 1, snippet.mirrors.size
|
33
|
+
assert_equal 'test', snippet.mirrors.first.identifier
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_layout_update
|
38
|
+
setup_sites
|
39
|
+
layout_1a = @site_a.layouts.create!(:identifier => 'test_a')
|
40
|
+
layout_1b = @site_a.layouts.create!(:identifier => 'test_b')
|
41
|
+
layout_1c = @site_a.layouts.create!(:identifier => 'nested', :parent => layout_1a)
|
42
|
+
|
43
|
+
assert layout_2a = layout_1a.mirrors.first
|
44
|
+
assert layout_2b = layout_1b.mirrors.first
|
45
|
+
assert layout_2c = layout_1c.mirrors.first
|
46
|
+
assert_equal layout_2a, layout_2c.parent
|
47
|
+
|
48
|
+
layout_1c.update_attributes!(
|
49
|
+
:identifier => 'updated',
|
50
|
+
:parent => layout_1b,
|
51
|
+
:content => 'updated content'
|
52
|
+
)
|
53
|
+
layout_2c.reload
|
54
|
+
assert_equal 'updated', layout_2c.identifier
|
55
|
+
assert_equal layout_2b, layout_2c.parent
|
56
|
+
assert_not_equal 'updated content', layout_2c
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_page_update
|
60
|
+
setup_sites
|
61
|
+
layout_1a = @site_a.layouts.create!(:identifier => 'test_a')
|
62
|
+
layout_1b = @site_a.layouts.create!(:identifier => 'test_b')
|
63
|
+
|
64
|
+
page_1r = @site_a.pages.create!(:slug => 'root', :layout => layout_1a)
|
65
|
+
page_1a = @site_a.pages.create!(:slug => 'test_a', :layout => layout_1a)
|
66
|
+
page_1b = @site_a.pages.create!(:slug => 'test_b', :layout => layout_1a)
|
67
|
+
assert_equal page_1r, page_1b.parent
|
68
|
+
|
69
|
+
assert layout_2b = layout_1b.mirrors.first
|
70
|
+
assert page_2a = page_1a.mirrors.first
|
71
|
+
assert page_2b = page_1b.mirrors.first
|
72
|
+
|
73
|
+
page_1b.update_attributes!(
|
74
|
+
:slug => 'updated',
|
75
|
+
:parent => page_1a,
|
76
|
+
:layout => layout_1b
|
77
|
+
)
|
78
|
+
page_2b.reload
|
79
|
+
assert_equal 'updated', page_2b.slug
|
80
|
+
assert_equal page_2a, page_2b.parent
|
81
|
+
assert_equal '/test_a/updated', page_2b.full_path
|
82
|
+
assert_equal layout_2b, page_2b.layout
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_snippet_update
|
86
|
+
setup_sites
|
87
|
+
snippet_1 = @site_a.snippets.create(:identifier => 'test')
|
88
|
+
assert snippet_2 = snippet_1.mirrors.first
|
89
|
+
snippet_1.update_attributes!(
|
90
|
+
:identifier => 'updated',
|
91
|
+
:content => 'updated content'
|
92
|
+
)
|
93
|
+
snippet_2.reload
|
94
|
+
assert_equal 'updated', snippet_2.identifier
|
95
|
+
assert_not_equal 'updated content', snippet_2.content
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_layout_destroy
|
99
|
+
setup_sites
|
100
|
+
layout_1a = @site_a.layouts.create!(:identifier => 'test_a')
|
101
|
+
layout_1b = @site_a.layouts.create!(:identifier => 'test_b')
|
102
|
+
layout_1c = @site_a.layouts.create!(:identifier => 'nested', :parent => layout_1b)
|
103
|
+
|
104
|
+
assert layout_2a = layout_1a.mirrors.first
|
105
|
+
assert layout_2b = layout_1b.mirrors.first
|
106
|
+
assert layout_2c = layout_1c.mirrors.first
|
107
|
+
|
108
|
+
assert_difference ['@site_a.layouts.count', '@site_b.layouts.count'], -1 do
|
109
|
+
layout_1a.destroy
|
110
|
+
assert_nil Cms::Layout.find_by_id(layout_2a.id)
|
111
|
+
end
|
112
|
+
|
113
|
+
assert_difference ['@site_a.layouts.count', '@site_b.layouts.count'], -2 do
|
114
|
+
layout_1b.destroy
|
115
|
+
assert_nil Cms::Layout.find_by_id(layout_2b.id)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_page_destroy
|
120
|
+
setup_sites
|
121
|
+
layout = @site_a.layouts.create!(:identifier => 'test')
|
122
|
+
page_1r = @site_a.pages.create!(:slug => 'root', :layout => layout)
|
123
|
+
page_1a = @site_a.pages.create!(:slug => 'test_a', :layout => layout)
|
124
|
+
page_1b = @site_a.pages.create!(:slug => 'test_b', :layout => layout)
|
125
|
+
|
126
|
+
assert page_2r = page_1r.mirrors.first
|
127
|
+
assert page_2a = page_1a.mirrors.first
|
128
|
+
assert page_2b = page_1b.mirrors.first
|
129
|
+
|
130
|
+
assert_difference ['@site_a.pages.count', '@site_b.pages.count'], -1 do
|
131
|
+
page_1a.destroy
|
132
|
+
assert_nil Cms::Page.find_by_id(page_2a.id)
|
133
|
+
end
|
134
|
+
|
135
|
+
assert_difference ['@site_a.pages.count', '@site_b.pages.count'], -2 do
|
136
|
+
page_1r.destroy
|
137
|
+
assert_nil Cms::Page.find_by_id(page_2r.id)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_snippet_destroy
|
142
|
+
setup_sites
|
143
|
+
snippet_1 = @site_a.snippets.create(:identifier => 'test')
|
144
|
+
assert snippet_2 = snippet_1.mirrors.first
|
145
|
+
|
146
|
+
assert_difference ['@site_a.snippets.count', '@site_b.snippets.count'], -1 do
|
147
|
+
snippet_1.destroy
|
148
|
+
assert_nil Cms::Snippet.find_by_id(snippet_2.id)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_site_creation_as_mirror
|
153
|
+
site = cms_sites(:default)
|
154
|
+
Cms::Site.update_all(:is_mirrored => true) # bypassing callbacks
|
155
|
+
|
156
|
+
assert_difference 'Cms::Site.count' do
|
157
|
+
assert_difference 'Cms::Layout.count', site.layouts.count do
|
158
|
+
assert_difference 'Cms::Page.count', site.pages.count do
|
159
|
+
assert_difference 'Cms::Snippet.count', site.snippets.count do
|
160
|
+
mirror = Cms::Site.create!(
|
161
|
+
:identifier => 'mirror',
|
162
|
+
:hostname => 'mirror.host',
|
163
|
+
:is_mirrored => true
|
164
|
+
)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_site_update_to_mirror
|
172
|
+
site = cms_sites(:default)
|
173
|
+
Cms::Site.update_all(:is_mirrored => true) # bypassing callbacks
|
174
|
+
|
175
|
+
mirror = Cms::Site.create!(
|
176
|
+
:identifier => 'mirror',
|
177
|
+
:hostname => 'mirror.host'
|
178
|
+
)
|
179
|
+
layout = mirror.layouts.create!(
|
180
|
+
:identifier => 'mirror_layout'
|
181
|
+
)
|
182
|
+
home_page = mirror.pages.create!(
|
183
|
+
:label => 'mirror home',
|
184
|
+
:layout => layout
|
185
|
+
)
|
186
|
+
child_page = mirror.pages.create!(
|
187
|
+
:label => 'mirror child',
|
188
|
+
:layout => layout,
|
189
|
+
:slug => 'mirror-child',
|
190
|
+
:parent => home_page
|
191
|
+
)
|
192
|
+
snippet = mirror.snippets.create!(
|
193
|
+
:identifier => 'mirror_snippet'
|
194
|
+
)
|
195
|
+
|
196
|
+
assert_difference ['site.layouts.count', 'site.pages.count', 'site.snippets.count'], 1 do
|
197
|
+
assert_difference 'mirror.layouts.count', 3 do
|
198
|
+
assert_difference 'mirror.pages.count', 1 do
|
199
|
+
assert_difference 'mirror.snippets.count', 1 do
|
200
|
+
|
201
|
+
mirror.update_attributes(:is_mirrored => true)
|
202
|
+
|
203
|
+
site.reload
|
204
|
+
assert site.layouts.where(:identifier => 'mirror_layout').present?
|
205
|
+
assert site.pages.where(:slug => 'mirror-child').present?
|
206
|
+
assert site.snippets.where(:identifier => 'mirror_snippet').present?
|
207
|
+
|
208
|
+
mirror.reload
|
209
|
+
assert mirror.layouts.where(:identifier => 'default').present?
|
210
|
+
assert mirror.pages.where(:slug => 'child-page').present?
|
211
|
+
assert mirror.snippets.where(:identifier => 'default').present?
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_site_destruction
|
219
|
+
site = cms_sites(:default)
|
220
|
+
Cms::Site.update_all(:is_mirrored => true) # bypassing callbacks
|
221
|
+
|
222
|
+
mirror = Cms::Site.create!(
|
223
|
+
:identifier => 'mirror',
|
224
|
+
:hostname => 'mirror.host',
|
225
|
+
:is_mirrored => true
|
226
|
+
)
|
227
|
+
mirror.reload
|
228
|
+
assert_no_difference ['site.layouts.count', 'site.pages.count', 'site.snippets.count'] do
|
229
|
+
mirror.destroy
|
230
|
+
site.reload
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
protected
|
235
|
+
|
236
|
+
def setup_sites
|
237
|
+
Cms::Site.delete_all
|
238
|
+
@site_a = Cms::Site.create!(:identifier => 'site_a', :hostname => 'site-a.host', :is_mirrored => true)
|
239
|
+
@site_b = Cms::Site.create!(:identifier => 'site_b', :hostname => 'site-b.host', :is_mirrored => true)
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|