Sha256: b88ecdf4334e41f9e9c9fafec8c2eb4b764e0b51499336756cdada0dfa5c86e8
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
require_relative "../../../test_helper" class ContentTagsFileTest < ActiveSupport::TestCase delegate :rails_blob_path, to: "Rails.application.routes.url_helpers" setup do @page = comfy_cms_pages(:default) end # -- Tests ------------------------------------------------------------------- def test_init tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "test") assert_equal "test", tag.identifier assert_equal "url", tag.as end def test_init_with_params string = "test, as: image, resize: 100x100, gravity: center, crop: '100x100+0+0'" tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, string) assert_equal "test", tag.identifier assert_equal "image", tag.as assert_equal ({ "resize" => "100x100", "gravity" => "center", "crop" => "100x100+0+0" }), tag.variant_attrs end def test_content frag = comfy_cms_fragments(:file) tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, frag.identifier) assert_equal rails_blob_path(frag.attachments.first, only_path: true), tag.content end def test_content_as_link frag = comfy_cms_fragments(:file) tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "#{frag.identifier}, as: link") out = "<a href='#{rails_blob_path(frag.attachments.first, only_path: true)}' target='_blank'>fragment.jpg</a>" assert_equal out, tag.content end def test_content_as_image frag = comfy_cms_fragments(:file) tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "#{frag.identifier}, as: image") out = "<img src='#{rails_blob_path(frag.attachments.first, only_path: true)}' alt='fragment.jpg'/>" assert_equal out, tag.content end def test_content_with_no_attachment tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "test") assert_equal "", tag.content end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comfortable_mexican_sofa-2.0.8 | test/lib/content/tags/file_test.rb |