# Copyright (c) 2008 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: MailForm.bunit,v 1.8 2010/06/15 21:29:15 nagler Exp $ my($rmid); FormModel({ setup_request => sub { my(undef, $params) = @_; req()->capture_mail; req()->put(query => {this => $rmid}) unless ref($params->[0]) eq 'HASH'; return; }, }); req()->set_realm_and_user(qw(mail_forum mail_user1)) ->initialize_fully('FORUM_MAIL_RECEIVE'); my($to) = from_type(EmailArray => [remote_email('mail_forum')]); my($message_id) = random_string() . '@bivio.biz'; my($now) = class('Type.DateTime')->now; my($date) = class('Type.DateTime')->rfc822($now); my($rm) = model('RealmMail'); $rm->create_from_rfc822(\(<<"EOF")); Message-Id: <$message_id> Subject: Re: MailForm1 From: joe Date: $date text1 EOF $rmid = $rm->get('realm_file_id'); [ empty_case({ to => $to, subject => 'Re: MailForm1', }), [{ to => $to, subject => 's1', body => 'body1', attachment1 => { content => \('att1'), content_type => 'text/plain', filename => 'a1.txt', }, }] => sub { my($msg) = req('Model.RealmMail')->get_rfc822; foreach my $p ( qr{^From:.*mail_user1.*mail_user1\@}im, qr{^To:.*mail_forum\@}im, qr{^Subject: s1}im, qr{^Sender:.*mail_forum\@}im, qr{^Message-Id: <\d+\.\w+@.*>}im, qr{^Reply-To:.*mail_forum\@}im, qr{\n\nbody1}, qr{filename="a1\.txt"}, ) { assert_equals($p, $msg); } return 1; }, ];