Project

General

Profile

Feature #40266 » issues_pdf_redmine_helper_test.rb

Yazan Al aeddin, 2024-02-19 14:27

 
1
# frozen_string_literal: true
2
require File.expand_path('../../../../../../test_helper', __FILE__)
3
require 'pdf/reader'
4

    
5
class IssuesPdfRedmineHelperTest <Redmine::HelperTest
6
  fixtures :issues
7

    
8
  include Redmine::Export::PDF::IssuesPdfHelper
9

    
10
  def test_issue_to_pdf_should_create_attachment_links
11
    issue = Issue.find(2)
12
    result = issue_to_pdf(issue)
13
    pdf_reader = PDF::Reader.new(StringIO.new(result))
14

    
15
    assert pdf_reader.pages.any? { |page| page.text.include?("#{issue.subject}") }, "The expected subject is not present in the PDF"
16

    
17
    issue.attachments.each do |attachment|
18
      link = link_to_attachment(attachment, {})
19
      assert_equal(true, result.include?("(http://test.host/attachments/#{attachment.id})"))
20
    end
21
  end
22
end
(2-2/5)