comfortable_mexican_sofa 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +12 -5
  3. data/app/models/comfy/cms/translation.rb +2 -0
  4. data/app/views/comfy/admin/cms/fragments/_form_fragments.html.haml +4 -2
  5. data/lib/comfortable_mexican_sofa/content/renderer.rb +11 -3
  6. data/lib/comfortable_mexican_sofa/content/tag.rb +6 -9
  7. data/lib/comfortable_mexican_sofa/content/tags/asset.rb +1 -1
  8. data/lib/comfortable_mexican_sofa/content/tags/file.rb +1 -1
  9. data/lib/comfortable_mexican_sofa/content/tags/file_link.rb +1 -1
  10. data/lib/comfortable_mexican_sofa/content/tags/files.rb +1 -1
  11. data/lib/comfortable_mexican_sofa/content/tags/fragment.rb +2 -2
  12. data/lib/comfortable_mexican_sofa/content/tags/helper.rb +1 -1
  13. data/lib/comfortable_mexican_sofa/content/tags/partial.rb +1 -1
  14. data/lib/comfortable_mexican_sofa/content/tags/snippet.rb +1 -1
  15. data/lib/comfortable_mexican_sofa/content/tags/template.rb +1 -1
  16. data/lib/comfortable_mexican_sofa/version.rb +1 -1
  17. data/test/controllers/comfy/admin/cms/pages_controller_test.rb +8 -5
  18. data/test/controllers/comfy/cms/content_controller_test.rb +16 -0
  19. data/test/lib/content/block_test.rb +1 -1
  20. data/test/lib/content/renderer_test.rb +39 -8
  21. data/test/lib/content/tag_test.rb +10 -4
  22. data/test/lib/content/tags/asset_test.rb +35 -11
  23. data/test/lib/content/tags/checkbox_test.rb +2 -2
  24. data/test/lib/content/tags/date_test.rb +2 -2
  25. data/test/lib/content/tags/datetime_test.rb +2 -2
  26. data/test/lib/content/tags/file_link_test.rb +25 -10
  27. data/test/lib/content/tags/file_test.rb +20 -7
  28. data/test/lib/content/tags/files_test.rb +12 -5
  29. data/test/lib/content/tags/fragment_test.rb +14 -10
  30. data/test/lib/content/tags/helper_test.rb +18 -9
  31. data/test/lib/content/tags/markdown_test.rb +7 -4
  32. data/test/lib/content/tags/number_test.rb +1 -1
  33. data/test/lib/content/tags/partial_test.rb +28 -7
  34. data/test/lib/content/tags/snippet_test.rb +5 -5
  35. data/test/lib/content/tags/template_test.rb +21 -6
  36. data/test/lib/content/tags/text_test.rb +1 -1
  37. data/test/lib/content/tags/textarea_test.rb +1 -1
  38. data/test/lib/content/tags/wysiwyg_test.rb +1 -1
  39. data/test/models/layout_test.rb +34 -14
  40. data/test/models/translation_test.rb +10 -4
  41. metadata +3 -3
@@ -7,13 +7,13 @@ class ContentTagsCheckboxTest < ActiveSupport::TestCase
7
7
  end
8
8
 
9
9
  def test_init
10
- tag = ComfortableMexicanSofa::Content::Tag::Checkbox.new(@page, "test")
10
+ tag = ComfortableMexicanSofa::Content::Tag::Checkbox.new(context: @page, params: ["test"])
11
11
  assert_equal "test", tag.identifier
12
12
  end
13
13
 
14
14
  def test_content
15
15
  frag = comfy_cms_fragments(:boolean)
16
- tag = ComfortableMexicanSofa::Content::Tag::Checkbox.new(@page, frag.identifier)
16
+ tag = ComfortableMexicanSofa::Content::Tag::Checkbox.new(context: @page, params: [frag.identifier])
17
17
  assert_equal frag, tag.fragment
18
18
  assert_equal frag.boolean, tag.content
19
19
  end
@@ -7,13 +7,13 @@ class ContentTagsDateTest < ActiveSupport::TestCase
7
7
  end
8
8
 
9
9
  def test_init
10
- tag = ComfortableMexicanSofa::Content::Tag::Date.new(@page, "test")
10
+ tag = ComfortableMexicanSofa::Content::Tag::Date.new(context: @page, params: ["test"])
11
11
  assert_equal "test", tag.identifier
12
12
  end
13
13
 
14
14
  def test_content
