comfortable_mexican_sofa 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/VERSION +1 -1
  2. data/app/models/cms_layout.rb +1 -1
  3. data/comfortable_mexican_sofa.gemspec +1 -1
  4. data/lib/comfortable_mexican_sofa/cms_tag.rb +4 -4
  5. data/lib/comfortable_mexican_sofa/cms_tag/field_datetime.rb +5 -5
  6. data/lib/comfortable_mexican_sofa/cms_tag/field_integer.rb +1 -1
  7. data/lib/comfortable_mexican_sofa/cms_tag/field_string.rb +1 -1
  8. data/lib/comfortable_mexican_sofa/cms_tag/field_text.rb +1 -1
  9. data/lib/comfortable_mexican_sofa/cms_tag/helper.rb +1 -1
  10. data/lib/comfortable_mexican_sofa/cms_tag/page_datetime.rb +6 -6
  11. data/lib/comfortable_mexican_sofa/cms_tag/page_integer.rb +1 -1
  12. data/lib/comfortable_mexican_sofa/cms_tag/page_string.rb +1 -1
  13. data/lib/comfortable_mexican_sofa/cms_tag/page_text.rb +1 -1
  14. data/lib/comfortable_mexican_sofa/cms_tag/partial.rb +1 -1
  15. data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +1 -1
  16. data/test/cms_seeds/test.host/layouts/default.yml +1 -1
  17. data/test/cms_seeds/test.host/layouts/nested.yml +1 -1
  18. data/test/cms_seeds/test.host/pages/child/subchild.yml +1 -1
  19. data/test/fixtures/cms_blocks.yml +1 -1
  20. data/test/fixtures/cms_layouts.yml +7 -7
  21. data/test/functional/cms_admin/pages_controller_test.rb +8 -8
  22. data/test/unit/cms_block_test.rb +1 -1
  23. data/test/unit/cms_configuration_test.rb +1 -1
  24. data/test/unit/cms_layout_test.rb +8 -8
  25. data/test/unit/cms_page_test.rb +1 -1
  26. data/test/unit/cms_site_test.rb +1 -1
  27. data/test/unit/cms_snippet_test.rb +1 -1
  28. data/test/unit/cms_tag_test.rb +24 -16
  29. data/test/unit/cms_tags/field_datetime_test.rb +12 -12
  30. data/test/unit/cms_tags/field_integer_test.rb +12 -12
  31. data/test/unit/cms_tags/field_string_test.rb +12 -12
  32. data/test/unit/cms_tags/field_text_test.rb +11 -11
  33. data/test/unit/cms_tags/helper_test.rb +10 -10
  34. data/test/unit/cms_tags/page_datetime_test.rb +12 -12
  35. data/test/unit/cms_tags/page_integer_test.rb +12 -12
  36. data/test/unit/cms_tags/page_string_test.rb +12 -12
  37. data/test/unit/cms_tags/page_text_test.rb +13 -13
  38. data/test/unit/cms_tags/partial_test.rb +15 -15
  39. data/test/unit/cms_tags/snippet_test.rb +12 -12
  40. data/test/unit/cms_upload_test.rb +1 -1
  41. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.9
1
+ 1.0.10
@@ -52,7 +52,7 @@ class CmsLayout < ActiveRecord::Base
52
52
  end
53
53
 
54
54
  # -- Instance Methods -----------------------------------------------------
55
- # magical merging tag is <cms:page:content> If parent layout has this tag
55
+ # magical merging tag is {cms:page:content} If parent layout has this tag
56
56
  # defined its content will be merged. If no such tag found, parent content
57
57
  # is ignored.
58
58
  def merged_content
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{comfortable_mexican_sofa}
8
- s.version = "1.0.9"
8
+ s.version = "1.0.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oleg Khabarov", "The Working Group Inc"]
@@ -6,7 +6,7 @@
6
6
  # end
7
7
  module CmsTag
8
8
 
