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,47 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class ViewHooksIntegrationTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
def teardown
|
6
|
-
ComfortableMexicanSofa::ViewHooks.remove(:navigation)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_hooks_rendering
|
10
|
-
Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path("../fixtures/views", File.dirname(__FILE__)))
|
11
|
-
ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook")
|
12
|
-
|
13
|
-
r :get, comfy_admin_cms_sites_path
|
14
|
-
assert_response :success
|
15
|
-
assert_match %r{hook_content}, response.body
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_hooks_rendering_with_multiples
|
19
|
-
Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path("../fixtures/views", File.dirname(__FILE__)))
|
20
|
-
ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook")
|
21
|
-
ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook_2")
|
22
|
-
|
23
|
-
r :get, comfy_admin_cms_sites_path
|
24
|
-
assert_response :success
|
25
|
-
assert_match %r{hook_content}, response.body
|
26
|
-
assert_match %r{<hook_content_2>}, response.body
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_hooks_rendering_with_proper_order
|
30
|
-
Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path("../fixtures/views", File.dirname(__FILE__)))
|
31
|
-
ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook_2", 0)
|
32
|
-
ComfortableMexicanSofa::ViewHooks.add(:navigation, "/nav_hook", 1)
|
33
|
-
|
34
|
-
r :get, comfy_admin_cms_sites_path
|
35
|
-
assert_response :success
|
36
|
-
assert_match %r{<hook_content_2>hook_content}, response.body
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_hooks_rendering_with_no_hook
|
40
|
-
ComfortableMexicanSofa::ViewHooks.remove(:navigation)
|
41
|
-
|
42
|
-
r :get, comfy_admin_cms_sites_path
|
43
|
-
assert_response :success
|
44
|
-
assert_no_match %r{hook_content}, response.body
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class ConfigurationTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_configuration_presence
|
6
|
-
assert config = ComfortableMexicanSofa.configuration
|
7
|
-
assert_equal "ComfortableMexicanSofa CMS Engine", config.cms_title
|
8
|
-
assert_equal "ApplicationController", config.base_controller
|
9
|
-
assert_equal "ComfortableMexicanSofa::AccessControl::AdminAuthentication", config.admin_auth
|
10
|
-
assert_equal "ComfortableMexicanSofa::AccessControl::AdminAuthorization", config.admin_authorization
|
11
|
-
assert_equal "ComfortableMexicanSofa::AccessControl::PublicAuthentication", config.public_auth
|
12
|
-
assert_equal "", config.admin_route_redirect
|
13
|
-
assert_equal false, config.enable_seeds
|
14
|
-
assert_equal File.expand_path("db/cms_seeds", Rails.root), config.seeds_path
|
15
|
-
assert_equal 25, config.revisions_limit
|
16
|
-
assert_equal ({
|
17
|
-
"en" => "English",
|
18
|
-
"es" => "Español"
|
19
|
-
}), config.locales
|
20
|
-
assert_nil config.admin_locale
|
21
|
-
assert_nil config.admin_cache_sweeper
|
22
|
-
assert_equal false, config.allow_erb
|
23
|
-
assert_nil config.allowed_helpers
|
24
|
-
assert_nil config.allowed_partials
|
25
|
-
assert_nil config.allowed_templates
|
26
|
-
assert_nil config.hostname_aliases
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_initialization_overrides
|
30
|
-
ComfortableMexicanSofa.configuration.cms_title = "New Title"
|
31
|
-
assert_equal "New Title", ComfortableMexicanSofa.configuration.cms_title
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_version
|
35
|
-
assert ComfortableMexicanSofa::VERSION
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require_relative "../../test_helper"
|
2
|
-
|
3
|
-
class ContentBlockTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
class TestBlockTag < ComfortableMexicanSofa::Content::Block
|
6
|
-
# ...
|
7
|
-
end
|
8
|
-
|
9
|
-
setup do
|
10
|
-
ComfortableMexicanSofa::Content::Renderer.register_tag(:test_block, TestBlockTag)
|
11
|
-
end
|
12
|
-
|
13
|
-
teardown do
|
14
|
-
ComfortableMexicanSofa::Content::Renderer.tags.delete("test_block")
|
15
|
-
end
|
16
|
-
|
17
|
-
# -- Tests -------------------------------------------------------------------
|
18
|
-
|
19
|
-
def test_block_tag_nodes
|
20
|
-
block = TestBlockTag.new(context: nil)
|
21
|
-
assert_equal [], block.nodes
|
22
|
-
block.nodes << "text"
|
23
|
-
assert_equal ["text"], block.nodes
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
require_relative "../../test_helper"
|
2
|
-
|
3
|
-
class ContentParamsParserTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_tokenizer
|
6
|
-
tokens = ComfortableMexicanSofa::Content::ParamsParser.tokenize("param")
|
7
|
-
assert_equal [[:string, "param"]], tokens
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_tokenizer_with_integer
|
11
|
-
tokens = ComfortableMexicanSofa::Content::ParamsParser.tokenize("123")
|
12
|
-
assert_equal [[:string, "123"]], tokens
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_tokenizer_with_commas
|
16
|
-
tokens = ComfortableMexicanSofa::Content::ParamsParser.tokenize("param_a, param_b, param_c")
|
17
|
-
assert_equal [
|
18
|
-
[:string, "param_a"], [:comma, ","], [:string, "param_b"], [:comma, ","], [:string, "param_c"]
|
19
|
-
], tokens
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_tokenizer_with_columns
|
23
|
-
tokens = ComfortableMexicanSofa::Content::ParamsParser.tokenize("key: value")
|
24
|
-
assert_equal [[:string, "key"], [:column, ":"], [:string, "value"]], tokens
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_tokenizer_with_quoted_value
|
28
|
-
tokens = ComfortableMexicanSofa::Content::ParamsParser.tokenize("key: ''")
|
29
|
-
assert_equal [[:string, "key"], [:column, ":"], [:string, ""]], tokens
|
30
|
-
|
31
|
-
tokens = ComfortableMexicanSofa::Content::ParamsParser.tokenize("key: 'test'")
|
32
|
-
assert_equal [[:string, "key"], [:column, ":"], [:string, "test"]], tokens
|
33
|
-
|
34
|
-
tokens = ComfortableMexicanSofa::Content::ParamsParser.tokenize("key: 'v1, v2: v3'")
|
35
|
-
assert_equal [[:string, "key"], [:column, ":"], [:string, "v1, v2: v3"]], tokens
|
36
|
-
|
37
|
-
tokens = ComfortableMexicanSofa::Content::ParamsParser.tokenize('key: "v1, v2: v3"')
|
38
|
-
assert_equal [[:string, "key"], [:column, ":"], [:string, "v1, v2: v3"]], tokens
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_tokenizer_with_bad_input
|
42
|
-
message = "Unexpected char: %"
|
43
|
-
assert_exception_raised ComfortableMexicanSofa::Content::ParamsParser::Error, message do
|
44
|
-
ComfortableMexicanSofa::Content::ParamsParser.tokenize("%")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_slice
|
49
|
-
tokens = [[:string, "a"], [:comma, ","], [:string, "b"]]
|
50
|
-
token_groups = ComfortableMexicanSofa::Content::ParamsParser.slice(tokens)
|
51
|
-
assert_equal [[[:string, "a"]], [[:string, "b"]]], token_groups
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_parameterize
|
55
|
-
token_groups = [[[:string, "a"]]]
|
56
|
-
params = ComfortableMexicanSofa::Content::ParamsParser.parameterize(token_groups)
|
57
|
-
assert_equal ["a"], params
|
58
|
-
|
59
|
-
token_groups = [[[:string, "a"], [:column, ":"], [:string, "b"]]]
|
60
|
-
params = ComfortableMexicanSofa::Content::ParamsParser.parameterize(token_groups)
|
61
|
-
assert_equal [{ "a" => "b" }], params
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_parameterize_with_bad_input
|
65
|
-
message = "Unexpected tokens found: [[:string, \"a\"], [:string, \"b\"]]"
|
66
|
-
token_groups = [[[:string, "a"], [:string, "b"]]]
|
67
|
-
assert_exception_raised ComfortableMexicanSofa::Content::ParamsParser::Error, message do
|
68
|
-
ComfortableMexicanSofa::Content::ParamsParser.parameterize(token_groups)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_collect_param_for_string!
|
73
|
-
params = []
|
74
|
-
ComfortableMexicanSofa::Content::ParamsParser.collect_param_for_string!(params, [:string, "a"])
|
75
|
-
assert_equal ["a"], params
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_collect_param_for_string_with_bad_input
|
79
|
-
message = "Unexpected token: [:invalid, \"a\"]"
|
80
|
-
assert_exception_raised ComfortableMexicanSofa::Content::ParamsParser::Error, message do
|
81
|
-
ComfortableMexicanSofa::Content::ParamsParser.collect_param_for_string!([], [:invalid, "a"])
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_collect_param_for_hash!
|
86
|
-
params = []
|
87
|
-
tokens = [[:string, "a"], [:column, ":"], [:string, "b"]]
|
88
|
-
ComfortableMexicanSofa::Content::ParamsParser.collect_param_for_hash!(params, tokens)
|
89
|
-
assert_equal [{ "a" => "b" }], params
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_collect_param_for_hash_with_trailing_hash
|
93
|
-
params = ["x", { "y" => "z" }]
|
94
|
-
tokens = [[:string, "a"], [:column, ":"], [:string, "b"]]
|
95
|
-
ComfortableMexicanSofa::Content::ParamsParser.collect_param_for_hash!(params, tokens)
|
96
|
-
assert_equal ["x", { "y" => "z", "a" => "b" }], params
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_collect_param_for_hash_with_trailing_param
|
100
|
-
params = ["x", { "y" => "z" }, "k"]
|
101
|
-
tokens = [[:string, "a"], [:column, ":"], [:string, "b"]]
|
102
|
-
ComfortableMexicanSofa::Content::ParamsParser.collect_param_for_hash!(params, tokens)
|
103
|
-
assert_equal ["x", { "y" => "z" }, "k", { "a" => "b" }], params
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_collect_param_for_hash_with_bad_input
|
107
|
-
message = "Unexpected tokens: [[:string, \"a\"], [:invalid, \":\"], [:string, \"b\"]]"
|
108
|
-
assert_exception_raised ComfortableMexicanSofa::Content::ParamsParser::Error, message do
|
109
|
-
tokens = [[:string, "a"], [:invalid, ":"], [:string, "b"]]
|
110
|
-
ComfortableMexicanSofa::Content::ParamsParser.collect_param_for_hash!([], tokens)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_parse
|
115
|
-
text = "param_a, param_b, key_a: val_a, key_b: val_b, param_c, key_c: val_c"
|
116
|
-
params = ComfortableMexicanSofa::Content::ParamsParser.parse(text)
|
117
|
-
assert_equal [
|
118
|
-
"param_a",
|
119
|
-
"param_b",
|
120
|
-
{ "key_a" => "val_a", "key_b" => "val_b" },
|
121
|
-
"param_c",
|
122
|
-
{ "key_c" => "val_c" }
|
123
|
-
], params
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|
@@ -1,276 +0,0 @@
|
|
1
|
-
require_relative "../../test_helper"
|
2
|
-
|
3
|
-
class ContentRendererTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
class TestTag < ComfortableMexicanSofa::Content::Tag
|
6
|
-
|
7
|
-
def content
|
8
|
-
"test tag content"
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
class TestNestedTag < ComfortableMexicanSofa::Content::Tag
|
14
|
-
|
15
|
-
def content
|
16
|
-
"test {{cms:test}} content"
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
class TestBlockTag < ComfortableMexicanSofa::Content::Block
|
22
|
-
# ...
|
23
|
-
end
|
24
|
-
|
25
|
-
DEFAULT_REGISTERED_TAGS = {
|
26
|
-
"wysiwyg" => ComfortableMexicanSofa::Content::Tag::Wysiwyg,
|
27
|
-
"text" => ComfortableMexicanSofa::Content::Tag::Text,
|
28
|
-
"textarea" => ComfortableMexicanSofa::Content::Tag::TextArea,
|
29
|
-
"markdown" => ComfortableMexicanSofa::Content::Tag::Markdown,
|
30
|
-
"datetime" => ComfortableMexicanSofa::Content::Tag::Datetime,
|
31
|
-
"date" => ComfortableMexicanSofa::Content::Tag::Date,
|
32
|
-
"number" => ComfortableMexicanSofa::Content::Tag::Number,
|
33
|
-
"checkbox" => ComfortableMexicanSofa::Content::Tag::Checkbox,
|
34
|
-
"file" => ComfortableMexicanSofa::Content::Tag::File,
|
35
|
-
"files" => ComfortableMexicanSofa::Content::Tag::Files,
|
36
|
-
"snippet" => ComfortableMexicanSofa::Content::Tag::Snippet,
|
37
|
-
"asset" => ComfortableMexicanSofa::Content::Tag::Asset,
|
38
|
-
"file_link" => ComfortableMexicanSofa::Content::Tag::FileLink,
|
39
|
-
"helper" => ComfortableMexicanSofa::Content::Tag::Helper,
|
40
|
-
"partial" => ComfortableMexicanSofa::Content::Tag::Partial,
|
41
|
-
"template" => ComfortableMexicanSofa::Content::Tag::Template
|
42
|
-
}.freeze
|
43
|
-
|
44
|
-
setup do
|
45
|
-
@page = comfy_cms_pages(:default)
|
46
|
-
@template = ComfortableMexicanSofa::Content::Renderer.new(@page)
|
47
|
-
|
48
|
-
ComfortableMexicanSofa::Content::Renderer.register_tag(:test, TestTag)
|
49
|
-
ComfortableMexicanSofa::Content::Renderer.register_tag(:test_nested, TestNestedTag)
|
50
|
-
ComfortableMexicanSofa::Content::Renderer.register_tag(:test_block, TestBlockTag)
|
51
|
-
end
|
52
|
-
|
53
|
-
teardown do
|
54
|
-
ComfortableMexicanSofa::Content::Renderer.tags.delete("test")
|
55
|
-
ComfortableMexicanSofa::Content::Renderer.tags.delete("test_nested")
|
56
|
-
ComfortableMexicanSofa::Content::Renderer.tags.delete("test_block")
|
57
|
-
end
|
58
|
-
|
59
|
-
# Test helper so we don't have to do this each time
|
60
|
-
def render_string(string, template = @template)
|
61
|
-
tokens = template.tokenize(string)
|
62
|
-
nodes = template.nodes(tokens)
|
63
|
-
template.render(nodes)
|
64
|
-
end
|
65
|
-
|
66
|
-
# -- Tests -------------------------------------------------------------------
|
67
|
-
|
68
|
-
def test_tags
|
69
|
-
assert_equal DEFAULT_REGISTERED_TAGS.merge(
|
70
|
-
"test" => ContentRendererTest::TestTag,
|
71
|
-
"test_nested" => ContentRendererTest::TestNestedTag,
|
72
|
-
"test_block" => ContentRendererTest::TestBlockTag
|
73
|
-
), ComfortableMexicanSofa::Content::Renderer.tags
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_register_tags
|
77
|
-
ComfortableMexicanSofa::Content::Renderer.register_tag(:other, TestTag)
|
78
|
-
assert_equal DEFAULT_REGISTERED_TAGS.merge(
|
79
|
-
"test" => ContentRendererTest::TestTag,
|
80
|
-
"test_nested" => ContentRendererTest::TestNestedTag,
|
81
|
-
"test_block" => ContentRendererTest::TestBlockTag,
|
82
|
-
"other" => ContentRendererTest::TestTag
|
83
|
-
), ComfortableMexicanSofa::Content::Renderer.tags
|
84
|
-
ensure
|
85
|
-
ComfortableMexicanSofa::Content::Renderer.tags.delete("other")
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_tokenize
|
89
|
-
assert_equal ["test text"], @template.tokenize("test text")
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_tokenize_with_tag
|
93
|
-
assert_equal ["test ", { tag_class: "tag", tag_params: "", source: "{{cms:tag}}" }, " text"],
|
94
|
-
@template.tokenize("test {{cms:tag}} text")
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_tokenize_with_tag_and_params
|
98
|
-
expected = [
|
99
|
-
"test ",
|
100
|
-
{ tag_class: "tag", tag_params: "name, key:val", source: "{{cms:tag name, key:val}}" },
|
101
|
-
" text"
|
102
|
-
]
|
103
|
-
assert_equal expected, @template.tokenize("test {{cms:tag name, key:val}} text")
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_tokenize_with_invalid_tag
|
107
|
-
assert_equal ["test {{abc:tag}} text"],
|
108
|
-
@template.tokenize("test {{abc:tag}} text")
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_tokenize_with_newlines
|
112
|
-
expected = [
|
113
|
-
{ tag_class: "test", tag_params: "", source: "{{cms:test}}" },
|
114
|
-
"\n",
|
115
|
-
{ tag_class: "test", tag_params: "", source: "{{cms:test}}" }
|
116
|
-
]
|
117
|
-
assert_equal expected, @template.tokenize("{{cms:test}}\n{{cms:test}}")
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_nodes
|
121
|
-
tokens = @template.tokenize("test")
|
122
|
-
nodes = @template.nodes(tokens)
|
123
|
-
assert_equal ["test"], nodes
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_nodes_with_tags
|
127
|
-
tokens = @template.tokenize("test {{cms:test}} content {{cms:test}}")
|
128
|
-
nodes = @template.nodes(tokens)
|
129
|
-
assert_equal 4, nodes.count
|
130
|
-
assert_equal "test ", nodes[0]
|
131
|
-
assert nodes[1].is_a?(ContentRendererTest::TestTag)
|
132
|
-
assert_equal " content ", nodes[2]
|
133
|
-
assert nodes[3].is_a?(ContentRendererTest::TestTag)
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_nodes_with_tag_with_params
|
137
|
-
tokens = @template.tokenize("{{cms:test param, key: value}}")
|
138
|
-
nodes = @template.nodes(tokens)
|
139
|
-
assert_equal 1, nodes.count
|
140
|
-
assert nodes[0].is_a?(ContentRendererTest::TestTag)
|
141
|
-
tag = nodes[0]
|
142
|
-
assert_equal @page, tag.context
|
143
|
-
assert_equal ["param", { "key" => "value" }], tag.params
|
144
|
-
assert_equal "{{cms:test param, key: value}}", tag.source
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_nodes_with_block_tag
|
148
|
-
string = "a {{cms:test_block}} b {{cms:end}} c"
|
149
|
-
tokens = @template.tokenize(string)
|
150
|
-
nodes = @template.nodes(tokens)
|
151
|
-
assert_equal 3, nodes.count
|
152
|
-
|
153
|
-
assert_equal "a ", nodes[0]
|
154
|
-
assert_equal " c", nodes[2]
|
155
|
-
|
156
|
-
block = nodes[1]
|
157
|
-
assert block.is_a?(ContentRendererTest::TestBlockTag)
|
158
|
-
assert_equal [" b "], block.nodes
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_nodes_with_block_tag_and_tag
|
162
|
-
string = "a {{cms:test_block}} b {{cms:test}} c {{cms:end}} d"
|
163
|
-
tokens = @template.tokenize(string)
|
164
|
-
nodes = @template.nodes(tokens)
|
165
|
-
assert_equal 3, nodes.count
|
166
|
-
assert_equal "a ", nodes[0]
|
167
|
-
assert_equal " d", nodes[2]
|
168
|
-
|
169
|
-
block = nodes[1]
|
170
|
-
assert block.is_a?(ContentRendererTest::TestBlockTag)
|
171
|
-
assert_equal 3, block.nodes.count
|
172
|
-
assert_equal " b ", block.nodes[0]
|
173
|
-
assert_equal " c ", block.nodes[2]
|
174
|
-
|
175
|
-
tag = block.nodes[1]
|
176
|
-
assert tag.is_a?(ContentRendererTest::TestTag)
|
177
|
-
assert_equal ["test tag content"], tag.nodes
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_nodes_with_nested_block_tag
|
181
|
-
string = "a {{cms:test_block}} b {{cms:test_block}} c {{cms:end}} d {{cms:end}} e"
|
182
|
-
tokens = @template.tokenize(string)
|
183
|
-
nodes = @template.nodes(tokens)
|
184
|
-
assert_equal 3, nodes.count
|
185
|
-
assert_equal "a ", nodes[0]
|
186
|
-
assert_equal " e", nodes[2]
|
187
|
-
|
188
|
-
block = nodes[1]
|
189
|
-
assert block.is_a?(ContentRendererTest::TestBlockTag)
|
190
|
-
assert_equal 3, block.nodes.count
|
191
|
-
assert_equal " b ", block.nodes[0]
|
192
|
-
assert_equal " d ", block.nodes[2]
|
193
|
-
|
194
|
-
block = block.nodes[1]
|
195
|
-
assert_equal [" c "], block.nodes
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_nodes_with_unclosed_block_tag
|
199
|
-
string = "a {{cms:test_block}} b"
|
200
|
-
tokens = @template.tokenize(string)
|
201
|
-
message = "unclosed block detected"
|
202
|
-
assert_exception_raised ComfortableMexicanSofa::Content::Renderer::SyntaxError, message do
|
203
|
-
@template.nodes(tokens)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_nodes_with_closed_tag
|
208
|
-
string = "a {{cms:end}} b"
|
209
|
-
tokens = @template.tokenize(string)
|
210
|
-
message = "closing unopened block"
|
211
|
-
assert_exception_raised ComfortableMexicanSofa::Content::Renderer::SyntaxError, message do
|
212
|
-
@template.nodes(tokens)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
def test_nodes_with_invalid_tag
|
217
|
-
string = "a {{cms:invalid}} b"
|
218
|
-
tokens = @template.tokenize(string)
|
219
|
-
message = "Unrecognized tag: {{cms:invalid}}"
|
220
|
-
assert_exception_raised ComfortableMexicanSofa::Content::Renderer::SyntaxError, message do
|
221
|
-
@template.nodes(tokens)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_sanitize_erb
|
226
|
-
out = @template.sanitize_erb("<% test %>", false)
|
227
|
-
assert_equal "<% test %>", out
|
228
|
-
|
229
|
-
out = @template.sanitize_erb("<% test %>", true)
|
230
|
-
assert_equal "<% test %>", out
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_render
|
234
|
-
out = render_string("test")
|
235
|
-
assert_equal "test", out
|
236
|
-
end
|
237
|
-
|
238
|
-
def test_render_with_tag
|
239
|
-
out = render_string("a {{cms:text content}} z")
|
240
|
-
assert_equal "a content z", out
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_render_with_erb
|
244
|
-
out = render_string("<%= 1 + 1 %>")
|
245
|
-
assert_equal "<%= 1 + 1 %>", out
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_render_with_erb_allowed
|
249
|
-
ComfortableMexicanSofa.config.allow_erb = true
|
250
|
-
out = render_string("<%= 1 + 1 %>")
|
251
|
-
assert_equal "<%= 1 + 1 %>", out
|
252
|
-
end
|
253
|
-
|
254
|
-
def test_render_with_erb_allowed_via_tag
|
255
|
-
out = render_string("{{cms:partial path}}")
|
256
|
-
assert_equal "<%= render partial: \"path\", locals: {} %>", out
|
257
|
-
end
|
258
|
-
|
259
|
-
def test_render_with_nested_tag
|
260
|
-
string = "a {{cms:text content}} b"
|
261
|
-
comfy_cms_fragments(:default).update_column(:content, "c {{cms:snippet default}} d")
|
262
|
-
comfy_cms_snippets(:default).update_column(:content, "e {{cms:helper test}} f")
|
263
|
-
out = render_string(string)
|
264
|
-
assert_equal "a c e <%= test() %> f d b", out
|
265
|
-
end
|
266
|
-
|
267
|
-
def test_render_stack_overflow
|
268
|
-
# making self-referencing content loop here
|
269
|
-
comfy_cms_snippets(:default).update_column(:content, "a {{cms:snippet default}} b")
|
270
|
-
message = "Deep tag nesting or recursive nesting detected"
|
271
|
-
assert_exception_raised ComfortableMexicanSofa::Content::Renderer::Error, message do
|
272
|
-
render_string("{{cms:snippet default}}")
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
end
|