comfortable_mexican_sofa 2.0.9 → 2.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/comfy/vendor/bootstrap.min.js +3 -3
- data/app/assets/stylesheets/comfy/admin/cms/application.sass +1 -2
- data/app/assets/stylesheets/comfy/admin/cms/base.sass +12 -13
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_alert.scss +3 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_button-group.scss +31 -72
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_buttons.scss +26 -19
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_card.scss +23 -12
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_carousel.scss +2 -2
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_close.scss +6 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_code.scss +4 -12
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_custom-forms.scss +124 -84
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_dropdown.scss +30 -2
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_forms.scss +46 -71
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_functions.scss +4 -4
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_images.scss +0 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_input-group.scss +99 -126
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_list-group.scss +2 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_modal.scss +24 -9
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_nav.scss +2 -2
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_navbar.scss +8 -3
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_pagination.scss +32 -19
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_popover.scss +106 -117
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_print.scss +17 -3
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_progress.scss +4 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_reboot.scss +3 -25
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_tables.scss +1 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_tooltip.scss +65 -57
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_type.scss +2 -2
- data/app/assets/stylesheets/comfy/vendor/bootstrap/_variables.scss +174 -108
- data/app/assets/stylesheets/comfy/vendor/bootstrap/bootstrap-grid.scss +32 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/bootstrap-reboot.scss +12 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/bootstrap.scss +42 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_background-variant.scss +2 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_breakpoints.scss +11 -7
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_buttons.scss +37 -22
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_caret.scss +30 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_forms.scss +48 -19
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_grid-framework.scss +5 -7
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_hover.scss +24 -46
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_list-group.scss +10 -13
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_screen-reader.scss +1 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/mixins/_text-hide.scss +1 -0
- data/app/assets/stylesheets/comfy/vendor/bootstrap/utilities/_borders.scss +6 -1
- data/app/assets/stylesheets/comfy/vendor/bootstrap/utilities/_display.scss +10 -28
- data/app/controllers/comfy/admin/cms/files_controller.rb +6 -7
- data/app/helpers/comfy/admin/cms_helper.rb +5 -4
- data/app/models/concerns/comfy/cms/with_categories.rb +20 -9
- data/app/views/comfy/admin/cms/categories/_edit.html.haml +3 -3
- data/app/views/comfy/admin/cms/categories/_form.html.haml +3 -9
- data/app/views/comfy/admin/cms/categories/_index.html.haml +2 -2
- data/app/views/comfy/admin/cms/categories/_show.html.haml +4 -3
- data/app/views/comfy/admin/cms/categories/create.js.erb +1 -1
- data/app/views/comfy/admin/cms/files/_form.html.haml +11 -12
- data/app/views/comfy/admin/cms/files/edit.html.haml +2 -2
- data/app/views/comfy/admin/cms/files/new.html.haml +2 -2
- data/app/views/comfy/admin/cms/fragments/_form_fragment_attachments.html.haml +7 -5
- data/app/views/comfy/admin/cms/fragments/_form_fragments.html.haml +1 -1
- data/app/views/comfy/admin/cms/layouts/_form.html.haml +3 -2
- data/app/views/comfy/admin/cms/layouts/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/layouts/new.html.haml +2 -2
- data/app/views/comfy/admin/cms/pages/_form.html.haml +3 -5
- data/app/views/comfy/admin/cms/pages/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/pages/new.html.haml +1 -1
- data/app/views/comfy/admin/cms/revisions/show.html.haml +2 -2
- data/app/views/comfy/admin/cms/sites/_form.html.haml +4 -4
- data/app/views/comfy/admin/cms/sites/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/sites/new.html.haml +2 -2
- data/app/views/comfy/admin/cms/snippets/_form.html.haml +2 -2
- data/app/views/comfy/admin/cms/snippets/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/snippets/new.html.haml +2 -2
- data/app/views/comfy/admin/cms/translations/_form.html.haml +5 -7
- data/app/views/comfy/admin/cms/translations/edit.html.haml +1 -1
- data/app/views/comfy/admin/cms/translations/new.html.haml +2 -2
- data/comfortable_mexican_sofa.gemspec +6 -3
- data/config/locales/fr.yml +33 -33
- data/lib/comfortable_mexican_sofa/content/tags/file.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/files.rb +1 -1
- data/lib/comfortable_mexican_sofa/form_builder.rb +10 -15
- data/lib/comfortable_mexican_sofa/seeds.rb +2 -5
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- metadata +9 -116
- data/app/assets/stylesheets/comfy/vendor/_bootstrap.scss +0 -42
- data/doc/preview.jpg +0 -0
- data/test/controllers/comfy/admin/cms/base_controller_test.rb +0 -18
- data/test/controllers/comfy/admin/cms/categories_controller_test.rb +0 -74
- data/test/controllers/comfy/admin/cms/files_controller_test.rb +0 -242
- data/test/controllers/comfy/admin/cms/layouts_controller_test.rb +0 -137
- data/test/controllers/comfy/admin/cms/pages_controller_test.rb +0 -580
- data/test/controllers/comfy/admin/cms/revisions/layout_controller_test.rb +0 -62
- data/test/controllers/comfy/admin/cms/revisions/page_controller_test.rb +0 -87
- data/test/controllers/comfy/admin/cms/revisions/snippet_controller_test.rb +0 -60
- data/test/controllers/comfy/admin/cms/revisions/translation_controller_test.rb +0 -68
- data/test/controllers/comfy/admin/cms/sites_controller_test.rb +0 -106
- data/test/controllers/comfy/admin/cms/snippets_controller_test.rb +0 -156
- data/test/controllers/comfy/admin/cms/translations_controller_test.rb +0 -182
- data/test/controllers/comfy/cms/assets_controller_test.rb +0 -61
- data/test/controllers/comfy/cms/content_controller_test.rb +0 -249
- data/test/fixtures/active_storage/attachments.yml +0 -9
- data/test/fixtures/active_storage/blobs.yml +0 -13
- data/test/fixtures/comfy/cms/categories.yml +0 -4
- data/test/fixtures/comfy/cms/categorizations.yml +0 -3
- data/test/fixtures/comfy/cms/files.yml +0 -5
- data/test/fixtures/comfy/cms/fragments.yml +0 -25
- data/test/fixtures/comfy/cms/layouts.yml +0 -34
- data/test/fixtures/comfy/cms/pages.yml +0 -24
- data/test/fixtures/comfy/cms/revisions.yml +0 -29
- data/test/fixtures/comfy/cms/sites.yml +0 -5
- data/test/fixtures/comfy/cms/snippets.yml +0 -6
- data/test/fixtures/comfy/cms/translations.yml +0 -7
- 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/generators/cms/application.rb +0 -7
- data/test/fixtures/generators/cms/routes.rb +0 -5
- data/test/fixtures/generators/scaffold/controller.rb +0 -62
- data/test/fixtures/generators/scaffold/migration.rb +0 -9
- data/test/fixtures/generators/scaffold/model.rb +0 -21
- data/test/fixtures/generators/scaffold/routes.rb +0 -6
- data/test/fixtures/generators/scaffold/tests/controller.rb +0 -111
- data/test/fixtures/generators/scaffold/tests/fixture +0 -2
- data/test/fixtures/generators/scaffold/tests/model.rb +0 -24
- data/test/fixtures/generators/scaffold/views/_form.haml +0 -5
- data/test/fixtures/generators/scaffold/views/edit.haml +0 -5
- data/test/fixtures/generators/scaffold/views/index.haml +0 -21
- data/test/fixtures/generators/scaffold/views/new.haml +0 -5
- data/test/fixtures/generators/scaffold/views/show.haml +0 -4
- data/test/fixtures/views/_nav_hook.html.erb +0 -1
- data/test/fixtures/views/_nav_hook_2.html.erb +0 -1
- data/test/fixtures/views/render_test/_test.html.erb +0 -1
- data/test/fixtures/views/render_test/new.html.erb +0 -1
- data/test/fixtures/views/render_test/render_layout.html.erb +0 -1
- data/test/gemfiles/5.2.gemfile +0 -19
- data/test/generators/cms_assets_generator_test.rb +0 -14
- data/test/generators/cms_controllers_generator_test.rb +0 -14
- data/test/generators/cms_generator_test.rb +0 -26
- data/test/generators/cms_models_generator_test.rb +0 -14
- data/test/generators/cms_views_generator_test.rb +0 -14
- data/test/generators/scaffold_generator_test.rb +0 -32
- data/test/helpers/cms_helper_test.rb +0 -106
- data/test/integration/access_control_test.rb +0 -179
- data/test/integration/i18n_test.rb +0 -38
- data/test/integration/meta_variables_test.rb +0 -27
- data/test/integration/render_cms_test.rb +0 -255
- data/test/integration/routing_test.rb +0 -19
- data/test/integration/seeds_test.rb +0 -75
- data/test/integration/sites_test.rb +0 -107
- data/test/integration/view_hooks_test.rb +0 -47
- data/test/lib/configuration_test.rb +0 -38
- data/test/lib/content/block_test.rb +0 -26
- data/test/lib/content/params_parser_test.rb +0 -126
- data/test/lib/content/renderer_test.rb +0 -276
- data/test/lib/content/tag_test.rb +0 -58
- data/test/lib/content/tags/asset_test.rb +0 -104
- data/test/lib/content/tags/checkbox_test.rb +0 -21
- data/test/lib/content/tags/date_test.rb +0 -21
- data/test/lib/content/tags/datetime_test.rb +0 -21
- data/test/lib/content/tags/file_link_test.rb +0 -91
- data/test/lib/content/tags/file_test.rb +0 -69
- data/test/lib/content/tags/files_test.rb +0 -52
- data/test/lib/content/tags/fragment_test.rb +0 -68
- data/test/lib/content/tags/helper_test.rb +0 -62
- data/test/lib/content/tags/markdown_test.rb +0 -37
- data/test/lib/content/tags/number_test.rb +0 -14
- data/test/lib/content/tags/partial_test.rb +0 -65
- data/test/lib/content/tags/snippet_test.rb +0 -37
- data/test/lib/content/tags/template_test.rb +0 -51
- data/test/lib/content/tags/text_test.rb +0 -14
- data/test/lib/content/tags/textarea_test.rb +0 -14
- data/test/lib/content/tags/wysiwyg_test.rb +0 -14
- data/test/lib/revisions_test.rb +0 -222
- data/test/lib/seeds/files_test.rb +0 -97
- data/test/lib/seeds/layouts_test.rb +0 -156
- data/test/lib/seeds/pages_test.rb +0 -230
- data/test/lib/seeds/snippets_test.rb +0 -99
- data/test/lib/seeds_test.rb +0 -51
- data/test/models/categorization_test.rb +0 -76
- data/test/models/category_test.rb +0 -39
- data/test/models/file_test.rb +0 -43
- data/test/models/fragment_test.rb +0 -132
- data/test/models/layout_test.rb +0 -194
- data/test/models/page_test.rb +0 -575
- data/test/models/site_test.rb +0 -190
- data/test/models/snippet_test.rb +0 -56
- data/test/models/translation_test.rb +0 -67
- data/test/system/layouts_frontend_test.rb +0 -15
- data/test/system/pages_frontend_test.rb +0 -15
- data/test/system/sites_frontend_test.rb +0 -11
- data/test/system/snippets_frontend_test.rb +0 -15
- data/test/tasks/cms_seeds_test.rb +0 -34
- data/test/test_helper.rb +0 -201
@@ -1,97 +0,0 @@
|
|
1
|
-
require_relative "../../test_helper"
|
2
|
-
|
3
|
-
class SeedsFilesTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_creation
|
10
|
-
Comfy::Cms::File.delete_all
|
11
|
-
|
12
|
-
assert_count_difference [Comfy::Cms::File] do
|
13
|
-
ComfortableMexicanSofa::Seeds::File::Importer.new("sample-site", "default-site").import!
|
14
|
-
end
|
15
|
-
|
16
|
-
assert file = Comfy::Cms::File.last
|
17
|
-
|
18
|
-
assert_equal "Seed File", file.label
|
19
|
-
assert_equal "default.jpg", file.attachment.filename.to_s
|
20
|
-
assert_equal "image/jpeg", file.attachment.content_type
|
21
|
-
assert_equal "Seed File Description", file.description
|
22
|
-
|
23
|
-
assert_equal 2, file.categories.count
|
24
|
-
assert_equal %w[category_a category_b], file.categories.map(&:label)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_update
|
28
|
-
file = comfy_cms_files(:default)
|
29
|
-
file.update_column(:updated_at, 10.years.ago)
|
30
|
-
assert_equal "default.jpg", file.attachment.filename.to_s
|
31
|
-
assert_equal "default file", file.label
|
32
|
-
assert_equal "default description", file.description
|
33
|
-
|
34
|
-
assert_count_no_difference [Comfy::Cms::File] do
|
35
|
-
ComfortableMexicanSofa::Seeds::File::Importer.new("sample-site", "default-site").import!
|
36
|
-
file.reload
|
37
|
-
assert_equal "default.jpg", file.attachment.filename.to_s
|
38
|
-
assert_equal "Seed File", file.label
|
39
|
-
assert_equal "Seed File Description", file.description
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_update_ignore
|
44
|
-
file = comfy_cms_files(:default)
|
45
|
-
file_path = File.join(ComfortableMexicanSofa.config.seeds_path, "sample-site", "files", "default.jpg")
|
46
|
-
attr_path = File.join(ComfortableMexicanSofa.config.seeds_path, "sample-site", "files", "_default.jpg.yml")
|
47
|
-
|
48
|
-
assert file.updated_at >= File.mtime(file_path)
|
49
|
-
assert file.updated_at >= File.mtime(attr_path)
|
50
|
-
|
51
|
-
ComfortableMexicanSofa::Seeds::File::Importer.new("sample-site", "default-site").import!
|
52
|
-
file.reload
|
53
|
-
assert_equal "default.jpg", file.attachment.filename.to_s
|
54
|
-
assert_equal "default file", file.label
|
55
|
-
assert_equal "default description", file.description
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_delete
|
59
|
-
old_file = comfy_cms_files(:default)
|
60
|
-
active_storage_blobs(:default).update_column(:filename, "old")
|
61
|
-
|
62
|
-
assert_count_no_difference [Comfy::Cms::File] do
|
63
|
-
ComfortableMexicanSofa::Seeds::File::Importer.new("sample-site", "default-site").import!
|
64
|
-
assert file = Comfy::Cms::File.last
|
65
|
-
assert_equal "default.jpg", file.attachment.filename.to_s
|
66
|
-
assert_equal "Seed File", file.label
|
67
|
-
assert_equal "Seed File Description", file.description
|
68
|
-
|
69
|
-
assert Comfy::Cms::File.where(id: old_file.id).blank?
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_export
|
74
|
-
host_path = File.join(ComfortableMexicanSofa.config.seeds_path, "test-site")
|
75
|
-
attr_path = File.join(host_path, "files/_default.jpg.yml")
|
76
|
-
file_path = File.join(host_path, "files/default.jpg")
|
77
|
-
|
78
|
-
# We don't have saved file, so lets fake that
|
79
|
-
ActiveStorage::Blob.any_instance.stubs(:download).returns(
|
80
|
-
File.read(File.join(Rails.root, "db/cms_seeds/sample-site/files/default.jpg"))
|
81
|
-
)
|
82
|
-
|
83
|
-
ComfortableMexicanSofa::Seeds::File::Exporter.new("default-site", "test-site").export!
|
84
|
-
|
85
|
-
assert File.exist?(attr_path)
|
86
|
-
assert File.exist?(file_path)
|
87
|
-
assert_equal ({
|
88
|
-
"label" => "default file",
|
89
|
-
"description" => "default description",
|
90
|
-
"categories" => ["Default"]
|
91
|
-
}), YAML.load_file(attr_path)
|
92
|
-
|
93
|
-
ensure
|
94
|
-
FileUtils.rm_rf(host_path)
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
@@ -1,156 +0,0 @@
|
|
1
|
-
require_relative "../../test_helper"
|
2
|
-
|
3
|
-
class SeedsLayoutsTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
DEFAULT_HTML = <<-HTML.strip_heredoc
|
6
|
-
<html>
|
7
|
-
<body>
|
8
|
-
{{ cms:file header, as: image }}
|
9
|
-
{{ cms:markdown content }}
|
10
|
-
</body>
|
11
|
-
</html>
|
12
|
-
|
13
|
-
HTML
|
14
|
-
|
15
|
-
NESTED_HTML = <<-HTML.strip_heredoc
|
16
|
-
{{ cms:file thumbnail }}
|
17
|
-
<div class="left">{{ cms:markdown left }}</div>
|
18
|
-
<div class="right">{{ cms:markdown right }}</div>
|
19
|
-
|
20
|
-
HTML
|
21
|
-
|
22
|
-
def test_creation
|
23
|
-
Comfy::Cms::Layout.delete_all
|
24
|
-
|
25
|
-
assert_difference "Comfy::Cms::Layout.count", 2 do
|
26
|
-
ComfortableMexicanSofa::Seeds::Layout::Importer.new("sample-site", "default-site").import!
|
27
|
-
end
|
28
|
-
|
29
|
-
assert layout = Comfy::Cms::Layout.where(identifier: "default").first
|
30
|
-
assert_equal "Default Seed Layout", layout.label
|
31
|
-
assert_equal DEFAULT_HTML, layout.content
|
32
|
-
assert_equal "body{color: red}\n", layout.css
|
33
|
-
assert_equal "// default js\n\n", layout.js
|
34
|
-
|
35
|
-
assert nested_layout = Comfy::Cms::Layout.where(identifier: "nested").first
|
36
|
-
assert_equal layout, nested_layout.parent
|
37
|
-
assert_equal "Nested Seed Layout", nested_layout.label
|
38
|
-
assert_equal NESTED_HTML, nested_layout.content
|
39
|
-
assert_equal "div{float:left}\n", nested_layout.css
|
40
|
-
assert_equal "// nested js\n\n", nested_layout.js
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_update
|
44
|
-
layout = comfy_cms_layouts(:default)
|
45
|
-
nested_layout = comfy_cms_layouts(:nested)
|
46
|
-
child_layout = comfy_cms_layouts(:child)
|
47
|
-
layout.update_column(:updated_at, 10.years.ago)
|
48
|
-
nested_layout.update_column(:updated_at, 10.years.ago)
|
49
|
-
child_layout.update_column(:updated_at, 10.years.ago)
|
50
|
-
|
51
|
-
assert_count_difference [Comfy::Cms::Layout], -1 do
|
52
|
-
ComfortableMexicanSofa::Seeds::Layout::Importer.new("sample-site", "default-site").import!
|
53
|
-
|
54
|
-
layout.reload
|
55
|
-
assert_equal "Default Seed Layout", layout.label
|
56
|
-
assert_equal DEFAULT_HTML, layout.content
|
57
|
-
assert_equal "body{color: red}\n", layout.css
|
58
|
-
assert_equal "// default js\n\n", layout.js
|
59
|
-
assert_equal 0, layout.position
|
60
|
-
|
61
|
-
nested_layout.reload
|
62
|
-
assert_equal layout, nested_layout.parent
|
63
|
-
assert_equal "Nested Seed Layout", nested_layout.label
|
64
|
-
assert_equal NESTED_HTML, nested_layout.content
|
65
|
-
assert_equal "div{float:left}\n", nested_layout.css
|
66
|
-
assert_equal "// nested js\n\n", nested_layout.js
|
67
|
-
assert_equal 42, nested_layout.position
|
68
|
-
|
69
|
-
assert_nil Comfy::Cms::Layout.where(identifier: "child").first
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_update_ignore
|
74
|
-
layout = comfy_cms_layouts(:default)
|
75
|
-
layout_path = File.join(ComfortableMexicanSofa.config.seeds_path, "sample-site", "layouts", "default")
|
76
|
-
content_file_path = File.join(layout_path, "content.html")
|
77
|
-
|
78
|
-
assert layout.updated_at >= File.mtime(content_file_path)
|
79
|
-
|
80
|
-
ComfortableMexicanSofa::Seeds::Layout::Importer.new("sample-site", "default-site").import!
|
81
|
-
layout.reload
|
82
|
-
assert_equal "default", layout.identifier
|
83
|
-
assert_equal "Default Layout", layout.label
|
84
|
-
assert_equal "{{cms:textarea content}}", layout.content
|
85
|
-
assert_equal "default_css", layout.css
|
86
|
-
assert_equal "default_js", layout.js
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_export
|
90
|
-
host_path = File.join(ComfortableMexicanSofa.config.seeds_path, "test-site")
|
91
|
-
|
92
|
-
layout_1_content_path = File.join(host_path, "layouts/default/content.html")
|
93
|
-
layout_2_content_path = File.join(host_path, "layouts/nested/content.html")
|
94
|
-
layout_3_content_path = File.join(host_path, "layouts/nested/child/content.html")
|
95
|
-
|
96
|
-
ComfortableMexicanSofa::Seeds::Layout::Exporter.new("default-site", "test-site").export!
|
97
|
-
|
98
|
-
assert File.exist?(layout_1_content_path)
|
99
|
-
assert File.exist?(layout_2_content_path)
|
100
|
-
assert File.exist?(layout_3_content_path)
|
101
|
-
|
102
|
-
out = <<-TEXT.strip_heredoc
|
103
|
-
[attributes]
|
104
|
-
---
|
105
|
-
label: Default Layout
|
106
|
-
app_layout:\s
|
107
|
-
position: 0
|
108
|
-
|
109
|
-
[content]
|
110
|
-
{{cms:textarea content}}
|
111
|
-
[js]
|
112
|
-
default_js
|
113
|
-
[css]
|
114
|
-
default_css
|
115
|
-
TEXT
|
116
|
-
assert_equal out, IO.read(layout_1_content_path)
|
117
|
-
|
118
|
-
out = <<-TEXT.strip_heredoc
|
119
|
-
[attributes]
|
120
|
-
---
|
121
|
-
label: Nested Layout
|
122
|
-
app_layout:\s
|
123
|
-
position: 0
|
124
|
-
|
125
|
-
[content]
|
126
|
-
{{cms:text header}}
|
127
|
-
{{cms:textarea content}}
|
128
|
-
[js]
|
129
|
-
nested_js
|
130
|
-
[css]
|
131
|
-
nested_css
|
132
|
-
TEXT
|
133
|
-
assert_equal out, IO.read(layout_2_content_path)
|
134
|
-
|
135
|
-
out = <<-TEXT.strip_heredoc
|
136
|
-
[attributes]
|
137
|
-
---
|
138
|
-
label: Child Layout
|
139
|
-
app_layout:\s
|
140
|
-
position: 0
|
141
|
-
|
142
|
-
[content]
|
143
|
-
{{cms:textarea left_column}}
|
144
|
-
{{cms:textarea right_column}}
|
145
|
-
[js]
|
146
|
-
child_js
|
147
|
-
[css]
|
148
|
-
child_css
|
149
|
-
TEXT
|
150
|
-
assert_equal out, IO.read(layout_3_content_path)
|
151
|
-
|
152
|
-
ensure
|
153
|
-
FileUtils.rm_rf(host_path)
|
154
|
-
end
|
155
|
-
|
156
|
-
end
|
@@ -1,230 +0,0 @@
|
|
1
|
-
require_relative "../../test_helper"
|
2
|
-
|
3
|
-
class SeedsPagesTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@layout = comfy_cms_layouts(:default)
|
8
|
-
@page = comfy_cms_pages(:default)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_creation
|
12
|
-
Comfy::Cms::Page.delete_all
|
13
|
-
|
14
|
-
assert_count_difference "Comfy::Cms::Page", 3 do
|
15
|
-
assert_count_difference "Comfy::Cms::Translation", 2 do
|
16
|
-
ComfortableMexicanSofa::Seeds::Page::Importer.new("sample-site", "default-site").import!
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
assert page = Comfy::Cms::Page.find_by(full_path: "/")
|
21
|
-
|
22
|
-
assert_equal @layout, page.layout
|
23
|
-
assert_equal "index", page.slug
|
24
|
-
|
25
|
-
assert_equal "Home Seed Page", page.label
|
26
|
-
assert_equal 69, page.position
|
27
|
-
assert page.is_published?
|
28
|
-
|
29
|
-
assert_equal 5, page.fragments.count
|
30
|
-
assert_equal [
|
31
|
-
{ identifier: "header",
|
32
|
-
tag: "file",
|
33
|
-
content: nil,
|
34
|
-
datetime: nil,
|
35
|
-
boolean: false },
|
36
|
-
{ identifier: "published_on",
|
37
|
-
tag: "date",
|
38
|
-
content: nil,
|
39
|
-
datetime: Date.parse("2015-10-31"),
|
40
|
-
boolean: false },
|
41
|
-
{ identifier: "content",
|
42
|
-
tag: "wysiwyg",
|
43
|
-
content: "Home Page Seed Contént\n{{ cms:snippet default }}\n\n",
|
44
|
-
datetime: nil,
|
45
|
-
boolean: false },
|
46
|
-
{ identifier: "published",
|
47
|
-
tag: "checkbox",
|
48
|
-
content: nil,
|
49
|
-
datetime: nil,
|
50
|
-
boolean: true },
|
51
|
-
{ identifier: "attachments",
|
52
|
-
tag: "files",
|
53
|
-
content: nil,
|
54
|
-
datetime: nil,
|
55
|
-
boolean: false }
|
56
|
-
], page.fragments_attributes
|
57
|
-
|
58
|
-
frag = page.fragments.find_by(identifier: "header")
|
59
|
-
assert_equal 1, frag.attachments.count
|
60
|
-
|
61
|
-
frag = page.fragments.find_by(identifier: "attachments")
|
62
|
-
assert_equal 2, frag.attachments.count
|
63
|
-
|
64
|
-
assert_equal 2, page.categories.count
|
65
|
-
assert_equal %w[category_a category_b], page.categories.map(&:label)
|
66
|
-
|
67
|
-
assert child_page_a = Comfy::Cms::Page.find_by(full_path: "/child_a")
|
68
|
-
assert_equal page, child_page_a.parent
|
69
|
-
|
70
|
-
assert child_page_b = Comfy::Cms::Page.find_by(full_path: "/child_b")
|
71
|
-
assert_equal page, child_page_b.parent
|
72
|
-
|
73
|
-
assert_equal child_page_b, child_page_a.target_page
|
74
|
-
|
75
|
-
assert_equal 2, page.translations.count
|
76
|
-
translation = page.translations.where(locale: "fr").first
|
77
|
-
|
78
|
-
assert_equal "Bienvenue", translation.label
|
79
|
-
assert_equal [
|
80
|
-
{ identifier: "content",
|
81
|
-
tag: "wysiwyg",
|
82
|
-
content: "French Home Page Seed Content\n",
|
83
|
-
datetime: nil,
|
84
|
-
boolean: false }
|
85
|
-
], translation.fragments_attributes
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_update
|
89
|
-
@page.update_column(:updated_at, 10.years.ago)
|
90
|
-
assert_equal "Default Page", @page.label
|
91
|
-
|
92
|
-
child = comfy_cms_pages(:child)
|
93
|
-
child.update_column(:slug, "old")
|
94
|
-
|
95
|
-
assert_count_difference [Comfy::Cms::Page] do
|
96
|
-
ComfortableMexicanSofa::Seeds::Page::Importer.new("sample-site", "default-site").import!
|
97
|
-
|
98
|
-
@page.reload
|
99
|
-
assert_equal "Home Seed Page", @page.label
|
100
|
-
|
101
|
-
assert_nil Comfy::Cms::Page.where(slug: "old").first
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_update_ignore
|
106
|
-
Comfy::Cms::Page.destroy_all
|
107
|
-
|
108
|
-
page = @site.pages.create!(
|
109
|
-
label: "Test",
|
110
|
-
layout: comfy_cms_layouts(:default),
|
111
|
-
fragments_attributes: [
|
112
|
-
{ identifier: "content", content: "test content" }
|
113
|
-
]
|
114
|
-
)
|
115
|
-
|
116
|
-
page_path = File.join(ComfortableMexicanSofa.config.seeds_path, "sample-site", "pages", "index")
|
117
|
-
content_path = File.join(page_path, "content.html")
|
118
|
-
|
119
|
-
assert page.updated_at >= File.mtime(content_path)
|
120
|
-
|
121
|
-
ComfortableMexicanSofa::Seeds::Page::Importer.new("sample-site", "default-site").import!
|
122
|
-
page.reload
|
123
|
-
|
124
|
-
assert_nil page.slug
|
125
|
-
assert_equal "Test", page.label
|
126
|
-
frag = page.fragments.where(identifier: "content").first
|
127
|
-
assert_equal "test content", frag.content
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_update_removing_deleted_blocks
|
131
|
-
Comfy::Cms::Page.destroy_all
|
132
|
-
|
133
|
-
page = @site.pages.create!(
|
134
|
-
label: "Test",
|
135
|
-
layout: comfy_cms_layouts(:default),
|
136
|
-
fragments_attributes: [
|
137
|
-
{ identifier: "to_delete", content: "test content" }
|
138
|
-
]
|
139
|
-
)
|
140
|
-
page.update_column(:updated_at, 10.years.ago)
|
141
|
-
|
142
|
-
ComfortableMexicanSofa::Seeds::Page::Importer.new("sample-site", "default-site").import!
|
143
|
-
page.reload
|
144
|
-
|
145
|
-
frag = page.fragments.where(identifier: "content").first
|
146
|
-
assert_equal "Home Page Seed Contént\n{{ cms:snippet default }}\n\n", frag.content
|
147
|
-
|
148
|
-
refute page.fragments.where(identifier: "to_delete").first
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_export
|
152
|
-
ActiveStorage::Blob.any_instance.stubs(:download).returns(
|
153
|
-
file_fixture("image.jpg").read
|
154
|
-
)
|
155
|
-
|
156
|
-
comfy_cms_pages(:default).update_attribute(:target_page, comfy_cms_pages(:child))
|
157
|
-
comfy_cms_categories(:default).categorizations.create!(
|
158
|
-
categorized: comfy_cms_pages(:default)
|
159
|
-
)
|
160
|
-
|
161
|
-
comfy_cms_translations(:default).update_attributes!(fragments_attributes: [
|
162
|
-
{
|
163
|
-
identifier: "content",
|
164
|
-
content: "translation content",
|
165
|
-
tag: "markdown"
|
166
|
-
}
|
167
|
-
])
|
168
|
-
|
169
|
-
host_path = File.join(ComfortableMexicanSofa.config.seeds_path, "test-site")
|
170
|
-
page_1_content_path = File.join(host_path, "pages/index/content.html")
|
171
|
-
page_1_attachment_path = File.join(host_path, "pages/index/fragment.jpg")
|
172
|
-
page_2_content_path = File.join(host_path, "pages/index/child-page/content.html")
|
173
|
-
translation_path = File.join(host_path, "pages/index/content.fr.html")
|
174
|
-
|
175
|
-
ComfortableMexicanSofa::Seeds::Page::Exporter.new("default-site", "test-site").export!
|
176
|
-
|
177
|
-
out = <<-TEXT.strip_heredoc
|
178
|
-
[attributes]
|
179
|
-
---
|
180
|
-
label: Default Page
|
181
|
-
layout: default
|
182
|
-
target_page: "/child-page"
|
183
|
-
categories:
|
184
|
-
- Default
|
185
|
-
is_published: true
|
186
|
-
position: 0
|
187
|
-
|
188
|
-
[checkbox boolean]
|
189
|
-
true
|
190
|
-
[file file]
|
191
|
-
fragment.jpg
|
192
|
-
[datetime datetime]
|
193
|
-
1981-10-04 12:34:56 UTC
|
194
|
-
[text content]
|
195
|
-
content
|
196
|
-
TEXT
|
197
|
-
assert_equal out, IO.read(page_1_content_path)
|
198
|
-
|
199
|
-
assert File.exist?(page_1_attachment_path)
|
200
|
-
|
201
|
-
out = <<-TEXT.strip_heredoc
|
202
|
-
[attributes]
|
203
|
-
---
|
204
|
-
label: Child Page
|
205
|
-
layout: default
|
206
|
-
target_page:\s
|
207
|
-
categories: []
|
208
|
-
is_published: true
|
209
|
-
position: 0
|
210
|
-
|
211
|
-
TEXT
|
212
|
-
assert_equal out, IO.read(page_2_content_path)
|
213
|
-
|
214
|
-
out = <<-TEXT.strip_heredoc
|
215
|
-
[attributes]
|
216
|
-
---
|
217
|
-
label: Default Translation
|
218
|
-
layout: default
|
219
|
-
is_published: true
|
220
|
-
|
221
|
-
[markdown content]
|
222
|
-
translation content
|
223
|
-
TEXT
|
224
|
-
assert_equal out, IO.read(translation_path)
|
225
|
-
|
226
|
-
ensure
|
227
|
-
FileUtils.rm_rf(host_path)
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|