Sha256: abb95890437cea26fd65a94e15aeba08936ee97f01a722abbf208703a027b47d

Contents?: true

Size: 1019 Bytes

Versions: 4

Compression:

Stored size: 1019 Bytes

Contents

require File.dirname(__FILE__) + '/../liquid_helper'
include LiquidHelperMethods

module Redmineup
  class AdditionalFilterTest < ActiveSupport::TestCase
    def setup
      @issue = Issue.first
      @issue_drop = Liquid::IssueDrop.new(@issue)
      @strainer = ::Liquid::Context.new.strainer
    end

    def test_parse_inline_attachments
      text = '<p>description with image <img src="screenshot.png" /></p>'
      attachment = mock_attachment
      attachments = [attachment]
      @issue_drop.define_singleton_method(:attachments) { attachments }
      Attachment.stub(:latest_attach, attachment) do
        assert_equal '<p>description with image <img src="mock_url" title="attach_image" alt="attach_image" loading="lazy" /></p>', @strainer.parse_inline_attachments(text, @issue_drop)
      end
    end

    private

    def mock_attachment
      attachment = Minitest::Mock.new
      attachment.expect(:url, 'mock_url')
      attachment.expect(:description, "attach_image")
      attachment
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redmineup-1.0.10 test/liquid/filters/additional_filter_test.rb
redmineup-1.0.9 test/liquid/filters/additional_filter_test.rb
redmineup-1.0.8 test/liquid/filters/additional_filter_test.rb
redmineup-1.0.7 test/liquid/filters/additional_filter_test.rb