9
- TOKENIZER_REGEX = /(<\s*cms:.*?\/?>)|((?:[^<]|\<(?!\s*cms:.*?\/?>))+)/
9
+ TOKENIZER_REGEX = /(\{\s*cms:.*?\})|((?:[^\{]|\{(?!\s*cms:.*?\}))+)/
10
10
 
11
11
  attr_accessor :params,
12
12
  :parent
@@ -14,9 +14,9 @@ module CmsTag
14
14
  module ClassMethods
15
15
  # Regex that is used to match tags in the content
16
16
  # Example:
17
- # /<\s*?cms:page:(\w+)\/?>/
17
+ # /\{\s*?cms:page:(\w+)\}/
18
18
  # will match tags like these:
19
- # <cms:page:my_label/>
19
+ # {cms:page:my_label}
20
20
  def regex_tag_signature
21
21
  nil
22
22
  end
@@ -53,7 +53,7 @@ module CmsTag
53
53
 
54
54
  # Regex that is used to identify instance of the tag
55
55
  # Example:
56
- # /<\s*?cms:page:tag_label\/?>/
56
+ # /<\{\s*?cms:page:tag_label\}/
57
57
  def regex_tag_signature
58
58
  nil
59
59
  end
@@ -1,20 +1,20 @@
1
1
  class CmsTag::FieldDateTime < CmsBlock
2
2
 
3
3
  include CmsTag
4
-
4
+
5
5
  def self.regex_tag_signature(label = nil)
6
6
  label ||= /\w+/
7
- /<\s*cms:field:(#{label}):datetime\s*\/?>/
7
+ /\{\s*cms:field:(#{label}):datetime\s*\}/
8
8
  end
9
-
9
+
10
10
  def regex_tag_signature
11
11
  self.class.regex_tag_signature(label)
12
12
  end
13
-
13
+
14
14
  def content=(value)
15
15
  write_attribute(:content_datetime, value)
16
16
  end
17
-
17
+
18
18
  def content
19
19
  read_attribute(:content_datetime)
20
20
  end
@@ -4,7 +4,7 @@ class CmsTag::FieldInteger < CmsBlock
4
4
 
5
5
  def self.regex_tag_signature(label = nil)
6
6
  label ||= /\w+/
7
- /<\s*cms:field:(#{label}):integer\s*\/?>/
7
+ /\{\s*cms:field:(#{label}):integer\s*\}/
8
8
  end
9
9
 
10
10
  def regex_tag_signature
@@ -4,7 +4,7 @@ class CmsTag::FieldString < CmsBlock
4
4
 
5
5
  def self.regex_tag_signature(label = nil)
6
6
  label ||= /\w+/
7
- /<\s*cms:field:(#{label}):?(?:string)?\s*\/?>/
7
+ /\{\s*cms:field:(#{label}):?(?:string)?\s*\}/
8
8
  end
9
9
 
10
10
  def regex_tag_signature
@@ -4,7 +4,7 @@ class CmsTag::FieldText < CmsBlock
4
4
 
5
5
  def self.regex_tag_signature(label = nil)
6
6
  label ||= /\w+/
7
- /<\s*?cms:field:(#{label}):?(?:text)?\s*?\/?>/
7
+ /\{\s*cms:field:(#{label}):?(?:text)?\s*?\}/
8
8
  end
9
9
 
10
10
  def regex_tag_signature
@@ -6,7 +6,7 @@ class CmsTag::Helper
6
6
 
7
7
  def self.regex_tag_signature(label = nil)
8
8
  label ||= /\w+/
9
- /<\s*cms:helper:(#{label}):?(.*?)\s*\/?>/
9
+ /\{\s*cms:helper:(#{label}):?(.*?)\s*\}/
10
10
  end
11
11
 
12
12
  def regex_tag_signature
@@ -1,20 +1,20 @@
1
1
  class CmsTag::PageDateTime < CmsBlock
2
-
2
+
3
3
  include CmsTag
4
-
4
+
5
5
  def self.regex_tag_signature(label = nil)
6
6
  label ||= /\w+/
7
- /<\s*cms:page:(#{label}):datetime\s*\/?>/
7
+ /\{\s*cms:page:(#{label}):datetime\s*\}/
8
8
  end
9
-
9
+
10
10
  def regex_tag_signature
11
11
  self.class.regex_tag_signature(label)
12
12
  end
13
-
13
+
14
14
  def content=(value)
15
15
  write_attribute(:content_datetime, value)
16
16
  end
17
-
17
+
18
18
  def content
19
19
  read_attribute(:content_datetime)
20
20
  end
@@ -4,7 +4,7 @@ class CmsTag::PageInteger < CmsBlock
4
4
 
5
5
  def self.regex_tag_signature(label = nil)
6
6
  label ||= /\w+/
7
- /<\s*cms:page:(#{label}):integer\s*\/?>/
7
+ /\{\s*cms:page:(#{label}):integer\s*\}/
8
8
  end
9
9
 
10
10
  def regex_tag_signature
@@ -4,7 +4,7 @@ class CmsTag::PageString < CmsBlock
4
4
 
5
5
  def self.regex_tag_signature(label = nil)
6
6
  label ||= /\w+/
7
- /<\s*cms:page:(#{label}):string\s*\/?>/
7
+ /\{\s*cms:page:(#{label}):string\s*\}/
8
8
  end
9
9
 
10
10
  def regex_tag_signature
@@ -4,7 +4,7 @@ class CmsTag::PageText < CmsBlock
4
4
 
5
5
  def self.regex_tag_signature(label = nil)
6
6
  label ||= /\w+/
7
- /<\s*cms:page:(#{label}):?(?:text)?\s*\/?>/
7
+ /\{\s*cms:page:(#{label}):?(?:text)?\s*\}/
8
8
  end
9
9
 
10
10
  def regex_tag_signature
@@ -6,7 +6,7 @@ class CmsTag::Partial
6
6
 
7
7
  def self.regex_tag_signature(label = nil)
8
8
  label ||= /[\w\/]+/
9
- /<\s*cms:partial:(#{label}):?(.*?)\s*\/?>/
9
+ /\{\s*cms:partial:(#{label}):?(.*?)\s*\}/
10
10
  end
11
11
 
12
12
  def regex_tag_signature
@@ -10,7 +10,7 @@ class CmsTag::Snippet < CmsSnippet
10
10
 
11
11
  def self.regex_tag_signature(label = nil)
12
12
  label ||= /\w+/
13
- /<\s*cms:snippet:(#{label})\s*\/?>/
13
+ /\{\s*cms:snippet:(#{label})\s*\}/
14
14
  end
15
15
 
16
16
  def regex_tag_signature
@@ -1,2 +1,2 @@
1
1
  label: Default Layout
2
- content: <html><cms:page:content/></html>
2
+ content: <html>{cms:page:content}</html>
@@ -1,3 +1,3 @@
1
1
  label: Nested Layout
2
2
  parent: default
3
- content: <div><cms:page:content/></div>
3
+ content: <div>{cms:page:content}</div>
@@ -7,4 +7,4 @@ cms_blocks_attributes:
7
7
  label: content
8
8
  type: CmsTag::PageText
9
9
  content: |-
10
- Sub Child Page Content <cms:snippet:default/>
10
+ Sub Child Page Content {cms:snippet:default}
@@ -10,5 +10,5 @@ default_page_text:
10
10
  label: default_page_text
11
11
  content_text: |-
12
12
  default_page_text_content_a
13
- <cms:snippet:default>
13
+ {cms:snippet:default}
14
14
  default_page_text_content_b
@@ -4,11 +4,11 @@ default:
4
4
  slug: default
5
5
  parent:
6
6
  content: |-
7
- <cms:field:default_field_text:text>
7
+ {cms:field:default_field_text:text}
8
8
  layout_content_a
9
- <cms:page:default_page_text:text>
9
+ {cms:page:default_page_text:text}
10
10
  layout_content_b
11
- <cms:snippet:default>
11
+ {cms:snippet:default}
12
12
  layout_content_c
13
13
  css: default_css
14
14
  js: default_js
@@ -19,8 +19,8 @@ nested:
19
19
  slug: nested
20
20
  parent:
21
21
  content: |-
22
- <cms:page:header/>
23
- <cms:page:content/>
22
+ {cms:page:header}
23
+ {cms:page:content}
24
24
  css: nested_css
25
25
  js: nested_js
26
26
 
@@ -30,7 +30,7 @@ child:
30
30
  slug: child
31
31
  parent: nested
32
32
  content: |-
33
- <cms:page:left_column>
34
- <cms:page:right_column>
33
+ {cms:page:left_column}
34
+ {cms:page:right_column}
35
35
  css: child_css
36
36
  js: child_js
@@ -20,7 +20,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
20
20
  end
21
21
 
22
22
  def test_get_new_with_field_datetime
23
- cms_layouts(:default).update_attribute(:content, '<cms:field:test_label:datetime>')
23
+ cms_layouts(:default).update_attribute(:content, '{cms:field:test_label:datetime}')
24
24
  get :new
25
25
  assert_select "input[type='datetime'][name='cms_page[cms_blocks_attributes][][content]']"
26
26
  assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
@@ -28,7 +28,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
28
28
  end
29
29
 
30
30
  def test_get_new_with_field_integer
31
- cms_layouts(:default).update_attribute(:content, '<cms:field:test_label:integer>')
31
+ cms_layouts(:default).update_attribute(:content, '{cms:field:test_label:integer}')
32
32
  get :new
33
33
  assert_select "input[type='number'][name='cms_page[cms_blocks_attributes][][content]']"
34
34
  assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
@@ -36,7 +36,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
36
36
  end
37
37
 
38
38
  def test_get_new_with_field_string
39
- cms_layouts(:default).update_attribute(:content, '<cms:field:test_label>')
39
+ cms_layouts(:default).update_attribute(:content, '{cms:field:test_label}')
40
40
  get :new
41
41
  assert_select "input[type='text'][name='cms_page[cms_blocks_attributes][][content]']"
42
42
  assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
@@ -44,7 +44,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
44
44
  end
45
45
 
46
46
  def test_get_new_with_field_text
47
- cms_layouts(:default).update_attribute(:content, '<cms:field:test_label:text>')
47
+ cms_layouts(:default).update_attribute(:content, '{cms:field:test_label:text}')
48
48
  get :new
49
49
  assert_select "textarea[name='cms_page[cms_blocks_attributes][][content]']"
50
50
  assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
@@ -52,7 +52,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
52
52
  end
53
53
 
54
54
  def test_get_new_with_page_datetime
55
- cms_layouts(:default).update_attribute(:content, '<cms:page:test_label:datetime>')
55
+ cms_layouts(:default).update_attribute(:content, '{cms:page:test_label:datetime}')
56
56
  get :new
57
57
  assert_select "input[type='datetime'][name='cms_page[cms_blocks_attributes][][content]']"
58
58
  assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
@@ -60,7 +60,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
60
60
  end
61
61
 
62
62
  def test_get_new_with_page_integer
63
- cms_layouts(:default).update_attribute(:content, '<cms:page:test_label:integer>')
63
+ cms_layouts(:default).update_attribute(:content, '{cms:page:test_label:integer}')
64
64
  get :new
65
65
  assert_select "input[type='number'][name='cms_page[cms_blocks_attributes][][content]']"
66
66
  assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
@@ -68,7 +68,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
68
68
  end
69
69
 
70
70
  def test_get_new_with_page_string
71
- cms_layouts(:default).update_attribute(:content, '<cms:page:test_label:string>')
71
+ cms_layouts(:default).update_attribute(:content, '{cms:page:test_label:string}')
72
72
  get :new
73
73
  assert_select "input[type='text'][name='cms_page[cms_blocks_attributes][][content]']"
74
74
  assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
@@ -76,7 +76,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
76
76
  end
77
77
 
78
78
  def test_get_new_with_page_text
79
- cms_layouts(:default).update_attribute(:content, '<cms:page:test_label>')
79
+ cms_layouts(:default).update_attribute(:content, '{cms:page:test_label}')
80
80
  get :new
81
81
  assert_select "textarea[name='cms_page[cms_blocks_attributes][][content]']"
82
82
  assert_select "input[type='hidden'][name='cms_page[cms_blocks_attributes][][label]'][value='test_label']"
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class CmsBlockTest < ActiveSupport::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class CmsConfigurationTest < ActiveSupport::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class CmsLayoutTest < ActiveSupport::TestCase
4
4
 
@@ -30,12 +30,12 @@ class CmsLayoutTest < ActiveSupport::TestCase
30
30
  def test_merged_content
31
31
  parent_layout = cms_layouts(:nested)
32
32
  layout = cms_layouts(:child)
33
- assert_equal "<cms:page:header/>\n<cms:page:left_column>\n<cms:page:right_column>", layout.merged_content
34
- assert_equal "<cms:page:left_column>\n<cms:page:right_column>", layout.content
33
+ assert_equal "{cms:page:header}\n{cms:page:left_column}\n{cms:page:right_column}", layout.merged_content
34
+ assert_equal "{cms:page:left_column}\n{cms:page:right_column}", layout.content
35
35
 
36
- parent_layout.update_attribute(:content, '<cms:page:whatever/>')
36
+ parent_layout.update_attribute(:content, '{cms:page:whatever}')
37
37
  layout.reload
38
- assert_equal "<cms:page:left_column>\n<cms:page:right_column>", layout.merged_content
38
+ assert_equal "{cms:page:left_column}\n{cms:page:right_column}", layout.merged_content
39
39
  end
40
40
 
41
41
  def test_merged_css
@@ -55,12 +55,12 @@ class CmsLayoutTest < ActiveSupport::TestCase
55
55
 
56
56
  assert layout = CmsLayout.load_from_file(cms_sites(:default), 'default')
57
57
  assert_equal 'Default Layout', layout.label
58
- assert_equal '<html><cms:page:content/></html>', layout.content
58
+ assert_equal '<html>{cms:page:content}</html>', layout.content
59
59
 
60
60
  assert layout = CmsLayout.load_from_file(cms_sites(:default), 'nested')
61
61
  assert_equal 'Nested Layout', layout.label
62
- assert_equal '<div><cms:page:content/></div>', layout.content
63
- assert_equal '<html><div><cms:page:content/></div></html>', layout.merged_content
62
+ assert_equal '<div>{cms:page:content}</div>', layout.content
63
+ assert_equal '<html><div>{cms:page:content}</div></html>', layout.merged_content
64
64
  end
65
65
 
66
66
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class CmsPageTest < ActiveSupport::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class CmsSiteTest < ActiveSupport::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class CmsSnippetTest < ActiveSupport::TestCase
4
4
 
@@ -1,51 +1,59 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class CmsTagTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_tokenizer_regex
6
6
  regex = CmsTag::TOKENIZER_REGEX
7
7
 
8
- tokens = 'content<<cms:some_tag content'.scan(regex)
8
+ tokens = 'content<{cms:some_tag content'.scan(regex)
9
9
  assert_equal nil, tokens[0][0]
10
- assert_equal 'content<<cms:some_tag content', tokens[0][1]
10
+ assert_equal 'content<{cms:some_tag content', tokens[0][1]
11
11
 
12
- tokens = 'content<<cms some_tag>>content'.scan(regex)
12
+ tokens = 'content<{cms some_tag}>content'.scan(regex)
13
13
  assert_equal nil, tokens[0][0]
14
- assert_equal 'content<<cms some_tag>>content', tokens[0][1]
14
+ assert_equal 'content<{cms some_tag}>content', tokens[0][1]
15
15
 
16
- tokens = 'content<<cms:some_tag>>content'.scan(regex)
16
+ tokens = 'content<{cms:some_tag}>content'.scan(regex)
17
17
  assert_equal nil, tokens[0][0]
18
18
  assert_equal 'content<', tokens[0][1]
19
- assert_equal '<cms:some_tag>', tokens[1][0]
19
+ assert_equal '{cms:some_tag}', tokens[1][0]
20
20
  assert_equal nil, tokens[1][1]
21
21
  assert_equal nil, tokens[2][0]
22
22
  assert_equal '>content', tokens[2][1]
23
23
 
24
- tokens = 'content<<cms:type:label>>content'.scan(regex)
24
+ tokens = 'content<{cms:type:label}>content'.scan(regex)
25
25
  assert_equal nil, tokens[0][0]
26
26
  assert_equal 'content<', tokens[0][1]
27
- assert_equal '<cms:type:label>', tokens[1][0]
27
+ assert_equal '{cms:type:label}', tokens[1][0]
28
28
  assert_equal nil, tokens[1][1]
29
29
  assert_equal nil, tokens[2][0]
30
30
  assert_equal '>content', tokens[2][1]
31
31
 
32
- tokens = 'content<<cms:type:label />>content'.scan(regex)
32
+ tokens = 'content<{cms:type:label }>content'.scan(regex)
33
33
  assert_equal nil, tokens[0][0]
34
34
  assert_equal 'content<', tokens[0][1]
35
- assert_equal '<cms:type:label />', tokens[1][0]
35
+ assert_equal '{cms:type:label }', tokens[1][0]
36
36
  assert_equal nil, tokens[1][1]
37
37
  assert_equal nil, tokens[2][0]
38
38
  assert_equal '>content', tokens[2][1]
39
39
 
40
- tokens = 'content<< cms:type:la/b el />>content'.scan(regex)
40
+ tokens = 'content<{ cms:type:la/b el }>content'.scan(regex)
41
41
  assert_equal nil, tokens[0][0]
42
42
  assert_equal 'content<', tokens[0][1]
43
- assert_equal '< cms:type:la/b el />', tokens[1][0]
43
+ assert_equal '{ cms:type:la/b el }', tokens[1][0]
44
44
  assert_equal nil, tokens[1][1]
45
45
  assert_equal nil, tokens[2][0]
46
46
  assert_equal '>content', tokens[2][1]
47
47
  end
48
48
 
49
+ def test_tokenizer_regex_limit
50
+ string = '<p>text</p>' * 400
51
+ tokens = string.scan(CmsTag::TOKENIZER_REGEX)
52
+ assert_equal 1, tokens.count
53
+ assert_equal nil, tokens[0][0]
54
+ assert_equal string, tokens[0][1]
55
+ end
56
+
49
57
  def test_content_for_existing_page
50
58
  page = cms_pages(:default)
51
59
  assert page.cms_tags.blank?
@@ -107,7 +115,7 @@ class CmsTagTest < ActiveSupport::TestCase
107
115
  },
108
116
  {
109
117
  :label => 'default_page_text',
110
- :content => "new_default_page_text_content\n<cms:snippet:default>",
118
+ :content => "new_default_page_text_content\n{cms:snippet:default}",
111
119
  :type => 'CmsTag::PageText'
112
120
  },
113
121
  {
@@ -138,7 +146,7 @@ class CmsTagTest < ActiveSupport::TestCase
138
146
 
139
147
  def test_content_with_repeated_tags
140
148
  page = cms_pages(:default)
141
- page.cms_layout.content << "\n<cms:page:default_page_text:text>"
149
+ page.cms_layout.content << "\n{cms:page:default_page_text:text}"
142
150
  page.cms_layout.save!
143
151
 
144
152
  assert_equal rendered_content_formatter(
@@ -169,7 +177,7 @@ class CmsTagTest < ActiveSupport::TestCase
169
177
  def test_content_with_cyclical_tags
170
178
  page = cms_pages(:default)
171
179
  snippet = cms_snippets(:default)
172
- snippet.update_attribute(:content, "infinite <cms:page:default> loop")
180
+ snippet.update_attribute(:content, "infinite {cms:page:default} loop")
173
181
  assert_equal rendered_content_formatter(
174
182
  '
175
183
  layout_content_a
@@ -1,30 +1,30 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class FieldDateTimeTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:field:content:datetime/>
8
- <cms:field:content:datetime>
9
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:field:content:datetime }',
8
+ '{cms:field:content:datetime}'
9
+ ].each do |tag_signature|
10
10
  assert tag = CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), tag_signature)
11
11
  assert_equal 'content', tag.label
12
12
  end
13
13
  end
14
14
 
15
15
  def test_initialize_tag_failure
16
- %w(
17
- <cms:field:content:not_datetime/>
18
- <cms:field:content/>
19
- <cms:not_field:content/>
20
- not_a_tag
21
- ).each do |tag_signature|
16
+ [
17
+ '{cms:field:content:not_datetime}',
18
+ '{cms:field:content}',
19
+ '{cms:not_field:content}',
20
+ 'not_a_tag'
21
+ ].each do |tag_signature|
22
22
  assert_nil CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), tag_signature)
23
23
  end
24
24
  end
25
25
 
26
26
  def test_content_and_render
27
- tag = CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), "<cms:field:content:datetime>")
27
+ tag = CmsTag::FieldDateTime.initialize_tag(cms_pages(:default), '{cms:field:content:datetime}')
28
28
  assert tag.content.blank?
29
29
  time = 2.days.ago
30
30
  tag.content = time
@@ -1,30 +1,30 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class FieldIntegerTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:field:content:integer/>
8
- <cms:field:content:integer>
9
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:field:content:integer }',
8
+ '{cms:field:content:integer}'
9
+ ].each do |tag_signature|
10
10
  assert tag = CmsTag::FieldInteger.initialize_tag(cms_pages(:default), tag_signature)
11
11
  assert_equal 'content', tag.label
12
12
  end
13
13
  end
14
14
 
15
15
  def test_initialize_tag_failure
16
- %w(
17
- <cms:field:content:not_integer/>
18
- <cms:field:content/>
19
- <cms:not_field:content/>
20
- not_a_tag
21
- ).each do |tag_signature|
16
+ [
17
+ '{cms:field:content:not_integer}',
18
+ '{cms:field:content}',
19
+ '{cms:not_field:content}',
20
+ 'not_a_tag'
21
+ ].each do |tag_signature|
22
22
  assert_nil CmsTag::FieldInteger.initialize_tag(cms_pages(:default), tag_signature)
23
23
  end
24
24
  end
25
25
 
26
26
  def test_content_and_render
27
- tag = CmsTag::FieldInteger.initialize_tag(cms_pages(:default), "<cms:field:content:integer>")
27
+ tag = CmsTag::FieldInteger.initialize_tag(cms_pages(:default), '{cms:field:content:integer}')
28
28
  assert tag.content.blank?
29
29
  tag.content = '5'
30
30
  assert_equal 5, tag.content
@@ -1,30 +1,30 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class FieldStringTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:field:content:string/>
8
- <cms:field:content:string>
9
- <cms:field:content>
10
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:field:content:string }',
8
+ '{cms:field:content:string}',
9
+ '{cms:field:content}'
10
+ ].each do |tag_signature|
11
11
  assert tag = CmsTag::FieldString.initialize_tag(cms_pages(:default), tag_signature)
12
12
  assert_equal 'content', tag.label
13
13
  end
14
14
  end
15
15
 
16
16
  def test_initialize_tag_failure
17
- %w(
18
- <cms:field:content:not_string/>
19
- <cms:not_field:content/>
20
- not_a_tag
21
- ).each do |tag_signature|
17
+ [
18
+ '{cms:field:content:not_string}',
19
+ '{cms:not_field:content}',
20
+ 'not_a_tag'
21
+ ].each do |tag_signature|
22
22
  assert_nil CmsTag::FieldString.initialize_tag(cms_pages(:default), tag_signature)
23
23
  end
24
24
  end
25
25
 
26
26
  def test_content_and_render
27
- tag = CmsTag::FieldString.initialize_tag(cms_pages(:default), "<cms:field:content>")
27
+ tag = CmsTag::FieldString.initialize_tag(cms_pages(:default), '{cms:field:content}')
28
28
  assert tag.content.blank?
29
29
  tag.content = 'test_content'
30
30
  assert_equal 'test_content', tag.content
@@ -1,29 +1,29 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class FieldTextTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:field:content:text/>
8
- <cms:field:content:text>
9
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:field:content:text }',
8
+ '{cms:field:content:text}'
9
+ ].each do |tag_signature|
10
10
  assert tag = CmsTag::FieldText.initialize_tag(cms_pages(:default), tag_signature)
11
11
  assert_equal 'content', tag.label
12
12
  end
13
13
  end
14
14
 
15
15
  def test_initialize_tag_failure
16
- %w(
17
- <cms:field:content:not_text/>
18
- <cms:not_field:content:text/>
19
- not_a_tag
20
- ).each do |tag_signature|
16
+ [
17
+ '{cms:field:content:not_text}',
18
+ '{cms:not_field:content:text}',
19
+ 'not_a_tag'
20
+ ].each do |tag_signature|
21
21
  assert_nil CmsTag::FieldText.initialize_tag(cms_pages(:default), tag_signature)
22
22
  end
23
23
  end
24
24
 
25
25
  def test_content_and_render
26
- tag = CmsTag::FieldText.initialize_tag(cms_pages(:default), "<cms:field:content:text>")
26
+ tag = CmsTag::FieldText.initialize_tag(cms_pages(:default), '{cms:field:content:text}')
27
27
  assert tag.content.blank?
28
28
  tag.content = 'test_content'
29
29
  assert_equal 'test_content', tag.content
@@ -1,33 +1,33 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class HelperTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- assert CmsTag::Helper.initialize_tag(cms_pages(:default), '<cms:helper:method_name/>')
6
+ assert CmsTag::Helper.initialize_tag(cms_pages(:default), '{ cms:helper:method_name }')
7
7
  end
8
8
 
9
9
  def test_initialize_tag_with_parameters
10
- assert tag = CmsTag::Helper.initialize_tag(cms_pages(:default), '<cms:helper:method_name:param1:param2/>')
10
+ assert tag = CmsTag::Helper.initialize_tag(cms_pages(:default), '{ cms:helper:method_name:param1:param2 }')
11
11
  assert tag.label = 'method_name'
12
12
  assert tag.params = 'param1:param2'
13
13
  end
14
14
 
15
15
  def test_initialize_tag_failure
16
- %w(
17
- <cms:helper>
18
- <cms:not_helper:method_name/>
19
- not_a_tag
20
- ).each do |tag_signature|
16
+ [
17
+ '{cms:helper}',
18
+ '{cms:not_helper:method_name}',
19
+ 'not_a_tag'
20
+ ].each do |tag_signature|
21
21
  assert_nil CmsTag::Helper.initialize_tag(cms_pages(:default), tag_signature)
22
22
  end
23
23
  end
24
24
 
25
25
  def test_content_and_render
26
- tag = CmsTag::Helper.initialize_tag(cms_pages(:default), "<cms:helper:method_name/>")
26
+ tag = CmsTag::Helper.initialize_tag(cms_pages(:default), '{cms:helper:method_name}')
27
27
  assert_equal "<%= method_name() %>", tag.content
28
28
  assert_equal "<%= method_name() %>", tag.render
29
29
 
30
- tag = CmsTag::Helper.initialize_tag(cms_pages(:default), "<cms:helper:method_name:param1:param2/>")
30
+ tag = CmsTag::Helper.initialize_tag(cms_pages(:default), '{cms:helper:method_name:param1:param2}')
31
31
  assert_equal "<%= method_name('param1', 'param2') %>", tag.content
32
32
  assert_equal "<%= method_name('param1', 'param2') %>", tag.render
33
33
  end
@@ -1,30 +1,30 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class PageDateTimeTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:page:content:datetime/>
8
- <cms:page:content:datetime>
9
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:page:content:datetime }',
8
+ '{cms:page:content:datetime}'
9
+ ].each do |tag_signature|
10
10
  assert tag = CmsTag::PageDateTime.initialize_tag(cms_pages(:default), tag_signature)
11
11
  assert_equal 'content', tag.label
12
12
  end
13
13
  end
14
14
 
15
15
  def test_initialize_tag_failure
16
- %w(
17
- <cms:page:content:not_datetime/>
18
- <cms:page:content/>
19
- <cms:not_page:content/>
20
- not_a_tag
21
- ).each do |tag_signature|
16
+ [
17
+ '{cms:page:content:not_datetime}',
18
+ '{cms:page:content}',
19
+ '{cms:not_page:content}',
20
+ 'not_a_tag'
21
+ ].each do |tag_signature|
22
22
  assert_nil CmsTag::PageDateTime.initialize_tag(cms_pages(:default), tag_signature)
23
23
  end
24
24
  end
25
25
 
26
26
  def test_content_and_render
27
- tag = CmsTag::PageDateTime.initialize_tag(cms_pages(:default), "<cms:page:content:datetime>")
27
+ tag = CmsTag::PageDateTime.initialize_tag(cms_pages(:default), '{cms:page:content:datetime}')
28
28
  assert tag.content.blank?
29
29
  time = 2.days.ago
30
30
  tag.content = time
@@ -1,30 +1,30 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class PageIntegerTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:page:content:integer/>
8
- <cms:page:content:integer>
9
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:page:content:integer }',
8
+ '{cms:page:content:integer}'
9
+ ].each do |tag_signature|
10
10
  assert tag = CmsTag::PageInteger.initialize_tag(cms_pages(:default), tag_signature)
11
11
  assert_equal 'content', tag.label
12
12
  end
13
13
  end
14
14
 
15
15
  def test_initialize_tag_failure
16
- %w(
17
- <cms:page:content:not_integer/>
18
- <cms:page:content/>
19
- <cms:not_page:content/>
20
- not_a_tag
21
- ).each do |tag_signature|
16
+ [
17
+ '{cms:page:content:not_integer}',
18
+ '{cms:page:content}',
19
+ '{cms:not_page:content}',
20
+ 'not_a_tag'
21
+ ].each do |tag_signature|
22
22
  assert_nil CmsTag::PageInteger.initialize_tag(cms_pages(:default), tag_signature)
23
23
  end
24
24
  end
25
25
 
26
26
  def test_content_and_render
27
- tag = CmsTag::PageInteger.initialize_tag(cms_pages(:default), "<cms:page:content:integer>")
27
+ tag = CmsTag::PageInteger.initialize_tag(cms_pages(:default), '{cms:page:content:integer}')
28
28
  assert tag.content.blank?
29
29
  tag.content = '5'
30
30
  assert_equal 5, tag.content
@@ -1,30 +1,30 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class PageStringTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:page:content:string/>
8
- <cms:page:content:string>
9
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:page:content:string }',
8
+ '{cms:page:content:string}'
9
+ ].each do |tag_signature|
10
10
  assert tag = CmsTag::PageString.initialize_tag(cms_pages(:default), tag_signature)
11
11
  assert_equal 'content', tag.label
12
12
  end
13
13
  end
14
14
 
15
15
  def test_initialize_tag_failure
16
- %w(
17
- <cms:page:content:not_string/>
18
- <cms:page:content/>
19
- <cms:not_page:content/>
20
- not_a_tag
21
- ).each do |tag_signature|
16
+ [
17
+ '{cms:page:content:not_string}',
18
+ '{cms:page:content}',
19
+ '{cms:not_page:content}',
20
+ 'not_a_tag'
21
+ ].each do |tag_signature|
22
22
  assert_nil CmsTag::PageString.initialize_tag(cms_pages(:default), tag_signature)
23
23
  end
24
24
  end
25
25
 
26
26
  def test_content_and_render
27
- tag = CmsTag::PageString.initialize_tag(cms_pages(:default), "<cms:page:content:string>")
27
+ tag = CmsTag::PageString.initialize_tag(cms_pages(:default), '{cms:page:content:string}')
28
28
  assert tag.content.blank?
29
29
  tag.content = 'test_content'
30
30
  assert_equal 'test_content', tag.content
@@ -1,31 +1,31 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class PageTextTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:page:content:text/>
8
- <cms:page:content/>
9
- <cms:page:content>
10
- <cms:page:content:text>
11
- ).each do |tag_signature|
6
+ [
7
+ ' {cms:page:content:text} ',
8
+ '{cms:page:content}',
9
+ '{cms:page:content}',
10
+ '{cms:page:content:text}'
11
+ ].each do |tag_signature|
12
12
  assert tag = CmsTag::PageText.initialize_tag(cms_pages(:default), tag_signature)
13
13
  assert_equal 'content', tag.label
14
14
  end
15
15
  end
16
16
 
17
17
  def test_initialize_tag_failure
18
- %w(
19
- <cms:page:content:not_text/>
20
- <cms:not_page:content/>
21
- not_a_tag
22
- ).each do |tag_signature|
18
+ [
19
+ '{cms:page:content:not_text}',
20
+ '{cms:not_page:content}',
21
+ 'not_a_tag'
22
+ ].each do |tag_signature|
23
23
  assert_nil CmsTag::PageText.initialize_tag(cms_pages(:default), tag_signature)
24
24
  end
25
25
  end
26
26
 
27
27
  def test_content_and_render
28
- tag = CmsTag::PageText.initialize_tag(cms_pages(:default), "<cms:page:content>")
28
+ tag = CmsTag::PageText.initialize_tag(cms_pages(:default), '{cms:page:content}')
29
29
  assert tag.content.blank?
30
30
  tag.content = 'test_content'
31
31
  assert_equal 'test_content', tag.content
@@ -1,38 +1,38 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class PartialTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:partial:partial_name/>
8
- <cms:partial:path/to/partial>
9
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:partial:partial_name }',
8
+ '{cms:partial:path/to/partial}'
9
+ ].each do |tag_signature|
10
10
  assert tag = CmsTag::Partial.initialize_tag(cms_pages(:default), tag_signature)
11
11
  end
12
12
  end
13
13
 
14
14
  def test_initialize_tag_with_parameters
15
- assert tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '<cms:partial:path/to/partial:param1:param2/>')
15
+ assert tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '{cms:partial:path/to/partial:param1:param2}')
16
16
  assert tag.label = 'path/to/partial'
17
17
  assert tag.params = 'param1:param2'
18
18
  end
19
19
 
20
20
  def test_initialize_tag_failure
21
- %w(
22
- <cms:partial>
23
- <cms:not_partial:label/>
24
- not_a_tag
25
- ).each do |tag_signature|
21
+ [
22
+ '{cms:partial}',
23
+ '{cms:not_partial:label}',
24
+ 'not_a_tag'
25
+ ].each do |tag_signature|
26
26
  assert_nil CmsTag::Partial.initialize_tag(cms_pages(:default), tag_signature)
27
27
  end
28
28
  end
29
29
 
30
30
  def test_content_and_render
31
- tag = CmsTag::Partial.initialize_tag(cms_pages(:default), "<cms:partial:path/to/patial>")
32
- assert_equal "<%= render :partial => 'path/to/patial' %>", tag.content
33
- assert_equal "<%= render :partial => 'path/to/patial' %>", tag.render
31
+ tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '{cms:partial:path/to/partial}')
32
+ assert_equal "<%= render :partial => 'path/to/partial' %>", tag.content
33
+ assert_equal "<%= render :partial => 'path/to/partial' %>", tag.render
34
34
 
35
- tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '<cms:partial:path/to/partial:param1:param2/>')
35
+ tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '{cms:partial:path/to/partial:param1:param2}')
36
36
  assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1', :param_2 => 'param2'} %>", tag.content
37
37
  assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1', :param_2 => 'param2'} %>", tag.render
38
38
  end
@@ -1,33 +1,33 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class SnippetTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_initialize_tag
6
- %w(
7
- <cms:snippet:label/>
8
- <cms:snippet:label>
9
- ).each do |tag_signature|
6
+ [
7
+ '{ cms:snippet:label }',
8
+ '{cms:snippet:label}'
9
+ ].each do |tag_signature|
10
10
  assert tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), tag_signature)
11
11
  assert_equal 'label', tag.slug
12
12
  end
13
13
  end
14
14
 
15
15
  def test_initialize_tag_failure
16
- %w(
17
- <cms:snippet>
18
- <cms:not_snippet:label/>
19
- not_a_tag
20
- ).each do |tag_signature|
16
+ [
17
+ '{cms:snippet}',
18
+ '{cms:not_snippet:label}',
19
+ 'not_a_tag'
20
+ ].each do |tag_signature|
21
21
  assert_nil CmsTag::Snippet.initialize_tag(cms_pages(:default), tag_signature)
22
22
  end
23
23
  end
24
24
 
25
25
  def test_content_and_render
26
- tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), "<cms:snippet:default>")
26
+ tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), '{cms:snippet:default}')
27
27
  assert_equal 'default_snippet_content', tag.content
28
28
  assert_equal 'default_snippet_content', tag.render
29
29
 
30
- tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), "<cms:snippet:doesnot_exist>")
30
+ tag = CmsTag::Snippet.initialize_tag(cms_pages(:default), "{cms:snippet:doesnot_exist}")
31
31
  assert_equal nil, tag.content
32
32
  assert_equal '', tag.render
33
33
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class CmsUploadTest < ActiveSupport::TestCase
4
4
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfortable_mexican_sofa
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 9
10
- version: 1.0.9
9
+ - 10
10
+ version: 1.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Oleg Khabarov