15
15
  frag = comfy_cms_fragments(:datetime)
16
- tag = ComfortableMexicanSofa::Content::Tag::Date.new(@page, frag.identifier)
16
+ tag = ComfortableMexicanSofa::Content::Tag::Date.new(context: @page, params: [frag.identifier])
17
17
  assert_equal frag, tag.fragment
18
18
  assert_equal frag.datetime, tag.content
19
19
  end
@@ -7,13 +7,13 @@ class ContentTagsDatetimeTest < ActiveSupport::TestCase
7
7
  end
8
8
 
9
9
  def test_init
10
- tag = ComfortableMexicanSofa::Content::Tag::Datetime.new(@page, "test")
10
+ tag = ComfortableMexicanSofa::Content::Tag::Datetime.new(context: @page, params: ["test"])
11
11
  assert_equal "test", tag.identifier
12
12
  end
13
13
 
14
14
  def test_content
15
15
  frag = comfy_cms_fragments(:datetime)
16
- tag = ComfortableMexicanSofa::Content::Tag::Datetime.new(@page, frag.identifier)
16
+ tag = ComfortableMexicanSofa::Content::Tag::Datetime.new(context: @page, params: [frag.identifier])
17
17
  assert_equal frag, tag.fragment
18
18
  assert_equal frag.datetime, tag.content
19
19
  end
@@ -12,14 +12,23 @@ class ContentTagsFileLinkTest < ActiveSupport::TestCase
12
12
  # -- Tests -------------------------------------------------------------------
13
13
 
14
14
  def test_init
15
- tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, "123")
15
+ tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(context: @page, params: ["123"])
16
16
  assert_equal "123", tag.identifier
17
17
  assert_equal "url", tag.as
18
18
  end
19
19
 
20
20
  def test_init_with_params
21
- string = "123, as: image, resize: 100x100, gravity: center, crop: '100x100+0+0'"
22
- tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, string)
21
+ tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(
22
+ context: @page,
23
+ params: [
24
+ "123", {
25
+ "as" => "image",
26
+ "resize" => "100x100",
27
+ "gravity" => "center",
28
+ "crop" => "100x100+0+0"
29
+ }
30
+ ]
31
+ )
23
32
  assert_equal "123", tag.identifier
24
33
  assert_equal "image", tag.as
25
34
  assert_equal ({
@@ -32,27 +41,30 @@ class ContentTagsFileLinkTest < ActiveSupport::TestCase
32
41
  def test_init_without_identifier
33
42
  message = "Missing identifier for file link tag"
34
43
  assert_exception_raised ComfortableMexicanSofa::Content::Tag::Error, message do
35
- ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, "")
44
+ ComfortableMexicanSofa::Content::Tag::FileLink.new(context: @page)
36
45
  end
37
46
  end
38
47
 
39
48
  def test_file
40
- tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, @file.id)
49
+ tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(context: @page, params: [@file.id])
41
50
  assert tag.file.is_a?(Comfy::Cms::File)
42
51
 
43
- tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, "invalid")
52
+ tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(context: @page, params: ["invalid"])
44
53
  assert_nil tag.file
45
54
  end
46
55
 
47
56
  def test_content
48
- tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, @file.id)
57
+ tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(context: @page, params: [@file.id])
49
58
  out = rails_blob_path(tag.file.attachment, only_path: true)
50
59
  assert_equal out, tag.content
51
60
  assert_equal out, tag.render
52
61
  end
53
62
 
54
63
  def test_content_as_link
55
- tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, "#{@file.id}, as: link")
64
+ tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(
65
+ context: @page,
66
+ params: [@file.id, { "as" => "link" }]
67
+ )
56
68
  url = rails_blob_path(tag.file.attachment, only_path: true)
57
69
  out = "<a href='#{url}' target='_blank'>default file</a>"
58
70
  assert_equal out, tag.content
@@ -60,7 +72,10 @@ class ContentTagsFileLinkTest < ActiveSupport::TestCase
60
72
  end
61
73
 
62
74
  def test_content_as_image
63
- tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, "#{@file.id}, as: image")
75
+ tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(
76
+ context: @page,
77
+ params: [@file.id, { "as" => "image" }]
78
+ )
64
79
  url = rails_blob_path(tag.file.attachment, only_path: true)
65
80
  out = "<img src='#{url}' alt='default file'/>"
66
81
  assert_equal out, tag.content
@@ -68,7 +83,7 @@ class ContentTagsFileLinkTest < ActiveSupport::TestCase
68
83
  end
