comfortable_mexican_sofa 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +12 -5
- data/app/models/comfy/cms/translation.rb +2 -0
- data/app/views/comfy/admin/cms/fragments/_form_fragments.html.haml +4 -2
- data/lib/comfortable_mexican_sofa/content/renderer.rb +11 -3
- data/lib/comfortable_mexican_sofa/content/tag.rb +6 -9
- data/lib/comfortable_mexican_sofa/content/tags/asset.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/file.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/file_link.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/files.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/fragment.rb +2 -2
- data/lib/comfortable_mexican_sofa/content/tags/helper.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/partial.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/snippet.rb +1 -1
- data/lib/comfortable_mexican_sofa/content/tags/template.rb +1 -1
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- data/test/controllers/comfy/admin/cms/pages_controller_test.rb +8 -5
- data/test/controllers/comfy/cms/content_controller_test.rb +16 -0
- data/test/lib/content/block_test.rb +1 -1
- data/test/lib/content/renderer_test.rb +39 -8
- data/test/lib/content/tag_test.rb +10 -4
- data/test/lib/content/tags/asset_test.rb +35 -11
- data/test/lib/content/tags/checkbox_test.rb +2 -2
- data/test/lib/content/tags/date_test.rb +2 -2
- data/test/lib/content/tags/datetime_test.rb +2 -2
- data/test/lib/content/tags/file_link_test.rb +25 -10
- data/test/lib/content/tags/file_test.rb +20 -7
- data/test/lib/content/tags/files_test.rb +12 -5
- data/test/lib/content/tags/fragment_test.rb +14 -10
- data/test/lib/content/tags/helper_test.rb +18 -9
- data/test/lib/content/tags/markdown_test.rb +7 -4
- data/test/lib/content/tags/number_test.rb +1 -1
- data/test/lib/content/tags/partial_test.rb +28 -7
- data/test/lib/content/tags/snippet_test.rb +5 -5
- data/test/lib/content/tags/template_test.rb +21 -6
- data/test/lib/content/tags/text_test.rb +1 -1
- data/test/lib/content/tags/textarea_test.rb +1 -1
- data/test/lib/content/tags/wysiwyg_test.rb +1 -1
- data/test/models/layout_test.rb +34 -14
- data/test/models/translation_test.rb +10 -4
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 79703d049752d5effd488e8aec9c2bfe55088532c485fa98ff3135d9b672d131
|
|
4
|
+
data.tar.gz: 2989239f43a6a8830e52dc9090ce06608f472af7c73078587bc5a8a01b1b9ca6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08b837b7639498ddccccf9cfb8bc292ffb904af74bbebe4d522544005ae690db9cb90b4ebdda5230f7ed6c215687d4c62732c4c7003194543fa35871ff31b6d7'
|
|
7
|
+
data.tar.gz: 58bb9995dcdb937ac75c5f93cd1721f37e5a795537917770fab4aac221bddbf1bd1c214379375604e507c9b4c34b1ce1f206d98b1194f9afadc9fd971b5ce638
|
data/README.md
CHANGED
|
@@ -67,11 +67,20 @@ After creating a Site, you need to make a Layout. Layout is the template of your
|
|
|
67
67
|
</html>
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
[See Wiki entry on available Tags you can use](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags)
|
|
71
|
-
|
|
72
70
|
Once you have a layout, you may start creating pages and populating content. It's that easy.
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
## Documentation
|
|
73
|
+
|
|
74
|
+
For more information on how to use this CMS please refer to the [Wiki](https://github.com/comfy/comfortable-mexican-sofa/wiki). Section that might be of interest is the entry
|
|
75
|
+
on [Content Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags).
|
|
76
|
+
|
|
77
|
+
[Comfy Demo App](https://github.com/comfy/comfy-demo) also can be used as an
|
|
78
|
+
example of a default Rails app with CMS installed.
|
|
79
|
+
|
|
80
|
+
## Add-ons
|
|
81
|
+
|
|
82
|
+
If you want to add a Blog functionality to your app take a look at
|
|
83
|
+
[ComfyBlog](https://github.com/comfy/comfy-blog).
|
|
75
84
|
|
|
76
85
|

|
|
77
86
|
|
|
@@ -89,8 +98,6 @@ ComfortableMexicanSofa repository can be ran like a regular Rails application in
|
|
|
89
98
|
development environment. It's as easy to work on as any other Rails app out there.
|
|
90
99
|
For more detail take a look at [CONTRIBUTING](CONTRIBUTING.md)
|
|
91
100
|
|
|
92
|
-
[](https://www.codetriage.com/comfy/comfortable-mexican-sofa)
|
|
93
|
-
|
|
94
101
|
#### Help and Contact
|
|
95
102
|
|
|
96
103
|
Gitter: https://gitter.im/comfy/comfortable-mexican-sofa
|
|
@@ -36,5 +36,7 @@
|
|
|
36
36
|
= fragments.field(record, tag, frag_index)
|
|
37
37
|
- frag_index += 1
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
- rescue ComfortableMexicanSofa::Content::Renderer::SyntaxError, ComfortableMexicanSofa::Content::Tag::Error => e
|
|
41
|
+
.alert.alert-danger
|
|
42
|
+
= e
|
|
@@ -71,7 +71,11 @@ class ComfortableMexicanSofa::Content::Renderer
|
|
|
71
71
|
while (string = ss.scan_until(TAG_REGEX))
|
|
72
72
|
text = string.sub(ss[0], "")
|
|
73
73
|
tokens << text unless text.empty?
|
|
74
|
-
tokens << {
|
|
74
|
+
tokens << {
|
|
75
|
+
tag_class: ss[:class],
|
|
76
|
+
tag_params: ss[:params].strip,
|
|
77
|
+
source: ss[0]
|
|
78
|
+
}
|
|
75
79
|
end
|
|
76
80
|
text = ss.rest
|
|
77
81
|
tokens << text if text.present?
|
|
@@ -99,10 +103,14 @@ class ComfortableMexicanSofa::Content::Renderer
|
|
|
99
103
|
|
|
100
104
|
else
|
|
101
105
|
unless (klass = self.class.tags[tag_class])
|
|
102
|
-
raise SyntaxError, "Unrecognized tag
|
|
106
|
+
raise SyntaxError, "Unrecognized tag: #{token[:source]}"
|
|
103
107
|
end
|
|
104
108
|
|
|
105
|
-
tag = klass.new(
|
|
109
|
+
tag = klass.new(
|
|
110
|
+
context: @context,
|
|
111
|
+
params: ComfortableMexicanSofa::Content::ParamsParser.parse(token[:tag_params]),
|
|
112
|
+
source: token[:source]
|
|
113
|
+
)
|
|
106
114
|
nodes.last << tag
|
|
107
115
|
|
|
108
116
|
# If it's a block tag we start collecting nodes into it
|
|
@@ -2,11 +2,12 @@ class ComfortableMexicanSofa::Content::Tag
|
|
|
2
2
|
|
|
3
3
|
class Error < StandardError; end
|
|
4
4
|
|
|
5
|
-
attr_reader :context, :params
|
|
5
|
+
attr_reader :context, :params, :source
|
|
6
6
|
|
|
7
|
-
def initialize(context,
|
|
7
|
+
def initialize(context:, params: [], source: nil)
|
|
8
8
|
@context = context
|
|
9
|
-
@params =
|
|
9
|
+
@params = params
|
|
10
|
+
@source = source
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
# Making sure we don't leak erb from tags by accident.
|
|
@@ -18,8 +19,8 @@ class ComfortableMexicanSofa::Content::Tag
|
|
|
18
19
|
# Normally it's a string. However if tag content has tags, we need to expand
|
|
19
20
|
# them and that produces potentually more stuff
|
|
20
21
|
def nodes
|
|
21
|
-
template
|
|
22
|
-
tokens
|
|
22
|
+
template = ComfortableMexicanSofa::Content::Renderer.new(@context)
|
|
23
|
+
tokens = template.tokenize(content)
|
|
23
24
|
template.nodes(tokens)
|
|
24
25
|
end
|
|
25
26
|
|
|
@@ -31,8 +32,4 @@ class ComfortableMexicanSofa::Content::Tag
|
|
|
31
32
|
content
|
|
32
33
|
end
|
|
33
34
|
|
|
34
|
-
def parse_params_string(string)
|
|
35
|
-
ComfortableMexicanSofa::Content::ParamsParser.parse(string)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
35
|
end
|
|
@@ -9,7 +9,7 @@ class ComfortableMexicanSofa::Content::Tag::Asset < ComfortableMexicanSofa::Cont
|
|
|
9
9
|
|
|
10
10
|
attr_reader :identifier, :type, :as
|
|
11
11
|
|
|
12
|
-
def initialize(context,
|
|
12
|
+
def initialize(context:, params: [], source: nil)
|
|
13
13
|
super
|
|
14
14
|
|
|
15
15
|
options = params.extract_options!
|
|
@@ -14,7 +14,7 @@ class ComfortableMexicanSofa::Content::Tag::File < ComfortableMexicanSofa::Conte
|
|
|
14
14
|
|
|
15
15
|
delegate :rails_blob_path, to: "Rails.application.routes.url_helpers"
|
|
16
16
|
|
|
17
|
-
def initialize(context,
|
|
17
|
+
def initialize(context:, params: [], source: nil)
|
|
18
18
|
super
|
|
19
19
|
@as = options["as"] || "url"
|
|
20
20
|
@label = options["label"]
|
|
@@ -14,7 +14,7 @@ class ComfortableMexicanSofa::Content::Tag::FileLink < ComfortableMexicanSofa::C
|
|
|
14
14
|
|
|
15
15
|
delegate :rails_blob_path, to: "Rails.application.routes.url_helpers"
|
|
16
16
|
|
|
17
|
-
def initialize(context,
|
|
17
|
+
def initialize(context:, params: [], source: nil)
|
|
18
18
|
super
|
|
19
19
|
|
|
20
20
|
options = params.extract_options!
|
|
@@ -10,14 +10,14 @@ class ComfortableMexicanSofa::Content::Tag::Fragment < ComfortableMexicanSofa::C
|
|
|
10
10
|
|
|
11
11
|
attr_reader :identifier, :renderable, :namespace, :options
|
|
12
12
|
|
|
13
|
-
def initialize(context,
|
|
13
|
+
def initialize(context:, params: [], source: nil)
|
|
14
14
|
super
|
|
15
15
|
|
|
16
16
|
@options = params.extract_options!
|
|
17
17
|
@identifier = params[0]
|
|
18
18
|
|
|
19
19
|
unless @identifier.present?
|
|
20
|
-
raise Error, "Missing identifier for fragment tag"
|
|
20
|
+
raise Error, "Missing identifier for fragment tag: #{source}"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
@namespace = @options["namespace"] || "default"
|
|
@@ -8,7 +8,7 @@ class ComfortableMexicanSofa::Content::Tag::Partial < ComfortableMexicanSofa::Co
|
|
|
8
8
|
|
|
9
9
|
attr_reader :path, :locals
|
|
10
10
|
|
|
11
|
-
def initialize(context,
|
|
11
|
+
def initialize(context:, params: [], source: nil)
|
|
12
12
|
super
|
|
13
13
|
@locals = params.extract_options!
|
|
14
14
|
@path = params[0]
|
|
@@ -186,15 +186,18 @@ class Comfy::Admin::Cms::PagesControllerTest < ActionDispatch::IntegrationTest
|
|
|
186
186
|
assert_select "label.renderable-false", "B"
|
|
187
187
|
end
|
|
188
188
|
|
|
189
|
-
def
|
|
189
|
+
def test_get_new_with_invalid_tag
|
|
190
190
|
@layout.update_column(:content, "{{cms:invalid}}")
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
r :get, new_comfy_admin_cms_site_page_path(site_id: @site)
|
|
192
|
+
assert_response :success
|
|
193
|
+
assert_select "div.alert-danger", "Unrecognized tag: {{cms:invalid}}"
|
|
194
|
+
end
|
|
194
195
|
|
|
195
|
-
|
|
196
|
+
def test_get_new_with_invalid_fragment_tag
|
|
197
|
+
@layout.update_column(:content, "a {{cms:markdown}} b")
|
|
196
198
|
r :get, new_comfy_admin_cms_site_page_path(site_id: @site)
|
|
197
199
|
assert_response :success
|
|
200
|
+
assert_select "div.alert-danger", "Missing identifier for fragment tag: {{cms:markdown}}"
|
|
198
201
|
end
|
|
199
202
|
|
|
200
203
|
def test_get_new_with_repeated_tag
|
|
@@ -230,4 +230,20 @@ class Comfy::Cms::ContentControllerTest < ActionDispatch::IntegrationTest
|
|
|
230
230
|
end
|
|
231
231
|
end
|
|
232
232
|
|
|
233
|
+
def test_with_translation_with_snippet
|
|
234
|
+
translation = @page.translations.create!(
|
|
235
|
+
locale: "ja",
|
|
236
|
+
label: "Test Translation",
|
|
237
|
+
fragments_attributes: [
|
|
238
|
+
{ identifier: "content",
|
|
239
|
+
tag: "text",
|
|
240
|
+
content: "test {{cms:snippet default}} test" }
|
|
241
|
+
]
|
|
242
|
+
)
|
|
243
|
+
I18n.locale = translation.locale
|
|
244
|
+
|
|
245
|
+
get comfy_cms_render_page_path(cms_path: "")
|
|
246
|
+
assert_equal "test snippet content test", response.body
|
|
247
|
+
end
|
|
248
|
+
|
|
233
249
|
end
|
|
@@ -17,7 +17,7 @@ class ContentBlockTest < ActiveSupport::TestCase
|
|
|
17
17
|
# -- Tests -------------------------------------------------------------------
|
|
18
18
|
|
|
19
19
|
def test_block_tag_nodes
|
|
20
|
-
block = TestBlockTag.new(nil
|
|
20
|
+
block = TestBlockTag.new(context: nil)
|
|
21
21
|
assert_equal [], block.nodes
|
|
22
22
|
block.nodes << "text"
|
|
23
23
|
assert_equal ["text"], block.nodes
|
|
@@ -42,7 +42,8 @@ class ContentRendererTest < ActiveSupport::TestCase
|
|
|
42
42
|
}.freeze
|
|
43
43
|
|
|
44
44
|
setup do
|
|
45
|
-
@
|
|
45
|
+
@page = comfy_cms_pages(:default)
|
|
46
|
+
@template = ComfortableMexicanSofa::Content::Renderer.new(@page)
|
|
46
47
|
|
|
47
48
|
ComfortableMexicanSofa::Content::Renderer.register_tag(:test, TestTag)
|
|
48
49
|
ComfortableMexicanSofa::Content::Renderer.register_tag(:test_nested, TestNestedTag)
|
|
@@ -89,13 +90,17 @@ class ContentRendererTest < ActiveSupport::TestCase
|
|
|
89
90
|
end
|
|
90
91
|
|
|
91
92
|
def test_tokenize_with_tag
|
|
92
|
-
assert_equal ["test ", { tag_class: "tag", tag_params: "" }, " text"],
|
|
93
|
+
assert_equal ["test ", { tag_class: "tag", tag_params: "", source: "{{cms:tag}}" }, " text"],
|
|
93
94
|
@template.tokenize("test {{cms:tag}} text")
|
|
94
95
|
end
|
|
95
96
|
|
|
96
97
|
def test_tokenize_with_tag_and_params
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
expected = [
|
|
99
|
+
"test ",
|
|
100
|
+
{ tag_class: "tag", tag_params: "name, key:val", source: "{{cms:tag name, key:val}}" },
|
|
101
|
+
" text"
|
|
102
|
+
]
|
|
103
|
+
assert_equal expected, @template.tokenize("test {{cms:tag name, key:val}} text")
|
|
99
104
|
end
|
|
100
105
|
|
|
101
106
|
def test_tokenize_with_invalid_tag
|
|
@@ -104,8 +109,12 @@ class ContentRendererTest < ActiveSupport::TestCase
|
|
|
104
109
|
end
|
|
105
110
|
|
|
106
111
|
def test_tokenize_with_newlines
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
expected = [
|
|
113
|
+
{ tag_class: "test", tag_params: "", source: "{{cms:test}}" },
|
|
114
|
+
"\n",
|
|
115
|
+
{ tag_class: "test", tag_params: "", source: "{{cms:test}}" }
|
|
116
|
+
]
|
|
117
|
+
assert_equal expected, @template.tokenize("{{cms:test}}\n{{cms:test}}")
|
|
109
118
|
end
|
|
110
119
|
|
|
111
120
|
def test_nodes
|
|
@@ -124,6 +133,17 @@ class ContentRendererTest < ActiveSupport::TestCase
|
|
|
124
133
|
assert nodes[3].is_a?(ContentRendererTest::TestTag)
|
|
125
134
|
end
|
|
126
135
|
|
|
136
|
+
def test_nodes_with_tag_with_params
|
|
137
|
+
tokens = @template.tokenize("{{cms:test param, key: value}}")
|
|
138
|
+
nodes = @template.nodes(tokens)
|
|
139
|
+
assert_equal 1, nodes.count
|
|
140
|
+
assert nodes[0].is_a?(ContentRendererTest::TestTag)
|
|
141
|
+
tag = nodes[0]
|
|
142
|
+
assert_equal @page, tag.context
|
|
143
|
+
assert_equal ["param", { "key" => "value" }], tag.params
|
|
144
|
+
assert_equal "{{cms:test param, key: value}}", tag.source
|
|
145
|
+
end
|
|
146
|
+
|
|
127
147
|
def test_nodes_with_block_tag
|
|
128
148
|
string = "a {{cms:test_block}} b {{cms:end}} c"
|
|
129
149
|
tokens = @template.tokenize(string)
|
|
@@ -178,7 +198,8 @@ class ContentRendererTest < ActiveSupport::TestCase
|
|
|
178
198
|
def test_nodes_with_unclosed_block_tag
|
|
179
199
|
string = "a {{cms:test_block}} b"
|
|
180
200
|
tokens = @template.tokenize(string)
|
|
181
|
-
|
|
201
|
+
message = "unclosed block detected"
|
|
202
|
+
assert_exception_raised ComfortableMexicanSofa::Content::Renderer::SyntaxError, message do
|
|
182
203
|
@template.nodes(tokens)
|
|
183
204
|
end
|
|
184
205
|
end
|
|
@@ -186,7 +207,17 @@ class ContentRendererTest < ActiveSupport::TestCase
|
|
|
186
207
|
def test_nodes_with_closed_tag
|
|
187
208
|
string = "a {{cms:end}} b"
|
|
188
209
|
tokens = @template.tokenize(string)
|
|
189
|
-
|
|
210
|
+
message = "closing unopened block"
|
|
211
|
+
assert_exception_raised ComfortableMexicanSofa::Content::Renderer::SyntaxError, message do
|
|
212
|
+
@template.nodes(tokens)
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def test_nodes_with_invalid_tag
|
|
217
|
+
string = "a {{cms:invalid}} b"
|
|
218
|
+
tokens = @template.tokenize(string)
|
|
219
|
+
message = "Unrecognized tag: {{cms:invalid}}"
|
|
220
|
+
assert_exception_raised ComfortableMexicanSofa::Content::Renderer::SyntaxError, message do
|
|
190
221
|
@template.nodes(tokens)
|
|
191
222
|
end
|
|
192
223
|
end
|
|
@@ -30,18 +30,24 @@ class ContentTagTest < ActiveSupport::TestCase
|
|
|
30
30
|
|
|
31
31
|
# -- Tests -------------------------------------------------------------------
|
|
32
32
|
|
|
33
|
-
def
|
|
34
|
-
tag = TestTag.new(
|
|
33
|
+
def test_init
|
|
34
|
+
tag = TestTag.new(
|
|
35
|
+
context: comfy_cms_pages(:default),
|
|
36
|
+
params: ["param_a", { "key" => "value" }],
|
|
37
|
+
source: "source"
|
|
38
|
+
)
|
|
39
|
+
assert_equal comfy_cms_pages(:default), tag.context
|
|
35
40
|
assert_equal ["param_a", { "key" => "value" }], tag.params
|
|
41
|
+
assert_equal "source", tag.source
|
|
36
42
|
end
|
|
37
43
|
|
|
38
44
|
def test_nodes
|
|
39
|
-
tag = TestTag.new(nil, "")
|
|
45
|
+
tag = TestTag.new(context: nil, params: [], source: "")
|
|
40
46
|
assert_equal ["test tag content"], tag.nodes
|
|
41
47
|
end
|
|
42
48
|
|
|
43
49
|
def test_tag_nodes_with_nested_tag
|
|
44
|
-
tag = TestNestedTag.new(nil, "")
|
|
50
|
+
tag = TestNestedTag.new(context: nil, params: [], source: "")
|
|
45
51
|
nodes = tag.nodes
|
|
46
52
|
assert_equal 3, nodes.count
|
|
47
53
|
assert_equal "test ", nodes[0]
|
|
@@ -7,14 +7,20 @@ class ContentTagsAssetTest < ActiveSupport::TestCase
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def test_init
|
|
10
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
10
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
11
|
+
context: @page,
|
|
12
|
+
params: ["default"]
|
|
13
|
+
)
|
|
11
14
|
assert_equal "default", tag.identifier
|
|
12
15
|
assert_nil tag.type
|
|
13
16
|
assert_equal "url", tag.as
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
def test_init_with_params
|
|
17
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
20
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
21
|
+
context: @page,
|
|
22
|
+
params: ["default", { "type" => "css", "as" => "tag" }]
|
|
23
|
+
)
|
|
18
24
|
assert_equal "default", tag.identifier
|
|
19
25
|
assert_equal "css", tag.type
|
|
20
26
|
assert_equal "tag", tag.as
|
|
@@ -23,28 +29,34 @@ class ContentTagsAssetTest < ActiveSupport::TestCase
|
|
|
23
29
|
def test_init_without_identifier
|
|
24
30
|
message = "Missing layout identifier for asset tag"
|
|
25
31
|
assert_exception_raised ComfortableMexicanSofa::Content::Tag::Error, message do
|
|
26
|
-
ComfortableMexicanSofa::Content::Tag::Asset.new(@page
|
|
32
|
+
ComfortableMexicanSofa::Content::Tag::Asset.new(context: @page)
|
|
27
33
|
end
|
|
28
34
|
end
|
|
29
35
|
|
|
30
36
|
def test_layout
|
|
31
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(@page, "default")
|
|
37
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(context: @page, params: ["default"])
|
|
32
38
|
assert tag.layout.is_a?(Comfy::Cms::Layout)
|
|
33
39
|
end
|
|
34
40
|
|
|
35
41
|
def test_content_for_invalid
|
|
36
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(@page, "default")
|
|
42
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(context: @page, params: ["default"])
|
|
37
43
|
assert_nil tag.content
|
|
38
44
|
end
|
|
39
45
|
|
|
40
46
|
def test_content_for_css
|
|
41
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
47
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
48
|
+
context: @page,
|
|
49
|
+
params: ["default", { "type" => "css" }]
|
|
50
|
+
)
|
|
42
51
|
out = "/cms-css/#{@page.site_id}/#{@page.layout.identifier}/#{@page.layout.cache_buster}.css"
|
|
43
52
|
assert_equal out, tag.content
|
|
44
53
|
end
|
|
45
54
|
|
|
46
55
|
def test_content_for_css_as_tag
|
|
47
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
56
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
57
|
+
context: @page,
|
|
58
|
+
params: ["default", { "type" => "css", "as" => "tag" }]
|
|
59
|
+
)
|
|
48
60
|
out = "/cms-css/#{@page.site_id}/#{@page.layout.identifier}/#{@page.layout.cache_buster}.css"
|
|
49
61
|
out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />"
|
|
50
62
|
assert_equal out, tag.content
|
|
@@ -52,19 +64,28 @@ class ContentTagsAssetTest < ActiveSupport::TestCase
|
|
|
52
64
|
|
|
53
65
|
def test_content_for_css_with_public_cms_path
|
|
54
66
|
ComfortableMexicanSofa.config.public_cms_path = "/custom"
|
|
55
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
67
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
68
|
+
context: @page,
|
|
69
|
+
params: ["default", { "type" => "css" }]
|
|
70
|
+
)
|
|
56
71
|
out = "/custom/cms-css/#{@page.site_id}/#{@page.layout.identifier}/#{@page.layout.cache_buster}.css"
|
|
57
72
|
assert_equal out, tag.content
|
|
58
73
|
end
|
|
59
74
|
|
|
60
75
|
def test_content_for_js
|
|
61
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
76
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
77
|
+
context: @page,
|
|
78
|
+
params: ["default", { "type" => "js" }]
|
|
79
|
+
)
|
|
62
80
|
out = "/cms-js/#{@page.site_id}/#{@page.layout.identifier}/#{@page.layout.cache_buster}.js"
|
|
63
81
|
assert_equal out, tag.content
|
|
64
82
|
end
|
|
65
83
|
|
|
66
84
|
def test_content_for_js_as_tag
|
|
67
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
85
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
86
|
+
context: @page,
|
|
87
|
+
params: ["default", { "type" => "js", "as" => "tag" }]
|
|
88
|
+
)
|
|
68
89
|
out = "/cms-js/#{@page.site_id}/#{@page.layout.identifier}/#{@page.layout.cache_buster}.js"
|
|
69
90
|
out = "<script src='#{out}' type='text/javascript'></script>"
|
|
70
91
|
assert_equal out, tag.content
|
|
@@ -72,7 +93,10 @@ class ContentTagsAssetTest < ActiveSupport::TestCase
|
|
|
72
93
|
|
|
73
94
|
def test_content_for_js_with_public_cms_path
|
|
74
95
|
ComfortableMexicanSofa.config.public_cms_path = "/custom"
|
|
75
|
-
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
96
|
+
tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
|
|
97
|
+
context: @page,
|
|
98
|
+
params: ["default", { "type" => "js" }]
|
|
99
|
+
)
|
|
76
100
|
out = "/custom/cms-js/#{@page.site_id}/#{@page.layout.identifier}/#{@page.layout.cache_buster}.js"
|
|
77
101
|
assert_equal out, tag.content
|
|
78
102
|
end
|