#!/usr/bin/env ruby
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/test-module-quickml"
require "qwik/quickml"

class TC_SubmitUuencode < Test::Unit::TestCase
  include TestQuickMLModule

  def test_uuencode
    qml = QuickML::QuickML.new(@ml_config, "test@example.com")
    qml.setup_test_config

    str = <<'EOT'
Date: Sun, 01 Aug 2004 12:34:56 +0900
From: Test User <user@e.com>
To: test@example.com
Subject: UuencodeImage
Message-Id: <nosuchmessageid@example.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------Boundary_iGrnGAlmY.rxNIm"
X-Mailer: EdMax Ver2.85.5F

--------------Boundary_iGrnGAlmY.rxNIm
Content-Type: text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit

This is a test.

--------------Boundary_iGrnGAlmY.rxNIm
Content-Type: application/octet-stream; name="1x1a.png"
Content-Transfer-Encoding: x-uuencode
Content-Disposition: attachment; filename="1x1a.png"

begin 666 1x1a.png
MB5!.1PT*&@H````-24A$4@````$````!"`(```"0=U/>````#$E$051XVF/X
8__\_``7^`OXS$I44`````$E%3D2N0F""
`
end
EOT
    mail = ml_mail("user@e.com", "test@example.com", str)

    qml.qwik_post(mail, true)
    page = @site["UuencodeImage"]
    assert_equal("UuencodeImage", page.get_title)
    assert_equal("* UuencodeImage\n{{mail(user@e.com,0)\nThis is a test.\n\n{{file(1x1a.png)}}\n\n}}\n", page.load)
  end
end
