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,48 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class FieldTextTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::FieldText.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:field:content:text }}'
|
8
|
+
)
|
9
|
+
assert_equal 'content', tag.identifier
|
10
|
+
assert_nil tag.namespace
|
11
|
+
assert tag = ComfyPress::Tag::FieldText.initialize_tag(
|
12
|
+
cms_pages(:default), '{{cms:field:content:text}}'
|
13
|
+
)
|
14
|
+
assert_equal 'content', tag.identifier
|
15
|
+
assert tag = ComfyPress::Tag::FieldText.initialize_tag(
|
16
|
+
cms_pages(:default), '{{cms:field:dash-content:text}}'
|
17
|
+
)
|
18
|
+
assert_equal 'dash-content', tag.identifier
|
19
|
+
assert tag = ComfyPress::Tag::FieldText.initialize_tag(
|
20
|
+
cms_pages(:default), '{{cms:field:namespace.content:text}}'
|
21
|
+
)
|
22
|
+
assert_equal 'namespace.content', tag.identifier
|
23
|
+
assert_equal 'namespace', tag.namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_tag_failure
|
27
|
+
[
|
28
|
+
'{{cms:field:content:not_text}}',
|
29
|
+
'{{cms:not_field:content:text}}',
|
30
|
+
'{not_a_tag}'
|
31
|
+
].each do |tag_signature|
|
32
|
+
assert_nil ComfyPress::Tag::FieldText.initialize_tag(
|
33
|
+
cms_pages(:default), tag_signature
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_content_and_render
|
39
|
+
tag = ComfyPress::Tag::FieldText.initialize_tag(
|
40
|
+
cms_pages(:default), '{{cms:field:content:text}}'
|
41
|
+
)
|
42
|
+
assert tag.block.content.blank?
|
43
|
+
tag.block.content = 'test_content'
|
44
|
+
assert_equal 'test_content', tag.content
|
45
|
+
assert_equal '', tag.render
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class FileTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::File.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:file:sample.jpg:image:alt text }}'
|
8
|
+
)
|
9
|
+
assert_equal cms_files(:default), tag.file
|
10
|
+
assert_equal 'sample.jpg', tag.identifier
|
11
|
+
assert_equal ['image', 'alt text'], tag.params
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_initialize_tag_failure
|
15
|
+
[
|
16
|
+
'{{cms:file}}',
|
17
|
+
'{{cms:not_file:label}}',
|
18
|
+
'{not_a_tag}'
|
19
|
+
].each do |tag_signature|
|
20
|
+
assert_nil ComfyPress::Tag::File.initialize_tag(
|
21
|
+
cms_pages(:default), tag_signature
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_render_for_invalid
|
27
|
+
tag = ComfyPress::Tag::File.initialize_tag(
|
28
|
+
cms_pages(:default), '{{cms:file:invalid.jpg}}'
|
29
|
+
)
|
30
|
+
assert_nil tag.file
|
31
|
+
assert_equal '', tag.render
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_render
|
35
|
+
file = cms_files(:default)
|
36
|
+
assert tag = ComfyPress::Tag::File.initialize_tag(
|
37
|
+
cms_pages(:default), '{{ cms:file:sample.jpg }}'
|
38
|
+
)
|
39
|
+
assert_equal file.file.url, tag.render
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_render_for_link
|
43
|
+
file = cms_files(:default)
|
44
|
+
assert tag = ComfyPress::Tag::File.initialize_tag(
|
45
|
+
cms_pages(:default), '{{ cms:file:sample.jpg:link }}'
|
46
|
+
)
|
47
|
+
assert_equal "<a href='#{file.file.url}' target='_blank'>sample.jpg</a>", tag.render
|
48
|
+
|
49
|
+
assert tag = ComfyPress::Tag::File.initialize_tag(
|
50
|
+
cms_pages(:default), '{{ cms:file:sample.jpg:link:link text }}'
|
51
|
+
)
|
52
|
+
assert_equal "<a href='#{file.file.url}' target='_blank'>link text</a>", tag.render
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_render_for_image
|
56
|
+
file = cms_files(:default)
|
57
|
+
assert tag = ComfyPress::Tag::File.initialize_tag(
|
58
|
+
cms_pages(:default), '{{ cms:file:sample.jpg:image }}'
|
59
|
+
)
|
60
|
+
assert_equal "<img src='#{file.file.url}' alt='sample.jpg' />", tag.render
|
61
|
+
|
62
|
+
assert tag = ComfyPress::Tag::File.initialize_tag(
|
63
|
+
cms_pages(:default), '{{ cms:file:sample.jpg:image:alt text }}'
|
64
|
+
)
|
65
|
+
assert_equal "<img src='#{file.file.url}' alt='alt text' />", tag.render
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class HelperTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::Helper.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:helper:method_name }}'
|
8
|
+
)
|
9
|
+
assert_equal 'method_name', tag.identifier
|
10
|
+
assert tag = ComfyPress::Tag::Helper.initialize_tag(
|
11
|
+
cms_pages(:default), '{{ cms:helper:method-name }}'
|
12
|
+
)
|
13
|
+
assert_equal 'method-name', tag.identifier
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_initialize_tag_with_parameters
|
17
|
+
assert tag = ComfyPress::Tag::Helper.initialize_tag(
|
18
|
+
cms_pages(:default), '{{ cms:helper:method_name:param1:param2 }}'
|
19
|
+
)
|
20
|
+
assert_equal 'method_name', tag.identifier
|
21
|
+
assert_equal ['param1', 'param2'], tag.params
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_initialize_tag_with_complex_parameters
|
25
|
+
assert tag = ComfyPress::Tag::Helper.initialize_tag(
|
26
|
+
cms_pages(:default), '{{ cms:helper:method_name:param1:"param:2" }}'
|
27
|
+
)
|
28
|
+
assert_equal 'method_name', tag.identifier
|
29
|
+
assert_equal ['param1', 'param:2'], tag.params
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_initialize_tag_failure
|
34
|
+
[
|
35
|
+
'{{cms:helper}}',
|
36
|
+
'{{cms:not_helper:method_name}}',
|
37
|
+
'{not_a_tag}'
|
38
|
+
].each do |tag_signature|
|
39
|
+
assert_nil ComfyPress::Tag::Helper.initialize_tag(
|
40
|
+
cms_pages(:default), tag_signature
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_content_and_render
|
46
|
+
tag = ComfyPress::Tag::Helper.initialize_tag(
|
47
|
+
cms_pages(:default), '{{cms:helper:method_name}}'
|
48
|
+
)
|
49
|
+
assert_equal "<%= method_name() %>", tag.content
|
50
|
+
assert_equal "<%= method_name() %>", tag.render
|
51
|
+
|
52
|
+
tag = ComfyPress::Tag::Helper.initialize_tag(
|
53
|
+
cms_pages(:default), '{{cms:helper:method_name:param1:param2}}'
|
54
|
+
)
|
55
|
+
assert_equal "<%= method_name('param1', 'param2') %>", tag.content
|
56
|
+
assert_equal "<%= method_name('param1', 'param2') %>", tag.render
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_blacklisted_methods
|
60
|
+
ComfyPress::Tag::Helper::BLACKLIST.each do |method|
|
61
|
+
tag = ComfyPress::Tag::Helper.initialize_tag(
|
62
|
+
cms_pages(:default), "{{ cms:helper:#{method}:Rails.env }}"
|
63
|
+
)
|
64
|
+
assert_equal "<%= #{method}('Rails.env') %>", tag.content
|
65
|
+
assert_equal nil, tag.render
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_whitelisted_methods
|
70
|
+
ComfyPress.config.allowed_helpers = [:tester, :eval]
|
71
|
+
ComfyPress.config.allowed_helpers.each do |method|
|
72
|
+
tag = ComfyPress::Tag::Helper.initialize_tag(
|
73
|
+
cms_pages(:default), "{{ cms:helper:#{method}:Rails.env }}"
|
74
|
+
)
|
75
|
+
assert_equal "<%= #{method}('Rails.env') %>", tag.content
|
76
|
+
assert_equal "<%= #{method}('Rails.env') %>", tag.render
|
77
|
+
end
|
78
|
+
|
79
|
+
tag = ComfyPress::Tag::Helper.initialize_tag(
|
80
|
+
cms_pages(:default), "{{ cms:helper:invalid:Rails.env }}"
|
81
|
+
)
|
82
|
+
assert_equal "<%= invalid('Rails.env') %>", tag.content
|
83
|
+
assert_equal nil, tag.render
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class PageDateTimeTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::PageDateTime.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:page:content:datetime }}'
|
8
|
+
)
|
9
|
+
assert_equal 'content', tag.identifier
|
10
|
+
assert_nil tag.namespace
|
11
|
+
assert tag = ComfyPress::Tag::PageDateTime.initialize_tag(
|
12
|
+
cms_pages(:default), '{{cms:page:content:datetime}}'
|
13
|
+
)
|
14
|
+
assert_equal 'content', tag.identifier
|
15
|
+
assert tag = ComfyPress::Tag::PageDateTime.initialize_tag(
|
16
|
+
cms_pages(:default), '{{cms:page:dash-content:datetime}}'
|
17
|
+
)
|
18
|
+
assert_equal 'dash-content', tag.identifier
|
19
|
+
assert tag = ComfyPress::Tag::PageDateTime.initialize_tag(
|
20
|
+
cms_pages(:default), '{{cms:page:namespace.content:datetime}}'
|
21
|
+
)
|
22
|
+
assert_equal 'namespace.content', tag.identifier
|
23
|
+
assert_equal 'namespace', tag.namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_tag_failure
|
27
|
+
[
|
28
|
+
'{{cms:page:content:not_datetime}}',
|
29
|
+
'{{cms:page:content}}',
|
30
|
+
'{{cms:not_page:content}}',
|
31
|
+
'{not_a_tag}'
|
32
|
+
].each do |tag_signature|
|
33
|
+
assert_nil ComfyPress::Tag::PageDateTime.initialize_tag(
|
34
|
+
cms_pages(:default), tag_signature
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_content_and_render
|
40
|
+
tag = ComfyPress::Tag::PageDateTime.initialize_tag(
|
41
|
+
cms_pages(:default), '{{cms:page:content:datetime}}'
|
42
|
+
)
|
43
|
+
assert tag.block.content.blank?
|
44
|
+
time = 2.days.ago
|
45
|
+
tag.block.content = time
|
46
|
+
assert_equal time, tag.content
|
47
|
+
assert_equal time.to_s, tag.render
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class PageFileTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:page_file:label }}'
|
8
|
+
)
|
9
|
+
assert_equal 'label', tag.identifier
|
10
|
+
assert_nil tag.namespace
|
11
|
+
assert 'url', tag.type
|
12
|
+
assert_equal nil, tag.dimensions
|
13
|
+
|
14
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(
|
15
|
+
cms_pages(:default), '{{ cms:page_file:label:partial }}'
|
16
|
+
)
|
17
|
+
assert_equal 'partial', tag.type
|
18
|
+
|
19
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(
|
20
|
+
cms_pages(:default), '{{ cms:page_file:namespace.label:partial }}'
|
21
|
+
)
|
22
|
+
assert_equal 'namespace.label', tag.identifier
|
23
|
+
assert_equal 'namespace', tag.namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_tag_with_dimentions
|
27
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(
|
28
|
+
cms_pages(:default), '{{ cms:page_file:label:image[100x100#] }}'
|
29
|
+
)
|
30
|
+
assert_equal 'image', tag.type
|
31
|
+
assert_equal '100x100#', tag.dimensions
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_initialize_tag_failure
|
35
|
+
[
|
36
|
+
'{{cms:page_file}}',
|
37
|
+
'{{cms:not_page_file:label}}',
|
38
|
+
'{not_a_tag}'
|
39
|
+
].each do |tag_signature|
|
40
|
+
assert_nil ComfyPress::Tag::PageFile.initialize_tag(
|
41
|
+
cms_pages(:default), tag_signature
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_content_and_render
|
47
|
+
page = cms_pages(:default)
|
48
|
+
|
49
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:partial }}')
|
50
|
+
assert_equal "<%= render :partial => 'partials/page_file', :locals => {:identifier => nil} %>", tag.render
|
51
|
+
|
52
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file }}')
|
53
|
+
assert_equal nil, tag.content
|
54
|
+
assert_equal '', tag.render
|
55
|
+
|
56
|
+
page.update_attributes!(
|
57
|
+
:blocks_attributes => [
|
58
|
+
{ :identifier => 'file',
|
59
|
+
:content => fixture_file_upload('files/image.jpg', "image/jpeg") }
|
60
|
+
]
|
61
|
+
)
|
62
|
+
file = tag.block.files.first
|
63
|
+
file_url = file.file.url
|
64
|
+
|
65
|
+
assert_equal file, tag.content
|
66
|
+
assert_match file_url, tag.render
|
67
|
+
|
68
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:link }}')
|
69
|
+
assert_equal "<a href='#{file_url}' target='_blank'>file</a>",
|
70
|
+
tag.render
|
71
|
+
|
72
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:link:link label }}')
|
73
|
+
assert_equal "<a href='#{file_url}' target='_blank'>link label</a>",
|
74
|
+
tag.render
|
75
|
+
|
76
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:image }}')
|
77
|
+
assert_equal "<img src='#{file_url}' alt='file' />",
|
78
|
+
tag.render
|
79
|
+
|
80
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:image:image alt }}')
|
81
|
+
assert_equal "<img src='#{file_url}' alt='image alt' />",
|
82
|
+
tag.render
|
83
|
+
|
84
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:partial }}')
|
85
|
+
assert_equal "<%= render :partial => 'partials/page_file', :locals => {:identifier => #{file.id}} %>",
|
86
|
+
tag.render
|
87
|
+
|
88
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:partial:path/to/partial }}')
|
89
|
+
assert_equal "<%= render :partial => 'path/to/partial', :locals => {:identifier => #{file.id}} %>",
|
90
|
+
tag.render
|
91
|
+
|
92
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:partial:path/to/partial:a:b }}')
|
93
|
+
assert_equal "<%= render :partial => 'path/to/partial', :locals => {:identifier => #{file.id}, :param_1 => 'a', :param_2 => 'b'} %>",
|
94
|
+
tag.render
|
95
|
+
|
96
|
+
assert tag = ComfyPress::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:field }}')
|
97
|
+
assert_equal '', tag.render
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_content_and_render_with_dimentions
|
101
|
+
layout = cms_layouts(:default)
|
102
|
+
layout.update_attributes(:content => '{{ cms:page_file:file:image[10x10#] }}')
|
103
|
+
page = cms_pages(:default)
|
104
|
+
upload = fixture_file_upload('files/image.jpg', 'image/jpeg')
|
105
|
+
|
106
|
+
assert_difference 'Cms::File.count' do
|
107
|
+
page.update_attributes!(
|
108
|
+
:blocks_attributes => [
|
109
|
+
{ :identifier => 'file',
|
110
|
+
:content => upload }
|
111
|
+
]
|
112
|
+
)
|
113
|
+
file = Cms::File.last
|
114
|
+
assert_equal 'image.jpg', file.file_file_name
|
115
|
+
# assert file.file_file_size < upload.size
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class PageFilesTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:page_files:label }}'
|
8
|
+
)
|
9
|
+
assert 'url', tag.type
|
10
|
+
assert_equal 'label', tag.identifier
|
11
|
+
assert_equal nil, tag.namespace
|
12
|
+
assert_equal nil, tag.dimensions
|
13
|
+
|
14
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(
|
15
|
+
cms_pages(:default), '{{ cms:page_files:label:partial }}'
|
16
|
+
)
|
17
|
+
assert 'partial', tag.type
|
18
|
+
|
19
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(
|
20
|
+
cms_pages(:default), '{{ cms:page_files:namespace.label:partial }}'
|
21
|
+
)
|
22
|
+
assert_equal 'namespace.label', tag.identifier
|
23
|
+
assert_equal 'namespace', tag.namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_tag_with_dimentions
|
27
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(
|
28
|
+
cms_pages(:default), '{{ cms:page_files:label:image[100x100#] }}'
|
29
|
+
)
|
30
|
+
assert_equal 'image', tag.type
|
31
|
+
assert_equal '100x100#', tag.dimensions
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_initialize_tag_failure
|
35
|
+
[
|
36
|
+
'{{cms:page_files}}',
|
37
|
+
'{{cms:not_page_files:label}}',
|
38
|
+
'{not_a_tag}'
|
39
|
+
].each do |tag_signature|
|
40
|
+
assert_nil ComfyPress::Tag::PageFiles.initialize_tag(
|
41
|
+
cms_pages(:default), tag_signature
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_content_and_render
|
47
|
+
page = cms_pages(:default)
|
48
|
+
|
49
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:partial }}')
|
50
|
+
assert_equal "<%= render :partial => 'partials/page_files', :locals => {:identifier => []} %>", tag.render
|
51
|
+
|
52
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files }}')
|
53
|
+
assert_equal [], tag.content
|
54
|
+
assert_equal '', tag.render
|
55
|
+
|
56
|
+
page.update_attributes!(
|
57
|
+
:blocks_attributes => [
|
58
|
+
{ :identifier => 'files',
|
59
|
+
:content => [fixture_file_upload('files/image.jpg', "image/jpeg"), fixture_file_upload('files/image.gif', "image/gif")] }
|
60
|
+
]
|
61
|
+
)
|
62
|
+
files = tag.block.files
|
63
|
+
file_a, file_b = files
|
64
|
+
file_a_url = file_a.file.url
|
65
|
+
file_b_url = file_b.file.url
|
66
|
+
|
67
|
+
assert_equal files, tag.content
|
68
|
+
assert_equal "#{file_a_url}, #{file_b_url}", tag.render
|
69
|
+
|
70
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:link }}')
|
71
|
+
assert_equal "<a href='#{file_a_url}' target='_blank'>Image</a> <a href='#{file_b_url}' target='_blank'>Image</a>",
|
72
|
+
tag.render
|
73
|
+
|
74
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:image }}')
|
75
|
+
assert_equal "<img src='#{file_a_url}' alt='Image' /> <img src='#{file_b_url}' alt='Image' />",
|
76
|
+
tag.render
|
77
|
+
|
78
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:partial }}')
|
79
|
+
assert_equal "<%= render :partial => 'partials/page_files', :locals => {:identifier => [#{files.collect(&:id).join(',')}]} %>",
|
80
|
+
tag.render
|
81
|
+
|
82
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:partial:path/to/partial }}')
|
83
|
+
assert_equal "<%= render :partial => 'path/to/partial', :locals => {:identifier => [#{files.collect(&:id).join(',')}]} %>",
|
84
|
+
tag.render
|
85
|
+
|
86
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:partial:path/to/partial:a:b }}')
|
87
|
+
assert_equal "<%= render :partial => 'path/to/partial', :locals => {:identifier => [#{files.collect(&:id).join(',')}], :param_1 => 'a', :param_2 => 'b'} %>",
|
88
|
+
tag.render
|
89
|
+
|
90
|
+
assert tag = ComfyPress::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:field }}')
|
91
|
+
assert_equal '', tag.render
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_content_and_render_with_dimentions
|
95
|
+
layout = cms_layouts(:default)
|
96
|
+
layout.update_attributes(:content => '{{ cms:page_files:file:image[10x10#] }}')
|
97
|
+
page = cms_pages(:default)
|
98
|
+
upload = fixture_file_upload('files/image.jpg', 'image/jpeg')
|
99
|
+
|
100
|
+
assert_difference 'Cms::File.count' do
|
101
|
+
page.update_attributes!(
|
102
|
+
:blocks_attributes => [
|
103
|
+
{ :identifier => 'file',
|
104
|
+
:content => upload }
|
105
|
+
]
|
106
|
+
)
|
107
|
+
file = Cms::File.last
|
108
|
+
assert_equal 'image.jpg', file.file_file_name
|
109
|
+
# assert file.file_file_size < upload.size
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class PageIntegerTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::PageInteger.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:page:content:integer }}'
|
8
|
+
)
|
9
|
+
assert_equal 'content', tag.identifier
|
10
|
+
assert_nil tag.namespace
|
11
|
+
assert tag = ComfyPress::Tag::PageInteger.initialize_tag(
|
12
|
+
cms_pages(:default), '{{cms:page:content:integer}}'
|
13
|
+
)
|
14
|
+
assert_equal 'content', tag.identifier
|
15
|
+
assert tag = ComfyPress::Tag::PageInteger.initialize_tag(
|
16
|
+
cms_pages(:default), '{{cms:page:dash-content:integer}}'
|
17
|
+
)
|
18
|
+
assert_equal 'dash-content', tag.identifier
|
19
|
+
assert tag = ComfyPress::Tag::PageInteger.initialize_tag(
|
20
|
+
cms_pages(:default), '{{cms:page:namespace.content:integer}}'
|
21
|
+
)
|
22
|
+
assert_equal 'namespace.content', tag.identifier
|
23
|
+
assert_equal 'namespace', tag.namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_tag_failure
|
27
|
+
[
|
28
|
+
'{{cms:page:content:not_integer}}',
|
29
|
+
'{{cms:page:content}}',
|
30
|
+
'{{cms:not_page:content}}',
|
31
|
+
'{not_a_tag}'
|
32
|
+
].each do |tag_signature|
|
33
|
+
assert_nil ComfyPress::Tag::PageInteger.initialize_tag(
|
34
|
+
cms_pages(:default), tag_signature
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_content_and_render
|
40
|
+
tag = ComfyPress::Tag::PageInteger.initialize_tag(
|
41
|
+
cms_pages(:default), '{{cms:page:content:integer}}'
|
42
|
+
)
|
43
|
+
assert tag.block.content.blank?
|
44
|
+
tag.block.content = '5'
|
45
|
+
assert_equal '5', tag.content
|
46
|
+
assert_equal '5', tag.render
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class PageMarkdownTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::PageMarkdown.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:page:content:markdown }}'
|
8
|
+
)
|
9
|
+
assert_equal 'content', tag.identifier
|
10
|
+
assert_nil tag.namespace
|
11
|
+
assert tag = ComfyPress::Tag::PageMarkdown.initialize_tag(
|
12
|
+
cms_pages(:default), '{{cms:page:content:markdown}}'
|
13
|
+
)
|
14
|
+
assert_equal 'content', tag.identifier
|
15
|
+
assert tag = ComfyPress::Tag::PageMarkdown.initialize_tag(
|
16
|
+
cms_pages(:default), '{{cms:page:dash-content:markdown}}'
|
17
|
+
)
|
18
|
+
assert_equal 'dash-content', tag.identifier
|
19
|
+
assert tag = ComfyPress::Tag::PageMarkdown.initialize_tag(
|
20
|
+
cms_pages(:default), '{{cms:page:namespace.content:markdown}}'
|
21
|
+
)
|
22
|
+
assert_equal 'namespace.content', tag.identifier
|
23
|
+
assert_equal 'namespace', tag.namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_tag_failure
|
27
|
+
[
|
28
|
+
'{{cms:page:content:not_markdown}}',
|
29
|
+
'{{cms:page:content}}',
|
30
|
+
'{{cms:not_page:content}}',
|
31
|
+
'{not_a_tag}'
|
32
|
+
].each do |tag_signature|
|
33
|
+
assert_nil ComfyPress::Tag::PageMarkdown.initialize_tag(
|
34
|
+
cms_pages(:default), tag_signature
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_content_and_render
|
40
|
+
tag = ComfyPress::Tag::PageMarkdown.initialize_tag(
|
41
|
+
cms_pages(:default), '{{cms:page:content:markdown}}'
|
42
|
+
)
|
43
|
+
assert tag.block.content.blank?
|
44
|
+
tag.block.content = '_test_content_'
|
45
|
+
assert_equal '_test_content_', tag.content
|
46
|
+
assert_equal "<p><em>test_content</em></p>\n", tag.render
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class PageRichTextTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::PageRichText.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:page:content:rich_text }}'
|
8
|
+
)
|
9
|
+
assert_equal 'content', tag.identifier
|
10
|
+
assert_nil tag.namespace
|
11
|
+
assert tag = ComfyPress::Tag::PageRichText.initialize_tag(
|
12
|
+
cms_pages(:default), '{{cms:page:content:rich_text}}'
|
13
|
+
)
|
14
|
+
assert_equal 'content', tag.identifier
|
15
|
+
assert tag = ComfyPress::Tag::PageRichText.initialize_tag(
|
16
|
+
cms_pages(:default), '{{cms:page:dash-content:rich_text}}'
|
17
|
+
)
|
18
|
+
assert_equal 'dash-content', tag.identifier
|
19
|
+
assert tag = ComfyPress::Tag::PageRichText.initialize_tag(
|
20
|
+
cms_pages(:default), '{{cms:page:namespace.content:rich_text}}'
|
21
|
+
)
|
22
|
+
assert_equal 'namespace.content', tag.identifier
|
23
|
+
assert_equal 'namespace', tag.namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_tag_failure
|
27
|
+
[
|
28
|
+
'{{cms:page:content:not_rich_text}}',
|
29
|
+
'{{cms:page:content}}',
|
30
|
+
'{{cms:not_page:content}}',
|
31
|
+
'{not_a_tag}'
|
32
|
+
].each do |tag_signature|
|
33
|
+
assert_nil ComfyPress::Tag::PageRichText.initialize_tag(
|
34
|
+
cms_pages(:default), tag_signature
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_content_and_render
|
40
|
+
tag = ComfyPress::Tag::PageRichText.initialize_tag(
|
41
|
+
cms_pages(:default), '{{cms:page:content:rich_text}}'
|
42
|
+
)
|
43
|
+
assert tag.block.content.blank?
|
44
|
+
tag.block.content = 'test_content'
|
45
|
+
assert_equal 'test_content', tag.content
|
46
|
+
assert_equal 'test_content', tag.render
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class PageStringTagTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def test_initialize_tag
|
6
|
+
assert tag = ComfyPress::Tag::PageString.initialize_tag(
|
7
|
+
cms_pages(:default), '{{ cms:page:content:string }}'
|
8
|
+
)
|
9
|
+
assert_equal 'content', tag.identifier
|
10
|
+
assert_nil tag.namespace
|
11
|
+
assert tag = ComfyPress::Tag::PageString.initialize_tag(
|
12
|
+
cms_pages(:default), '{{cms:page:content:string}}'
|
13
|
+
)
|
14
|
+
assert_equal 'content', tag.identifier
|
15
|
+
assert tag = ComfyPress::Tag::PageString.initialize_tag(
|
16
|
+
cms_pages(:default), '{{cms:page:dash-content:string}}'
|
17
|
+
)
|
18
|
+
assert_equal 'dash-content', tag.identifier
|
19
|
+
assert tag = ComfyPress::Tag::PageString.initialize_tag(
|
20
|
+
cms_pages(:default), '{{cms:page:namespace.content:string}}'
|
21
|
+
)
|
22
|
+
assert_equal 'namespace.content', tag.identifier
|
23
|
+
assert_equal 'namespace', tag.namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize_tag_failure
|
27
|
+
[
|
28
|
+
'{{cms:page:content:not_string}}',
|
29
|
+
'{{cms:page:content}}',
|
30
|
+
'{{cms:not_page:content}}',
|
31
|
+
'{not_a_tag}'
|
32
|
+
].each do |tag_signature|
|
33
|
+
assert_nil ComfyPress::Tag::PageString.initialize_tag(
|
34
|
+
cms_pages(:default), tag_signature
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_content_and_render
|
40
|
+
tag = ComfyPress::Tag::PageString.initialize_tag(
|
41
|
+
cms_pages(:default), '{{cms:page:content:string}}'
|
42
|
+
)
|
43
|
+
assert tag.block.content.blank?
|
44
|
+
tag.block.content = 'test_content'
|
45
|
+
assert_equal 'test_content', tag.content
|
46
|
+
assert_equal 'test_content', tag.render
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|