Sha256: e20d6a8bb9d2d0e00f4b4004e8d86946446f1dd7783f5442ce297fc00faf8697
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
require_relative "../../../test_helper" class ContentTagsPartialTest < ActiveSupport::TestCase def test_init tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial") assert_equal "path/to/partial", tag.path assert_equal ({}), tag.locals end def test_init_with_locals tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial, key: val") assert_equal "path/to/partial", tag.path assert_equal ({ "key" => "val" }), tag.locals end def test_init_without_path message = "Missing path for partial tag" assert_exception_raised ComfortableMexicanSofa::Content::Tag::Error, message do ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "key: val") end end def test_content tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial, key: val") assert_equal "<%= render partial: '@path', locals: {\"key\"=>\"val\"} %>", tag.content end def test_render tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial, key: val") assert_equal "<%= render partial: '@path', locals: {\"key\"=>\"val\"} %>", tag.render end def test_render_with_whitelist ComfortableMexicanSofa.config.allowed_partials = ["safe/path"] tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "path/to/partial") assert_equal "", tag.render tag = ComfortableMexicanSofa::Content::Tag::Partial.new(@page, "safe/path") assert_equal "<%= render partial: '@path', locals: {} %>", tag.render end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
comfortable_mexican_sofa-2.0.4 | test/lib/content/tags/partial_test.rb |
comfortable_mexican_sofa-2.0.3 | test/lib/content/tags/partial_test.rb |