69
84
 
70
85
  def test_content_when_not_found
71
- tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, "invalid")
86
+ tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(context: @page, params: ["invalid"])
72
87
  assert_equal "", tag.content
73
88
  assert_equal "", tag.render
74
89
  end
@@ -11,14 +11,21 @@ class ContentTagsFileTest < ActiveSupport::TestCase
11
11
  # -- Tests -------------------------------------------------------------------
12
12
 
13
13
  def test_init
14
- tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "test")
14
+ tag = ComfortableMexicanSofa::Content::Tag::File.new(context: @page, params: ["test"])
15
15
  assert_equal "test", tag.identifier
16
16
  assert_equal "url", tag.as
17
17
  end
18
18
 
19
19
  def test_init_with_params
20
- string = "test, as: image, resize: 100x100, gravity: center, crop: '100x100+0+0'"
21
- tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, string)
20
+ tag = ComfortableMexicanSofa::Content::Tag::File.new(
21
+ context: @page,
22
+ params: ["test", {
23
+ "as" => "image",
24
+ "resize" => "100x100",
25
+ "gravity" => "center",
26
+ "crop" => "100x100+0+0"
27
+ }]
28
+ )
22
29
  assert_equal "test", tag.identifier
23
30
  assert_equal "image", tag.as
24
31
  assert_equal ({
@@ -30,26 +37,32 @@ class ContentTagsFileTest < ActiveSupport::TestCase
30
37
 
31
38
  def test_content
32
39
  frag = comfy_cms_fragments(:file)
33
- tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, frag.identifier)
40
+ tag = ComfortableMexicanSofa::Content::Tag::File.new(context: @page, params: [frag.identifier])
34
41
  assert_equal rails_blob_path(frag.attachments.first, only_path: true), tag.content
35
42
  end
36
43
 
37
44
  def test_content_as_link
38
45
  frag = comfy_cms_fragments(:file)
39
- tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "#{frag.identifier}, as: link")
46
+ tag = ComfortableMexicanSofa::Content::Tag::File.new(
47
+ context: @page,
48
+ params: [frag.identifier, { "as" => "link" }]
49
+ )
40
50
  out = "<a href='#{rails_blob_path(frag.attachments.first, only_path: true)}' target='_blank'>fragment.jpg</a>"
41
51
  assert_equal out, tag.content
42
52
  end
43
53
 
44
54
  def test_content_as_image
45
55
  frag = comfy_cms_fragments(:file)
46
- tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "#{frag.identifier}, as: image")
56
+ tag = ComfortableMexicanSofa::Content::Tag::File.new(
57
+ context: @page,
58
+ params: [frag.identifier, { "as" => "image" }]
59
+ )
47
60
  out = "<img src='#{rails_blob_path(frag.attachments.first, only_path: true)}' alt='fragment.jpg'/>"
48
61
  assert_equal out, tag.content
49
62
  end
50
63
 
51
64
  def test_content_with_no_attachment
52
- tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "test")
65
+ tag = ComfortableMexicanSofa::Content::Tag::File.new(context: @page, params: ["test"])
53
66
  assert_equal "", tag.content
54
67
  end
55
68
 
@@ -11,14 +11,21 @@ class ContentTagsFilesTest < ActiveSupport::TestCase
11
11
  # -- Tests -------------------------------------------------------------------
12
12
 
13
13
  def test_init
14
- tag = ComfortableMexicanSofa::Content::Tag::Files.new(@page, "test")
14
+ tag = ComfortableMexicanSofa::Content::Tag::Files.new(context: @page, params: ["test"])
15
15
  assert_equal "test", tag.identifier
16
16
  assert_equal "url", tag.as
17
17
  end
18
18
 
19
19
  def test_init_with_params
20
- string = "test, as: image, resize: 100x100, gravity: center, crop: '100x100+0+0'"
21
- tag = ComfortableMexicanSofa::Content::Tag::Files.new(@page, string)
20
+ tag = ComfortableMexicanSofa::Content::Tag::Files.new(
21
+ context: @page,
22
+ params: ["test", {
23
+ "as" => "image",
24
+ "resize" => "100x100",
25
+ "gravity" => "center",
26
+ "crop" => "100x100+0+0"
27
+ }]
28
+ )
22
29
  assert_equal "test", tag.identifier
23
30
  assert_equal "image", tag.as
