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.
- data/VERSION +1 -1
- data/app/models/cms_layout.rb +1 -1
- data/comfortable_mexican_sofa.gemspec +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag.rb +4 -4
- data/lib/comfortable_mexican_sofa/cms_tag/field_datetime.rb +5 -5
- data/lib/comfortable_mexican_sofa/cms_tag/field_integer.rb +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag/field_string.rb +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag/field_text.rb +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag/helper.rb +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag/page_datetime.rb +6 -6
- data/lib/comfortable_mexican_sofa/cms_tag/page_integer.rb +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag/page_string.rb +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag/page_text.rb +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag/partial.rb +1 -1
- data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +1 -1
- data/test/cms_seeds/test.host/layouts/default.yml +1 -1
- data/test/cms_seeds/test.host/layouts/nested.yml +1 -1
- data/test/cms_seeds/test.host/pages/child/subchild.yml +1 -1
- data/test/fixtures/cms_blocks.yml +1 -1
- data/test/fixtures/cms_layouts.yml +7 -7
- data/test/functional/cms_admin/pages_controller_test.rb +8 -8
- data/test/unit/cms_block_test.rb +1 -1
- data/test/unit/cms_configuration_test.rb +1 -1
- data/test/unit/cms_layout_test.rb +8 -8
- data/test/unit/cms_page_test.rb +1 -1
- data/test/unit/cms_site_test.rb +1 -1
- data/test/unit/cms_snippet_test.rb +1 -1
- data/test/unit/cms_tag_test.rb +24 -16
- data/test/unit/cms_tags/field_datetime_test.rb +12 -12
- data/test/unit/cms_tags/field_integer_test.rb +12 -12
- data/test/unit/cms_tags/field_string_test.rb +12 -12
- data/test/unit/cms_tags/field_text_test.rb +11 -11
- data/test/unit/cms_tags/helper_test.rb +10 -10
- data/test/unit/cms_tags/page_datetime_test.rb +12 -12
- data/test/unit/cms_tags/page_integer_test.rb +12 -12
- data/test/unit/cms_tags/page_string_test.rb +12 -12
- data/test/unit/cms_tags/page_text_test.rb +13 -13
- data/test/unit/cms_tags/partial_test.rb +15 -15
- data/test/unit/cms_tags/snippet_test.rb +12 -12
- data/test/unit/cms_upload_test.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.10
|
data/app/models/cms_layout.rb
CHANGED
@@ -52,7 +52,7 @@ class CmsLayout < ActiveRecord::Base
|
|
52
52
|
end
|
53
53
|
|
54
54
|
# -- Instance Methods -----------------------------------------------------
|
55
|
-
# magical merging tag is
|
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.
|
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 = /(
|
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
|
-
#
|
17
|
+
# /\{\s*?cms:page:(\w+)\}/
|
18
18
|
# will match tags like these:
|
19
|
-
#
|
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
|
-
|
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
|
@@ -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
|
-
|
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
|
@@ -1,2 +1,2 @@
|
|
1
1
|
label: Default Layout
|
2
|
-
content: <html
|
2
|
+
content: <html>{cms:page:content}</html>
|
@@ -4,11 +4,11 @@ default:
|
|
4
4
|
slug: default
|
5
5
|
parent:
|
6
6
|
content: |-
|
7
|
-
|
7
|
+
{cms:field:default_field_text:text}
|
8
8
|
layout_content_a
|
9
|
-
|
9
|
+
{cms:page:default_page_text:text}
|
10
10
|
layout_content_b
|
11
|
-
|
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
|
-
|
23
|
-
|
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
|
-
|
34
|
-
|
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, '
|
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, '
|
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, '
|
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, '
|
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, '
|
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, '
|
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, '
|
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, '
|
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']"
|
data/test/unit/cms_block_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
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 "
|
34
|
-
assert_equal "
|
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, '
|
36
|
+
parent_layout.update_attribute(:content, '{cms:page:whatever}')
|
37
37
|
layout.reload
|
38
|
-
assert_equal "
|
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
|
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
|
63
|
-
assert_equal '<html><div
|
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
|
data/test/unit/cms_page_test.rb
CHANGED
data/test/unit/cms_site_test.rb
CHANGED
data/test/unit/cms_tag_test.rb
CHANGED
@@ -1,51 +1,59 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
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
|
8
|
+
tokens = 'content<{cms:some_tag content'.scan(regex)
|
9
9
|
assert_equal nil, tokens[0][0]
|
10
|
-
assert_equal 'content
|
10
|
+
assert_equal 'content<{cms:some_tag content', tokens[0][1]
|
11
11
|
|
12
|
-
tokens = 'content
|
12
|
+
tokens = 'content<{cms some_tag}>content'.scan(regex)
|
13
13
|
assert_equal nil, tokens[0][0]
|
14
|
-
assert_equal 'content
|
14
|
+
assert_equal 'content<{cms some_tag}>content', tokens[0][1]
|
15
15
|
|
16
|
-
tokens = 'content
|
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 '
|
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
|
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 '
|
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
|
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 '
|
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
|
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 '
|
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
|
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
|
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
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
not_a_tag
|
21
|
-
|
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),
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
not_a_tag
|
21
|
-
|
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),
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
not_a_tag
|
21
|
-
|
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),
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
not_a_tag
|
20
|
-
|
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),
|
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__)
|
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), '
|
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), '
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
not_a_tag
|
20
|
-
|
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),
|
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),
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
not_a_tag
|
21
|
-
|
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),
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
not_a_tag
|
21
|
-
|
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),
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
not_a_tag
|
21
|
-
|
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),
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
not_a_tag
|
22
|
-
|
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),
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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), '
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
not_a_tag
|
25
|
-
|
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),
|
32
|
-
assert_equal "<%= render :partial => 'path/to/
|
33
|
-
assert_equal "<%= render :partial => 'path/to/
|
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), '
|
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__)
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
not_a_tag
|
20
|
-
|
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),
|
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), "
|
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
|
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:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 10
|
10
|
+
version: 1.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Oleg Khabarov
|