woah. bad ignore file
Oleg
committed May 02, 2011
commit bee2a21e43671eae582871c706445c22f3fe7dfe
Showing 25
changed files with
758 additions
and 1 deletions
.gitignore
+0
-1
| @@ | @@ -11,4 +11,3 @@ rdoc |
| /tmp | |
| public/cms-css/ | |
| public/cms-js/ | |
| - | tags |
comfortable_mexican_sofa/tags/field_datetime.rb b/lib/comfortable_mexican_sofa/tags/field_datetime.rb
+21
-0
| @@ | @@ -0,0 +1,21 @@ |
| + | class ComfortableMexicanSofa::Tag::FieldDateTime |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:field:(#{label}):datetime\s*\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | def render |
| + | '' |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/field_integer.rb b/lib/comfortable_mexican_sofa/tags/field_integer.rb
+21
-0
| @@ | @@ -0,0 +1,21 @@ |
| + | class ComfortableMexicanSofa::Tag::FieldInteger |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:field:(#{label}):integer\s*\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | def render |
| + | '' |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/field_string.rb b/lib/comfortable_mexican_sofa/tags/field_string.rb
+21
-0
| @@ | @@ -0,0 +1,21 @@ |
| + | class ComfortableMexicanSofa::Tag::FieldString |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:field:(#{label}):?(?:string)?\s*\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | def render |
| + | '' |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/field_text.rb b/lib/comfortable_mexican_sofa/tags/field_text.rb
+21
-0
| @@ | @@ -0,0 +1,21 @@ |
| + | class ComfortableMexicanSofa::Tag::FieldText |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:field:(#{label}):?(?:text)?\s*?\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | def render |
| + | '' |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/helper.rb b/lib/comfortable_mexican_sofa/tags/helper.rb
+13
-0
| @@ | @@ -0,0 +1,13 @@ |
| + | class ComfortableMexicanSofa::Tag::Helper |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:helper:(#{label}):?(.*?)\s*\}\}/ |
| + | end |
| + | |
| + | def content |
| + | "<%= #{label}(#{params.split(':').collect{|p| "'#{p}'"}.join(', ')}) %>" |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/page_datetime.rb b/lib/comfortable_mexican_sofa/tags/page_datetime.rb
+17
-0
| @@ | @@ -0,0 +1,17 @@ |
| + | class ComfortableMexicanSofa::Tag::PageDateTime |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:page:(#{label}):datetime\s*\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/page_integer.rb b/lib/comfortable_mexican_sofa/tags/page_integer.rb
+17
-0
| @@ | @@ -0,0 +1,17 @@ |
| + | class ComfortableMexicanSofa::Tag::PageInteger |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:page:(#{label}):integer\s*\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/page_rich_text.rb b/lib/comfortable_mexican_sofa/tags/page_rich_text.rb
+17
-0
| @@ | @@ -0,0 +1,17 @@ |
| + | class ComfortableMexicanSofa::Tag::PageRichText |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:page:(#{label}):rich_text\s*\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/page_string.rb b/lib/comfortable_mexican_sofa/tags/page_string.rb
+17
-0
| @@ | @@ -0,0 +1,17 @@ |
| + | class ComfortableMexicanSofa::Tag::PageString |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:page:(#{label}):string\s*\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/page_text.rb b/lib/comfortable_mexican_sofa/tags/page_text.rb
+17
-0
| @@ | @@ -0,0 +1,17 @@ |
| + | class ComfortableMexicanSofa::Tag::PageText |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:page:(#{label}):?(?:text)?\s*\}\}/ |
| + | end |
| + | |
| + | def content=(value) |
| + | block.content = value |
| + | end |
| + | |
| + | def content |
| + | block.content |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/partial.rb b/lib/comfortable_mexican_sofa/tags/partial.rb
+14
-0
| @@ | @@ -0,0 +1,14 @@ |
| + | class ComfortableMexicanSofa::Tag::Partial |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\/\-]+/ |
| + | /\{\{\s*cms:partial:(#{label}):?(.*?)\s*\}\}/ |
| + | end |
| + | |
| + | def content |
| + | ps = params.split(':').collect_with_index{|p, i| ":param_#{i+1} => '#{p}'"}.join(', ') |
| + | "<%= render :partial => '#{label}'#{ps.blank?? nil : ", :locals => {#{ps}}"} %>" |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/snippet.rb b/lib/comfortable_mexican_sofa/tags/snippet.rb
+13
-0
| @@ | @@ -0,0 +1,13 @@ |
| + | class ComfortableMexicanSofa::Tag::Snippet |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-]+/ |
| + | /\{\{\s*cms:snippet:(#{label})\s*\}\}/ |
| + | end |
| + | |
| + | def content |
| + | snippet.content |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/field_datetime_test.rb
+44
-0
| @@ | @@ -0,0 +1,44 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class FieldDateTimeTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldDateTime.initialize_tag( |
| + | cms_pages(:default), '{{ cms:field:content:datetime }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldDateTime.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:datetime}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldDateTime.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:dash-content:datetime}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:field:content:not_datetime}}', |
| + | '{{cms:field:content}}', |
| + | '{{cms:not_field:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::FieldDateTime.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::FieldDateTime.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:datetime}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | time = 2.days.ago |
| + | tag.content = time |
| + | assert_equal time, tag.content |
| + | assert_equal '', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/field_integer_test.rb
+43
-0
| @@ | @@ -0,0 +1,43 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class FieldIntegerTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldInteger.initialize_tag( |
| + | cms_pages(:default), '{{ cms:field:content:integer }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldInteger.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:integer}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldInteger.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:dash-content:integer}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:field:content:not_integer}}', |
| + | '{{cms:field:content}}', |
| + | '{{cms:not_field:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::FieldInteger.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::FieldInteger.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:integer}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | tag.content = '5' |
| + | assert_equal '5', tag.content |
| + | assert_equal '', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/field_string_test.rb
+46
-0
| @@ | @@ -0,0 +1,46 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class FieldStringTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldString.initialize_tag( |
| + | cms_pages(:default), '{{ cms:field:content:string }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldString.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:string}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldString.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldString.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:dash-content}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:field:content:not_string}}', |
| + | '{{cms:not_field:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::FieldString.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::FieldString.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | tag.content = 'test_content' |
| + | assert_equal 'test_content', tag.content |
| + | assert_equal '', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/field_text_test.rb
+42
-0
| @@ | @@ -0,0 +1,42 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class FieldTextTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldText.initialize_tag( |
| + | cms_pages(:default), '{{ cms:field:content:text }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldText.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:text}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::FieldText.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:dash-content:text}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:field:content:not_text}}', |
| + | '{{cms:not_field:content:text}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::FieldText.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::FieldText.initialize_tag( |
| + | cms_pages(:default), '{{cms:field:content:text}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | tag.content = 'test_content' |
| + | assert_equal 'test_content', tag.content |
| + | assert_equal '', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/helper_test.rb
+50
-0
| @@ | @@ -0,0 +1,50 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class HelperTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag( |
| + | cms_pages(:default), '{{ cms:helper:method_name }}' |
| + | ) |
| + | assert_equal 'method_name', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag( |
| + | cms_pages(:default), '{{ cms:helper:method-name }}' |
| + | ) |
| + | assert_equal 'method-name', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_with_parameters |
| + | assert tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag( |
| + | cms_pages(:default), '{{ cms:helper:method_name:param1:param2 }}' |
| + | ) |
| + | assert tag.label = 'method_name' |
| + | assert tag.params = 'param1:param2' |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:helper}}', |
| + | '{{cms:not_helper:method_name}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::Helper.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag( |
| + | cms_pages(:default), '{{cms:helper:method_name}}' |
| + | ) |
| + | assert_equal "<%= method_name() %>", tag.content |
| + | assert_equal "<%= method_name() %>", tag.render |
| + | |
| + | tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag( |
| + | cms_pages(:default), '{{cms:helper:method_name:param1:param2}}' |
| + | ) |
| + | assert_equal "<%= method_name('param1', 'param2') %>", tag.content |
| + | assert_equal "<%= method_name('param1', 'param2') %>", tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/page_datetime_test.rb
+44
-0
| @@ | @@ -0,0 +1,44 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class PageDateTimeTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::PageDateTime.initialize_tag( |
| + | cms_pages(:default), '{{ cms:page:content:datetime }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageDateTime.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:datetime}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageDateTime.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:dash-content:datetime}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:page:content:not_datetime}}', |
| + | '{{cms:page:content}}', |
| + | '{{cms:not_page:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::PageDateTime.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::PageDateTime.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:datetime}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | time = 2.days.ago |
| + | tag.content = time |
| + | assert_equal time, tag.content |
| + | assert_equal time.to_s, tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/page_integer_test.rb
+43
-0
| @@ | @@ -0,0 +1,43 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class PageIntegerTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::PageInteger.initialize_tag( |
| + | cms_pages(:default), '{{ cms:page:content:integer }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageInteger.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:integer}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageInteger.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:dash-content:integer}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:page:content:not_integer}}', |
| + | '{{cms:page:content}}', |
| + | '{{cms:not_page:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::PageInteger.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::PageInteger.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:integer}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | tag.content = '5' |
| + | assert_equal '5', tag.content |
| + | assert_equal '5', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/page_rich_text.rb
+43
-0
| @@ | @@ -0,0 +1,43 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class PageRichTextTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::PageRichText.initialize_tag( |
| + | cms_pages(:default), '{{ cms:page:content:rich_text }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageRichText.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:rich_text}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageRichText.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:dash-content:rich_text}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:page:content:not_rich_text}}', |
| + | '{{cms:page:content}}', |
| + | '{{cms:not_page:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::PageRichText.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::PageRichText.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:rich_text}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | tag.content = 'test_content' |
| + | assert_equal 'test_content', tag.content |
| + | assert_equal 'test_content', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/page_string_test.rb
+43
-0
| @@ | @@ -0,0 +1,43 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class PageStringTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::PageString.initialize_tag( |
| + | cms_pages(:default), '{{ cms:page:content:string }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageString.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:string}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageString.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:dash-content:string}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:page:content:not_string}}', |
| + | '{{cms:page:content}}', |
| + | '{{cms:not_page:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::PageString.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::PageString.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:string}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | tag.content = 'test_content' |
| + | assert_equal 'test_content', tag.content |
| + | assert_equal 'test_content', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/page_text_test.rb
+46
-0
| @@ | @@ -0,0 +1,46 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class PageTextTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::PageText.initialize_tag( |
| + | cms_pages(:default), '{{ cms:page:content:text }}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageText.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageText.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content:text}}' |
| + | ) |
| + | assert_equal 'content', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::PageText.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:dash-content}}' |
| + | ) |
| + | assert_equal 'dash-content', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:page:content:not_text}}', |
| + | '{{cms:not_page:content}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::PageText.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::PageText.initialize_tag( |
| + | cms_pages(:default), '{{cms:page:content}}' |
| + | ) |
| + | assert tag.content.blank? |
| + | tag.content = 'test_content' |
| + | assert_equal 'test_content', tag.content |
| + | assert_equal 'test_content', tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/partial_test.rb
+60
-0
| @@ | @@ -0,0 +1,60 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class PartialTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::Partial.initialize_tag( |
| + | cms_pages(:default), '{{ cms:partial:partial_name }}' |
| + | ) |
| + | assert_equal 'partial_name', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::Partial.initialize_tag( |
| + | cms_pages(:default), '{{cms:partial:path/to/partial}}' |
| + | ) |
| + | assert_equal 'path/to/partial', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::Partial.initialize_tag( |
| + | cms_pages(:default), '{{cms:partial:path/to/dashed-partial}}' |
| + | ) |
| + | assert_equal 'path/to/dashed-partial', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_with_parameters |
| + | assert tag = ComfortableMexicanSofa::Tag::Partial.initialize_tag( |
| + | cms_pages(:default), '{{cms:partial:path/to/partial:param1:param2}}' |
| + | ) |
| + | assert tag.label = 'path/to/partial' |
| + | assert tag.params = 'param1:param2' |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:partial}}', |
| + | '{{cms:not_partial:label}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::Partial.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::Partial.initialize_tag( |
| + | cms_pages(:default), '{{cms:partial:path/to/partial}}' |
| + | ) |
| + | assert_equal "<%= render :partial => 'path/to/partial' %>", tag.content |
| + | assert_equal "<%= render :partial => 'path/to/partial' %>", tag.render |
| + | |
| + | tag = ComfortableMexicanSofa::Tag::Partial.initialize_tag( |
| + | cms_pages(:default), '{{cms:partial:path/to/partial:param1}}' |
| + | ) |
| + | assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1'} %>", tag.content |
| + | assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1'} %>", tag.render |
| + | |
| + | tag = ComfortableMexicanSofa::Tag::Partial.initialize_tag( |
| + | cms_pages(:default), '{{cms:partial:path/to/partial:param1:param2}}' |
| + | ) |
| + | assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1', :param_2 => 'param2'} %>", tag.content |
| + | assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1', :param_2 => 'param2'} %>", tag.render |
| + | end |
| + | |
| + | end |
| \ No newline at end of file | |
test/unit/tags/snippet_test.rb
+45
-0
| @@ | @@ -0,0 +1,45 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class SnippetTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::Snippet.initialize_tag( |
| + | cms_pages(:default), '{{ cms:snippet:label }}' |
| + | ) |
| + | assert_equal 'label', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::Snippet.initialize_tag( |
| + | cms_pages(:default), '{{cms:snippet:label}}' |
| + | ) |
| + | assert_equal 'label', tag.label |
| + | assert tag = ComfortableMexicanSofa::Tag::Snippet.initialize_tag( |
| + | cms_pages(:default), '{{cms:snippet:dash-label}}' |
| + | ) |
| + | assert_equal 'dash-label', tag.label |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:snippet}}', |
| + | '{{cms:not_snippet:label}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::Snippet.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_content_and_render |
| + | tag = ComfortableMexicanSofa::Tag::Snippet.initialize_tag( |
| + | cms_pages(:default), '{{cms:snippet:default}}' |
| + | ) |
| + | assert_equal 'default_snippet_content', tag.content |
| + | assert_equal 'default_snippet_content', tag.render |
| + | |
| + | tag = ComfortableMexicanSofa::Tag::Snippet.initialize_tag( |
| + | cms_pages(:default), "{{cms:snippet:doesnot_exist}}" |
| + | ) |
| + | assert_equal nil, tag.content |
| + | assert_equal '', tag.render |
| + | end |
| + | end |
| \ No newline at end of file | |