24
31
  assert_equal ({
@@ -32,13 +39,13 @@ class ContentTagsFilesTest < ActiveSupport::TestCase
32
39
  frag = comfy_cms_fragments(:file)
33
40
  frag.update_attribute(:tag, "files")
34
41
  frag.update_attribute(:files, fixture_file_upload("files/image.jpg", "image/jpeg"))
35
- tag = ComfortableMexicanSofa::Content::Tag::Files.new(@page, frag.identifier)
42
+ tag = ComfortableMexicanSofa::Content::Tag::Files.new(context: @page, params: [frag.identifier])
36
43
  out = frag.attachments.map { |a| rails_blob_path(a, only_path: true) }.join(" ")
37
44
  assert_equal out, tag.content
38
45
  end
39
46
 
40
47
  def test_content_no_attachments
41
- tag = ComfortableMexicanSofa::Content::Tag::Files.new(@page, "test")
48
+ tag = ComfortableMexicanSofa::Content::Tag::Files.new(context: @page, params: ["test"])
42
49
  assert_equal "", tag.content
43
50
  end
44
51
 
@@ -7,7 +7,7 @@ class ContentTagsFragmentTest < ActiveSupport::TestCase
7
7
  end
8
8
 
9
9
  def test_init
10
- tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(@page, "content")
10
+ tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(context: @page, params: ["content"])
11
11
  assert_equal @page, tag.context
12
12
  assert_equal "content", tag.identifier
13
13
  assert_equal true, tag.renderable
@@ -16,48 +16,52 @@ class ContentTagsFragmentTest < ActiveSupport::TestCase
16
16
 
17
17
  def test_init_with_params
18
18
  tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(
19
- @page, "content, render: false, namespace: test"
19
+ context: @page,
20
+ params: ["content", { "render" => "false", "namespace" => "test" }]
20
21
  )
21
22
  assert_equal false, tag.renderable
22
23
  assert_equal "test", tag.namespace
23
24
  end
24
25
 
25
26
  def test_init_without_identifier
26
- message = "Missing identifier for fragment tag"
27
+ message = "Missing identifier for fragment tag: {{cms:markdown}}"
27
28
  assert_exception_raised ComfortableMexicanSofa::Content::Tag::Error, message do
28
- ComfortableMexicanSofa::Content::Tag::Fragment.new(@page, "")
29
+ ComfortableMexicanSofa::Content::Tag::Fragment.new(context: @page, source: "{{cms:markdown}}")
29
30
  end
30
31
  end
31
32
 
32
33
  def test_fragment
33
- tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(@page, "content")
34
+ tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(context: @page, params: ["content"])
34
35
  assert_equal comfy_cms_fragments(:default), tag.fragment
35
36
  end
36
37
 
37
38
  def test_fragment_new_record
38
- tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(@page, "new")
39
+ tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(context: @page, params: ["new"])
39
40
  fragment = tag.fragment
40
41
  assert fragment.is_a?(Comfy::Cms::Fragment)
41
42
  assert fragment.new_record?
42
43
  end
43
44
 
44
45
  def test_content
45
- tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(@page, "content")
46
+ tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(context: @page, params: ["content"])
46
47
  assert_equal "content", tag.content
47
48
  end
48
49
 
49
50
  def test_content_new_record
50
- tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(@page, "new")
51
+ tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(context: @page, params: ["new"])
51
52
  assert_nil tag.content
52
53
  end
53
54
 
54
55
  def test_render
55
- tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(@page, "content")
56
+ tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(context: @page, params: ["content"])
56
57
  assert_equal "content", tag.render
57
58
  end
58
59
 
59
60
  def test_render_when_not_renderable
60
- tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(@page, "content, render: false")
61
+ tag = ComfortableMexicanSofa::Content::Tag::Fragment.new(
62
+ context: @page,
63
+ params: ["content", { "render" => "false" }]
64
+ )
61
65
  assert_equal "", tag.render
62
66
  end
63
67
 
@@ -3,13 +3,16 @@ require_relative "../../../test_helper"
3
3
  class ContentTagsHelperTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_init
6
- tag = ComfortableMexicanSofa::Content::Tag::Helper.new(@page, "helper_method")
6
+ tag = ComfortableMexicanSofa::Content::Tag::Helper.new(context: @page, params: ["helper_method"])
7
7
  assert_equal "helper_method", tag.method_name
8
8
  assert_equal [], tag.params
9
9
  end
10
10
 
11
11
  def test_init_with_params
12
- tag = ComfortableMexicanSofa::Content::Tag::Helper.new(@page, "helper_method, param, key: val")
12
+ tag = ComfortableMexicanSofa::Content::Tag::Helper.new(
13
+ context: @page,
14
+ params: ["helper_method", "param", { "key" => "val" }]
15
+ )
13
16
  assert_equal "helper_method", tag.method_name
14
17
  assert_equal ["param", { "key" => "val" }], tag.params
15
18
  end
@@ -17,35 +20,41 @@ class ContentTagsHelperTest < ActiveSupport::TestCase
17
20
  def test_init_without_method_name
18
21
  message = "Missing method name for helper tag"
19
22
  assert_exception_raised ComfortableMexicanSofa::Content::Tag::Error, message do
20
- ComfortableMexicanSofa::Content::Tag::Helper.new(@page, "")
23
+ ComfortableMexicanSofa::Content::Tag::Helper.new(context: @page)
21
24
  end
22
25
  end
23
26
 
24
27
  def test_content
25
- tag = ComfortableMexicanSofa::Content::Tag::Helper.new(@page, "method_name, param, key: val")
28
+ tag = ComfortableMexicanSofa::Content::Tag::Helper.new(
29
+ context: @page,
30
+ params: ["method_name", "param", { "key" => "val" }]
31
+ )
26
32
  assert_equal "<%= method_name(\"param\",{\"key\"=>\"val\"}) %>", tag.content
27
33
  end
28
34
 
29
35
  def test_render
30
- tag = ComfortableMexicanSofa::Content::Tag::Helper.new(@page, "method_name, param, key: val")
36
+ tag = ComfortableMexicanSofa::Content::Tag::Helper.new(
37
+ context: @page,
38
+ params: ["method_name", "param", { "key" => "val" }]
39
+ )
31
40
  assert_equal "<%= method_name(\"param\",{\"key\"=>\"val\"}) %>", tag.render
32
41
  end
33
42
 
34
43
  def test_render_with_whitelist
35
44
  ComfortableMexicanSofa.config.allowed_helpers = %i[tester eval]
36
- tag = ComfortableMexicanSofa::Content::Tag::Helper.new(@page, "tester")
45
+ tag = ComfortableMexicanSofa::Content::Tag::Helper.new(context: @page, params: ["tester"])
37
46
  assert_equal "<%= tester() %>", tag.render
38
47
 
39
- tag = ComfortableMexicanSofa::Content::Tag::Helper.new(@page, "eval")
48
+ tag = ComfortableMexicanSofa::Content::Tag::Helper.new(context: @page, params: ["eval"])
40
49
  assert_equal "<%= eval() %>", tag.render
41
50
 
42
- tag = ComfortableMexicanSofa::Content::Tag::Helper.new(@page, "not_whitelisted")
51
+ tag = ComfortableMexicanSofa::Content::Tag::Helper.new(context: @page, params: ["not_whitelisted"])
43
52
  assert_nil tag.render
44
53
  end
45
54
 
46
55
  def test_render_with_blacklist
47
56
  ComfortableMexicanSofa::Content::Tag::Helper::BLACKLIST.each do |method|
48
- tag = ComfortableMexicanSofa::Content::Tag::Helper.new(@page, method)
57
+ tag = ComfortableMexicanSofa::Content::Tag::Helper.new(context: @page, params: [method])
49
58
  assert_nil tag.render
50
59
  end
51
60
  end
@@ -7,13 +7,13 @@ class ContentTagsMarkdownTest < ActiveSupport::TestCase
7
7
  end
8
8
 
9
9
  def test_init
10
- tag = ComfortableMexicanSofa::Content::Tag::Markdown.new(@page, "test")
10
+ tag = ComfortableMexicanSofa::Content::Tag::Markdown.new(context: @page, params: ["test"])
11
11
  assert_equal "test", tag.identifier
12
12
  end
13
13
 
14
14
  def test_content
15
15
  frag = comfy_cms_fragments(:default)
16
- tag = ComfortableMexicanSofa::Content::Tag::Markdown.new(@page, frag.identifier)
16
+ tag = ComfortableMexicanSofa::Content::Tag::Markdown.new(context: @page, params: [frag.identifier])
17
17
  assert_equal frag, tag.fragment
18
18
  assert_equal frag.content, tag.content
19
19
  end
@@ -21,13 +21,16 @@ class ContentTagsMarkdownTest < ActiveSupport::TestCase
21
21
  def test_render
22
22
  frag = comfy_cms_fragments(:default)
23
23
  frag.update_column(:content, "**test**")
24
- tag = ComfortableMexicanSofa::Content::Tag::Markdown.new(@page, frag.identifier)
24
+ tag = ComfortableMexicanSofa::Content::Tag::Markdown.new(context: @page, params: [frag.identifier])
25
25
  assert_equal "<p><strong>test</strong></p>\n", tag.render
26
26
  end
27
27
 
28
28
  def test_render_unrenderable
29
29
  frag = comfy_cms_fragments(:default)
30
- tag = ComfortableMexicanSofa::Content::Tag::Markdown.new(@page, "#{frag.identifier}, render: false")
30
+ tag = ComfortableMexicanSofa::Content::Tag::Markdown.new(
31
+ context: @page,
32
+ params: [frag.identifier, { "render" => "false" }]
33
+ )
31
34
  assert_equal "", tag.render
32
35
  end
33
36
 
@@ -7,7 +7,7 @@ class ContentTagsNumberTest < ActiveSupport::TestCase
7
7
  end
8
8
 
9
9
  def test_init
10
- tag = ComfortableMexicanSofa::Content::Tag::Number.new(@page, "test")
10
+ tag = ComfortableMexicanSofa::Content::Tag::Number.new(context: @page, params: ["test"])
11
11
  assert_equal "test", tag.identifier
12
12
  end
13
13
 
@@ -3,13 +3,19 @@ require_relative "../../../test_helper"
3
3
  class ContentTagsPartialTest < ActiveSupport::TestCase
4
4
 
5
5
  def test_init
6
- tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial")
6
+ tag = ComfortableMexicanSofa::Content::Tag::Partial.new(
7
+ context: @page,
8
+ params: ["path/to/partial"]
9
+ )
7
10
  assert_equal "path/to/partial", tag.path
8
11
  assert_equal ({}), tag.locals
9
12
  end
10
13
 
11
14
  def test_init_with_locals
12
- tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial, key: val")
15
+ tag = ComfortableMexicanSofa::Content::Tag::Partial.new(
16
+ context: @page,
17
+ params: ["path/to/partial", { "key" => "val" }]
18
+ )
13
19
  assert_equal "path/to/partial", tag.path
14
20
  assert_equal ({ "key" => "val" }), tag.locals
15
21
  end
@@ -17,27 +23,42 @@ class ContentTagsPartialTest < ActiveSupport::TestCase
17
23
  def test_init_without_path
18
24
  message = "Missing path for partial tag"
19
25
  assert_exception_raised ComfortableMexicanSofa::Content::Tag::Error, message do
20
- ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "key: val")
26
+ ComfortableMexicanSofa::Content::Tag::Partial.new(
27
+ context: @page,
28
+ params: [{ "key" => "val" }]
29
+ )
21
30
  end
22
31
  end
23
32
 
24
33
  def test_content
25
- tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial, key: val")
34
+ tag = ComfortableMexicanSofa::Content::Tag::Partial.new(
35
+ context: @page,
36
+ params: ["path/to/partial", { "key" => "val" }]
37
+ )
26
38
  assert_equal "<%= render partial: \"path/to/partial\", locals: {\"key\"=>\"val\"} %>", tag.content
27
39
  end
28
40
 
29
41
  def test_render
30
- tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial, key: val")
42
+ tag = ComfortableMexicanSofa::Content::Tag::Partial.new(
43
+ context: @page,
44
+ params: ["path/to/partial", { "key" => "val" }]
45
+ )
31
46
  assert_equal "<%= render partial: \"path/to/partial\", locals: {\"key\"=>\"val\"} %>", tag.render
32
47
  end
33
48
 
34
49
  def test_render_with_whitelist
35
50
  ComfortableMexicanSofa.config.allowed_partials = ["safe/path"]
36
51
 
37
- tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial")
52
+ tag = ComfortableMexicanSofa::Content::Tag::Partial.new(
53
+ context: @page,
54
+ params: ["path/to/partial"]
55
+ )
38
56
  assert_equal "", tag.render
39
57
 
40
- tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "safe/path")
58
+ tag = ComfortableMexicanSofa::Content::Tag::Partial.new(
59
+ context: @page,
60
+ params: ["safe/path"]
61
+ )
41
62
  assert_equal "<%= render partial: \"safe/path\", locals: {} %>", tag.render
42
63
  end
43
64