now you can have fields with rich_text
Oleg
committed Mar 15, 2012
commit 86d8d41129ccbc5a11d3704339e86664f97acc3b
Showing 4
changed files with
70 additions
and 1 deletions
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb
+2
-1
| @@ | @@ -82,7 +82,8 @@ class ComfortableMexicanSofa::Configuration |
| 'en' => 'English', | |
| 'es' => 'Español', | |
| 'pt-BR' => 'Português Brasileiro', | |
| - | 'zh-CN' => '简体中文' |
| + | 'zh-CN' => '简体中文', |
| + | 'ja' => '日本語' |
| } | |
| @admin_locale = nil | |
| @database_config = nil | |
comfortable_mexican_sofa/tags/field_rich_text.rb b/lib/comfortable_mexican_sofa/tags/field_rich_text.rb
+17
-0
| @@ | @@ -0,0 +1,17 @@ |
| + | class ComfortableMexicanSofa::Tag::FieldRichText |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(identifier = nil) |
| + | identifier ||= /[\w\-]+/ |
| + | /\{\{\s*cms:field:(#{identifier}):rich_text\s*?\}\}/ |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | def render |
| + | '' |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/functional/cms_admin/pages_controller_test.rb
+8
-0
| @@ | @@ -77,6 +77,14 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase |
| assert_select "textarea[name='page[blocks_attributes][0][content]'][class='code']" | |
| assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']" | |
| end | |
| + | |
| + | def test_get_new_with_rich_page_text |
| + | cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label:rich_text}}') |
| + | get :new, :site_id => cms_sites(:default) |
| + | assert_response :success |
| + | assert_select "textarea[name='page[blocks_attributes][0][content]'][class='rich_text']" |
| + | assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']" |
| + | end |
| def test_get_new_with_page_datetime | |
| cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:datetime}}') | |
test/unit/tags/field_rich_text_test.rb
+43
-0
| @@ | @@ -0,0 +1,43 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class FieldRichTextTagTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag( |
| + | cms_pages(:default), '{{ cms:field:content:rich_text }}' |
| + | ) |
| + | assert_equal 'content', tag.identifier |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:rich_text}}' |
| + | ) |
| + | assert_equal 'content', tag.identifier |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:dash-content:rich_text}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.identifier |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:field:content:not_rich_text}}', |
| + | '{{cms:field:content}}', |
| + | '{{cms:not_page:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:rich_text}}' |
| + | ) |
| + | assert tag.block.content.blank? |
| + | tag.block.content = 'test_content' |
| + | assert_equal 'test_content', tag.content |
| + | assert_equal '', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |