#!/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_SubmitBase64 < Test::Unit::TestCase
  include TestQuickMLModule

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

    str = <<'EOT'
Date: Thu, 14 Apr 2005 21:22:30 +0900
From: user@e.com
To: test@example.com
User-Agent: Wanderlust/2.10.0 (Venus) SEMI/1.14.4 (Hosorogi) FLIM/1.14.4
 (=?ISO-8859-4?Q?Kashiharajing=FE-mae?=) APEL/10.4 Emacs/21.3
 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI)
MIME-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi")
Content-Type: multipart/mixed;
 boundary="Multipart_Thu_Apr_14_21:22:30_2005-1"
Subject: This is an inline test.

--Multipart_Thu_Apr_14_21:22:30_2005-1
Content-Type: text/plain; charset=ISO-2022-JP

サンプル.jpgを添付してみます。
--Multipart_Thu_Apr_14_21:22:30_2005-1
Content-Type: image/jpeg
Content-Disposition: inline; filename="sample.jpg"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4//8/AAX+Av4zEpUU
AAAAAElFTkSuQmCC

EOT
    mail = ml_mail("user@e.com", "test@example.com", str)

    qml.qwik_post(mail, true)
    page = @site["1"]
    $KCODE = "s"
    assert_equal("This is an inline test.", page.get_title)
    assert_equal("* This is an inline test.\n{{mail(user@e.com,0)\nサンプル.jpgを添付してみます。\n\n{{file(sample.jpg)}}\n\n}}\n", page.load)
    assert_equal(true, @site.files(page.key).exist?("sample.jpg"))
  end
end
