[Catalyst-commits] r12626 - in Catalyst-View-Email/trunk: . lib/Catalyst/View lib/Catalyst/View/Email t t/lib t/lib/TestApp/Controller t/lib/TestApp/View/Email t/lib/TestApp/View/Email/Template

dhoss at dev.catalyst.perl.org dhoss at dev.catalyst.perl.org
Wed Jan 13 01:17:26 GMT 2010


Author: dhoss
Date: 2010-01-13 01:17:26 +0000 (Wed, 13 Jan 2010)
New Revision: 12626

Added:
   Catalyst-View-Email/trunk/Makefile.PL
Removed:
   Catalyst-View-Email/trunk/Makefile.PL
Modified:
   Catalyst-View-Email/trunk/
   Catalyst-View-Email/trunk/Changes
   Catalyst-View-Email/trunk/lib/Catalyst/View/Email.pm
   Catalyst-View-Email/trunk/lib/Catalyst/View/Email/Template.pm
   Catalyst-View-Email/trunk/t/04basic.t
   Catalyst-View-Email/trunk/t/05template.t
   Catalyst-View-Email/trunk/t/06config.t
   Catalyst-View-Email/trunk/t/07mason.t
   Catalyst-View-Email/trunk/t/lib/TestApp.pm
   Catalyst-View-Email/trunk/t/lib/TestApp/Controller/Root.pm
   Catalyst-View-Email/trunk/t/lib/TestApp/View/Email/AppConfig.pm
   Catalyst-View-Email/trunk/t/lib/TestApp/View/Email/Template/AppConfig.pm
Log:
merged in latest stuffs


Property changes on: Catalyst-View-Email/trunk
___________________________________________________________________
Name: svn:mergeinfo
   - 

Modified: Catalyst-View-Email/trunk/Changes
===================================================================
--- Catalyst-View-Email/trunk/Changes	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/Changes	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,5 +1,10 @@
 Revision history for Perl extension Catalyst::View::Email.
 
+0.13.01 2010-01-09
+        - Ported over to using Email::Sender::Simple, and Moose
+		- Fixed Mason test so that it doesn't choke, as around 'process' seems to make
+		  it die.
+
 0.13    2009-02-22 14:06:00
         - bcc: POD corrections thanks to Lance Brown <lance at bearcircle.net>
 

Deleted: Catalyst-View-Email/trunk/Makefile.PL
===================================================================
--- Catalyst-View-Email/trunk/Makefile.PL	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/Makefile.PL	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,29 +0,0 @@
-use inc::Module::Install 0.87;
-
-name 'Catalyst-View-Email';
-all_from 'lib/Catalyst/View/Email.pm';
-
-requires 'Catalyst'             => '5.7';
-requires 'Class::C3';
-requires 'parent';
-requires 'Email::Send'          => '2.185';
-requires 'Email::MIME'          => '1.859';
-requires 'Email::MIME::Creator' => '1.455';
-
-feature 'Template Toolkit Support',
-    -default => 1,
-    'Catalyst::View::TT' => 0;
-
-feature 'Mason Support',
-    -default => 0,
-    'Catalyst::View::Mason';
-
-feature 'Net::SMTP Support',
-    -default => 0,
-    'MIME::Base64',
-    'Authen::SASL';
-
-auto_install;
-resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-View-Email/0.10/';
-
-WriteAll;

Copied: Catalyst-View-Email/trunk/Makefile.PL (from rev 12625, Catalyst-View-Email/branches/email-sender-porting/Makefile.PL)
===================================================================
--- Catalyst-View-Email/trunk/Makefile.PL	                        (rev 0)
+++ Catalyst-View-Email/trunk/Makefile.PL	2010-01-13 01:17:26 UTC (rev 12626)
@@ -0,0 +1,29 @@
+use inc::Module::Install 0.87;
+
+name 'Catalyst-View-Email';
+all_from 'lib/Catalyst/View/Email.pm';
+
+requires 'Catalyst'              => '5.7';
+requires 'Moose'                 => '0.93';
+requires 'parent';
+requires 'Email::Sender::Simple' => '2.185';
+requires 'Email::MIME'           => '1.859';
+requires 'Email::MIME::Creator'  => '1.455';
+
+feature 'Template Toolkit Support',
+    -default => 1,
+    'Catalyst::View::TT' => 0;
+
+feature 'Mason Support',
+    -default => 0,
+    'Catalyst::View::Mason';
+
+feature 'Net::SMTP Support',
+    -default => 0,
+    'MIME::Base64',
+    'Authen::SASL';
+
+auto_install;
+resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-View-Email/0.10/';
+
+WriteAll;

Modified: Catalyst-View-Email/trunk/lib/Catalyst/View/Email/Template.pm
===================================================================
--- Catalyst-View-Email/trunk/lib/Catalyst/View/Email/Template.pm	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/lib/Catalyst/View/Email/Template.pm	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,18 +1,13 @@
 package Catalyst::View::Email::Template;
 
-use warnings;
-use strict;
-
-use Class::C3;
+use Moose;
 use Carp;
 use Scalar::Util qw/ blessed /;
+use Data::Dumper;
+extends 'Catalyst::View::Email';
 
-use Email::MIME::Creator;
+our $VERSION = '0.13.01';
 
-use base qw/ Catalyst::View::Email /;
-
-our $VERSION = '0.13';
-
 =head1 NAME
 
 Catalyst::View::Email::Template - Send Templated Email from Catalyst
@@ -98,11 +93,32 @@
 # here the defaults of Catalyst::View::Email are extended by the additional
 # ones Template.pm needs.
 
-__PACKAGE__->config(
-    template_prefix => '',
+has 'stash_key' => (
+    is      => 'rw',
+    isa     => 'Str',
+    default => sub { "email" },
+    lazy    => 1,
 );
 
+has 'template_prefix' => (
+    is      => 'rw',
+    isa     => 'Str',
+    default => sub { '' },
+    lazy    => 1,
+);
 
+has 'default' => (
+    is      => 'rw',
+    isa     => 'HashRef',
+    default => sub {
+        {
+            view         => 'TT',
+            content_type => 'text/html',
+        };
+    },
+    lazy => 1,
+);
+
 # This view hitches into your default view and will call the render function
 # on the templates provided.  This means that you have a layer of abstraction
 # and you aren't required to modify your templates based on your desired engine
@@ -121,16 +137,18 @@
 #multipart/alternative
 
 sub _validate_view {
-    my ($self, $view) = @_;
-    
+    my ( $self, $view ) = @_;
+
     croak "C::V::Email::Template's configured view '$view' isn't an object!"
-        unless (blessed($view));
+      unless ( blessed($view) );
 
-    croak "C::V::Email::Template's configured view '$view' isn't an Catalyst::View!"
-        unless ($view->isa('Catalyst::View'));
+    croak
+      "C::V::Email::Template's configured view '$view' isn't an Catalyst::View!"
+      unless ( $view->isa('Catalyst::View') );
 
-    croak "C::V::Email::Template's configured view '$view' doesn't have a render method!"
-        unless ($view->can('render'));
+    croak
+"C::V::Email::Template's configured view '$view' doesn't have a render method!"
+      unless ( $view->can('render') );
 }
 
 =head1 METHODS
@@ -145,46 +163,65 @@
 =cut
 
 sub generate_part {
-    my ($self, $c, $attrs) = @_;
+    my ( $self, $c, $attrs ) = @_;
 
-    my $template_prefix         = $self->{template_prefix};
-    my $default_view            = $self->{default}->{view};
-    my $default_content_type    = $self->{default}->{content_type};
-    my $default_charset         = $self->{default}->{charset};
+    my $template_prefix      = $self->template_prefix;
+    my $default_view         = $self->default->{view};
+    my $default_content_type = $self->default->{content_type};
+    my $default_charset      = $self->default->{charset};
 
     my $view;
+
     # use the view specified for the email part
-    if (exists $attrs->{view} && defined $attrs->{view} && $attrs->{view} ne '') {
-        $view = $c->view($attrs->{view});
-        $c->log->debug("C::V::Email::Template uses specified view $view for rendering.") if $c->debug;
+    if (   exists $attrs->{view}
+        && defined $attrs->{view}
+        && $attrs->{view} ne '' )
+    {
+        $view = $c->view( $attrs->{view} );
+        $c->log->debug(
+            "C::V::Email::Template uses specified view $view for rendering.")
+          if $c->debug;
     }
+
     # if none specified use the configured default view
     elsif ($default_view) {
         $view = $c->view($default_view);
-        $c->log->debug("C::V::Email::Template uses default view $view for rendering.") if $c->debug;;
+        $c->log->debug(
+            "C::V::Email::Template uses default view $view for rendering.")
+          if $c->debug;
     }
+
     # else fallback to Catalysts default view
     else {
         $view = $c->view;
-        $c->log->debug("C::V::Email::Template uses Catalysts default view $view for rendering.") if $c->debug;;
+        $c->log->debug(
+"C::V::Email::Template uses Catalysts default view $view for rendering."
+        ) if $c->debug;
     }
 
     # validate the per template view
     $self->_validate_view($view);
-    
+
     # prefix with template_prefix if configured
-    my $template = $template_prefix ne '' ? join('/', $template_prefix, $attrs->{template}) : $attrs->{template};
-   
+    my $template =
+      $template_prefix ne ''
+      ? join( '/', $template_prefix, $attrs->{template} )
+      : $attrs->{template};
+
     # setup the attributes (merge with defaults)
-    my $e_m_attrs = $self->setup_attributes($c, $attrs);
+    my $e_m_attrs = $self->SUPER::setup_attributes( $c, $attrs );
 
     # render the email part
-    my $output = $view->render( $c, $template, { 
-        content_type    => $e_m_attrs->{content_type},
-        stash_key       => $self->{stash_key},
-        %{$c->stash},
-    });
-    
+    my $output = $view->render(
+        $c,
+        $template,
+        {
+            content_type => $e_m_attrs->{content_type},
+            stash_key    => $self->stash_key,
+            %{$c->stash},
+        }
+    );
+    warn "Email output: $output";
     if ( ref $output ) {
         croak $output->can('as_string') ? $output->as_string : $output;
     }
@@ -204,57 +241,56 @@
 
 =cut
 
-sub process {
-    my ( $self, $c, @args ) = @_;
+around 'process' => sub {
+    my ( $orig, $self, $c, @args ) = @_;
+    my $stash_key = $self->stash_key;
+    return $self->$orig( $c, @args )
+      unless $c->stash->{$stash_key}->{template}
+          or $c->stash->{$stash_key}->{templates};
+    warn "Stash: " . $stash_key;
 
-    # don't validate template_prefix
-
-    # the default view is validated if used
-
-    # the content type should be validated by Email::MIME::Creator
-    
-    my $stash_key = $self->{stash_key};
-
-    # Go upstream if we don't have a template
-    $self->next::method($c, @args)
-        unless $c->stash->{$stash_key}->{template}
-            or $c->stash->{$stash_key}->{templates};
-    
-    # this array holds the Email::MIME objects
     # in case of the simple api only one
-    my @parts = (); 
+    my @parts = ();
 
     # now find out if the single or multipart api was used
     # prefer the multipart one
-    
+
     # multipart api
-    if ($c->stash->{$stash_key}->{templates}
+    if (   $c->stash->{$stash_key}->{templates}
         && ref $c->stash->{$stash_key}->{templates} eq 'ARRAY'
-        && ref $c->stash->{$stash_key}->{templates}[0] eq 'HASH') {
+        && ref $c->stash->{$stash_key}->{templates}[0] eq 'HASH' )
+    {
+
         # loop through all parts of the mail
-        foreach my $part (@{$c->stash->{$stash_key}->{templates}}) {
-            push @parts, $self->generate_part($c, {
-                view            => $part->{view},
-                template        => $part->{template},
-                content_type    => $part->{content_type},
-                charset         => $part->{charset},
-            });
+        foreach my $part ( @{ $c->stash->{$stash_key}->{templates} } ) {
+            push @parts,
+              $self->generate_part(
+                $c,
+                {
+                    view         => $part->{view},
+                    template     => $part->{template},
+                    content_type => $part->{content_type},
+                    charset      => $part->{charset},
+                }
+              );
         }
     }
+
     # single part api
-    elsif($c->stash->{$stash_key}->{template}) {
-        push @parts, $self->generate_part($c, {
-            template    => $c->stash->{$stash_key}->{template},
-        });
+    elsif ( $c->stash->{$stash_key}->{template} ) {
+        push @parts,
+          $self->generate_part( $c,
+            { template => $c->stash->{$stash_key}->{template}, } );
     }
-    
+
     delete $c->stash->{$stash_key}->{body};
     $c->stash->{$stash_key}->{parts} ||= [];
-    push @{$c->stash->{$stash_key}->{parts}}, @parts;
+    push @{ $c->stash->{$stash_key}->{parts} }, @parts;
+    
+	warn "Stash: " . Dumper $c->stash;
+    return $self->$orig($c);
 
-    # Let C::V::Email do the actual sending.  We just assemble the tasty bits.
-    return $self->next::method($c);
-}
+};
 
 =back
 

Modified: Catalyst-View-Email/trunk/lib/Catalyst/View/Email.pm
===================================================================
--- Catalyst-View-Email/trunk/lib/Catalyst/View/Email.pm	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/lib/Catalyst/View/Email.pm	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,21 +1,50 @@
 package Catalyst::View::Email;
 
-use warnings;
-use strict;
-
-use Class::C3;
+use Moose;
 use Carp;
 
 use Encode qw(encode decode);
-use Email::Send;
+use Email::Sender::Simple qw/ sendmail /;
 use Email::MIME::Creator;
+extends 'Catalyst::View';
 
-use parent 'Catalyst::View';
+our $VERSION = '0.13.01';
 
-our $VERSION = '0.13';
+has 'mailer' => (
+    is      => 'rw',
+    isa     => 'Str',
+    lazy    => 1,
+    default => sub { "sendmail" }
+);
 
-__PACKAGE__->mk_accessors(qw/ mailer /);
+has 'stash_key' => (
+    is      => 'rw',
+    isa     => 'Str',
+    lazy    => 1,
+    default => sub { "email" }
+);
 
+has 'default' => (
+    is      => 'rw',
+    isa     => 'HashRef',
+    default => sub { { content_type => 'text/plain' } },
+    lazy    => 1,
+);
+
+has 'sender' => (
+    is      => 'rw',
+    isa     => 'HashRef',
+    lazy    => 1,
+    default => sub { { mailer => shift->mailer } }
+);
+
+has 'content_type' => (
+    is      => 'rw',
+	isa     => 'Str',
+	default => sub { shift->default->{content_type} },
+	lazy    => 1,
+);
+
 =head1 NAME
 
 Catalyst::View::Email - Send Email from Catalyst
@@ -75,13 +104,6 @@
 
 =cut
 
-__PACKAGE__->config(
-    stash_key   => 'email',
-    default     => {
-        content_type    => 'text/plain',
-    },
-);
-
 =head1 SENDING EMAIL
 
 Sending email is just filling the stash and forwarding to the view:
@@ -161,41 +183,13 @@
 
 =cut
 
-sub new {
-    my $self = shift->next::method(@_);
+sub BUILD {
+    my $self = shift;
 
-    my $stash_key = $self->{stash_key};
+    my $stash_key = $self->stash_key;
     croak "$self stash_key isn't defined!"
-        if ($stash_key eq '');
+      if ( $stash_key eq '' );
 
-    my $sender = Email::Send->new;
-
-    if ( my $mailer = $self->{sender}->{mailer} ) {
-        croak "$mailer is not supported, see Email::Send"
-            unless $sender->mailer_available($mailer);
-        $sender->mailer($mailer);
-    }
-    else {
-        # Default case, run through the most likely options first.
-        for ( qw/SMTP Sendmail Qmail/ ) {
-            $sender->mailer($_) and last if $sender->mailer_available($_);
-        }
-    }
-
-    if ( my $args = $self->{sender}->{mailer_args} ) {
-        if ( ref $args eq 'HASH' ) {
-            $sender->mailer_args([ %$args ]);
-        }
-        elsif ( ref $args eq 'ARRAY' ) {
-            $sender->mailer_args($args);
-        } else {
-            croak "Invalid mailer_args specified, check pod for Email::Send!";
-        }
-    }
-
-    $self->mailer($sender);
-
-    return $self;
 }
 
 =item process($c)
@@ -211,34 +205,35 @@
     my ( $self, $c ) = @_;
 
     croak "Unable to send mail, bad mail configuration"
-        unless $self->mailer;
+      unless $self->mailer;
 
-    my $email  = $c->stash->{$self->{stash_key}};
+    my $email = $c->stash->{ $self->stash_key };
     croak "Can't send email without a valid email structure"
-        unless $email;
+      unless $email;
 
     # Default content type
-    if ( exists $self->{content_type} and not $email->{content_type} ) {
-        $email->{content_type} = $self->{content_type};
+    if ( $self->content_type and not $email->{content_type} ) {
+        $email->{content_type} = $self->content_type;
     }
 
-    my $header  = $email->{header} || [];
-        push @$header, ('To' => delete $email->{to})
-            if $email->{to};
-        push @$header, ('Cc' => delete $email->{cc})
-            if $email->{cc};
-        push @$header, ('Bcc' => delete $email->{bcc})
-            if $email->{bcc};
-        push @$header, ('From' => delete $email->{from})
-            if $email->{from};
-        push @$header, ('Subject' => Encode::encode('MIME-Header', delete $email->{subject}))
-            if $email->{subject};
-        push @$header, ('Content-type' => $email->{content_type})
-            if $email->{content_type};
+    my $header = $email->{header} || [];
+    push @$header, ( 'To' => delete $email->{to} )
+      if $email->{to};
+    push @$header, ( 'Cc' => delete $email->{cc} )
+      if $email->{cc};
+    push @$header, ( 'Bcc' => delete $email->{bcc} )
+      if $email->{bcc};
+    push @$header, ( 'From' => delete $email->{from} )
+      if $email->{from};
+    push @$header,
+      ( 'Subject' => Encode::encode( 'MIME-Header', delete $email->{subject} ) )
+      if $email->{subject};
+    push @$header, ( 'Content-type' => $email->{content_type} )
+      if $email->{content_type};
 
     my $parts = $email->{parts};
     my $body  = $email->{body};
-   
+
     unless ( $parts or $body ) {
         croak "Can't send email without parts or body, check stash";
     }
@@ -247,26 +242,30 @@
 
     if ( $parts and ref $parts eq 'ARRAY' ) {
         $mime{parts} = $parts;
-    } else {
+    }
+    else {
         $mime{body} = $body;
     }
 
-    $mime{attributes}->{content_type} = $email->{content_type} 
-        if $email->{content_type};
-    if ( $mime{attributes} and not $mime{attributes}->{charset} and
-         $self->{default}->{charset} )
+    $mime{attributes}->{content_type} = $email->{content_type}
+      if $email->{content_type};
+    if (    $mime{attributes}
+        and not $mime{attributes}->{charset}
+        and $self->{default}->{charset} )
     {
         $mime{attributes}->{charset} = $self->{default}->{charset};
     }
 
     my $message = $self->generate_message( $c, \%mime );
 
-    if ( $message ) {
-        my $return = $self->mailer->send($message);
+    if ($message) {
+        my $return = sendmail( $message, { transport => $self->mailer } );
+
         # return is a Return::Value object, so this will stringify as the error
-        # in the case of a failure.  
+        # in the case of a failure.
         croak "$return" if !$return;
-    } else {
+    }
+    else {
         croak "Unable to create message";
     }
 }
@@ -282,25 +281,36 @@
 
 sub setup_attributes {
     my ( $self, $c, $attrs ) = @_;
-    
-    my $default_content_type    = $self->{default}->{content_type};
-    my $default_charset         = $self->{default}->{charset};
 
+    my $default_content_type = $self->default->{content_type};
+    my $default_charset      = $self->default->{charset};
+
     my $e_m_attrs = {};
 
-    if (exists $attrs->{content_type} && defined $attrs->{content_type} && $attrs->{content_type} ne '') {
-        $c->log->debug('C::V::Email uses specified content_type ' . $attrs->{content_type} . '.') if $c->debug;
+    if (   exists $attrs->{content_type}
+        && defined $attrs->{content_type}
+        && $attrs->{content_type} ne '' )
+    {
+        $c->log->debug( 'C::V::Email uses specified content_type '
+              . $attrs->{content_type}
+              . '.' )
+          if $c->debug;
         $e_m_attrs->{content_type} = $attrs->{content_type};
     }
-    elsif (defined $default_content_type && $default_content_type ne '') {
-        $c->log->debug("C::V::Email uses default content_type $default_content_type.") if $c->debug;
+    elsif ( defined $default_content_type && $default_content_type ne '' ) {
+        $c->log->debug(
+            "C::V::Email uses default content_type $default_content_type.")
+          if $c->debug;
         $e_m_attrs->{content_type} = $default_content_type;
     }
-   
-    if (exists $attrs->{charset} && defined $attrs->{charset} && $attrs->{charset} ne '') {
+
+    if (   exists $attrs->{charset}
+        && defined $attrs->{charset}
+        && $attrs->{charset} ne '' )
+    {
         $e_m_attrs->{charset} = $attrs->{charset};
     }
-    elsif (defined $default_charset && $default_charset ne '') {
+    elsif ( defined $default_charset && $default_charset ne '' ) {
         $e_m_attrs->{charset} = $default_charset;
     }
 
@@ -319,9 +329,11 @@
 sub generate_message {
     my ( $self, $c, $attr ) = @_;
 
-    # setup the attributes (merge with defaults)
-    $attr->{attributes} = $self->setup_attributes($c, $attr->{attributes});
-    return Email::MIME->create(%$attr);
+    # setup the attributes (merge with defaultis)
+	$attr->{attributes} = $self->setup_attributes($c, $attr->{attributes});
+    Email::MIME->create(
+	    %$attr
+	);
 }
 
 =back
@@ -372,6 +384,8 @@
 
 Lance Brown <lance at bearcircle.net>
 
+Devin Austin <dhoss at cpan.org>
+
 =head1 COPYRIGHT
 
 Copyright (c) 2007 - 2009

Modified: Catalyst-View-Email/trunk/t/04basic.t
===================================================================
--- Catalyst-View-Email/trunk/t/04basic.t	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/t/04basic.t	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,8 +1,9 @@
 use strict;
 use warnings;
-use Test::More tests => 5;
+BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' }
+use Test::More;
 
-use Email::Send::Test;
+use Email::Sender::Simple;
 use FindBin;
 use lib "$FindBin::Bin/lib";
 
@@ -12,8 +13,9 @@
 my $time = time;
 ok( ($response = request("/email?time=$time"))->is_success, 'request ok');
 
-my @emails = Email::Send::Test->emails;
+my @emails = Email::Sender::Simple->default_transport->deliveries;
+is( scalar @emails, 1, "got emails");
+isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' );
+like($emails[0]->{'email'}->[0]->body, qr/$time/, 'Got our email');
 
-is(@emails, 1, "got emails");
-isa_ok( $emails[0], 'Email::MIME', 'email is ok' );
-like($emails[0]->body, qr/$time/, 'Got our email');
+done_testing();

Modified: Catalyst-View-Email/trunk/t/05template.t
===================================================================
--- Catalyst-View-Email/trunk/t/05template.t	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/t/05template.t	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,9 +1,12 @@
 use strict;
 use warnings;
+
+BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' }
 use Test::More;
 
-use Email::Send::Test;
+use Email::Sender::Simple;
 use FindBin;
+use Data::Dumper;
 use lib "$FindBin::Bin/lib";
 
 eval "use Catalyst::View::TT";
@@ -11,7 +14,6 @@
     plan skip_all => 'Catalyst::View::TT required for Template tests';
     exit;
 }
-plan tests => 11;
 
 use_ok('Catalyst::Test', 'TestApp');
 
@@ -19,15 +21,14 @@
 my $time = time;
 ok( ( $response = request("/template_email?time=$time"))->is_success,
     'request ok' );
+my @emails = Email::Sender::Simple->default_transport->deliveries;
 like( $response->content, qr/Template Email Ok/, 'controller says ok' );
-my @emails = Email::Send::Test->emails;
-
 cmp_ok(@emails, '==', 1, 'got emails');
-isa_ok( $emails[0], 'Email::MIME', 'email is ok' );
+isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' );
 
-like($emails[0]->content_type, qr#^multipart/alternative#, 'Multipart email');
+like($emails[0]->{'email'}[0]->header("Content-type"), qr#^multipart/alternative#, 'Multipart email');
 
-my @parts = $emails[0]->parts;
+my @parts = $emails[0]->{'email'}[0]->parts;
 cmp_ok(@parts, '==', 2, 'got parts');
 
 is($parts[0]->content_type, 'text/plain', 'text/plain part ok');
@@ -36,4 +37,4 @@
 is($parts[1]->content_type, 'text/html', 'text/html ok');
 like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
 #like($emails[0]->body, qr/$time/, 'Got our email');
-
+done_testing();

Modified: Catalyst-View-Email/trunk/t/06config.t
===================================================================
--- Catalyst-View-Email/trunk/t/06config.t	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/t/06config.t	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,8 +1,9 @@
 use strict;
 use warnings;
-use Test::More tests => 13;
+BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' }
 
-use Email::Send::Test;
+use Test::More; 
+use Email::Sender::Simple;
 use FindBin;
 use lib "$FindBin::Bin/lib";
 
@@ -16,26 +17,26 @@
 
 ok( ($response = request("/email_app_config?time=$time"))->is_success, 'request ok');
 
- at emails = Email::Send::Test->emails;
+ at emails = Email::Sender::Simple->default_transport->deliveries;
 
-is(@emails, 1, "got emails");
-isa_ok( $emails[0], 'Email::MIME', 'email is ok' );
-like($emails[0]->body, qr/$time/, 'Got our email');
+is(scalar @emails, 1, "got emails");
+isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' );
+like($emails[0]->{'email'}->[0]->body, qr/$time/, 'Got our email');
 
-Email::Send::Test->clear;
+Email::Sender::Simple->default_transport->clear_deliveries;
 
 $time = time;
 ok( ($response = request("/template_email_app_config?time=$time"))->is_success, 'request ok');
 
- at emails = Email::Send::Test->emails;
+ at emails = Email::Sender::Simple->default_transport->deliveries;
 
-is(@emails, 1, "got emails");
-isa_ok( $emails[0], 'Email::MIME', 'email is ok' );
-my @parts = $emails[0]->parts;
+is(scalar @emails, 1, "got emails");
+isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' );
+my @parts = $emails[0]->{'email'}[0]->parts;
 cmp_ok(@parts, '==', 2, 'got parts');
 
 is($parts[0]->content_type, 'text/plain', 'text/plain ok');
 like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back');
 is($parts[1]->content_type, 'text/html', 'text/html ok');
 like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
-
+done_testing();

Modified: Catalyst-View-Email/trunk/t/07mason.t
===================================================================
--- Catalyst-View-Email/trunk/t/07mason.t	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/t/07mason.t	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,37 +1,37 @@
 use strict;
 use warnings;
 use Test::More;
-
-use Email::Send::Test;
+BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' }
 use FindBin;
 use lib "$FindBin::Bin/lib";
 
+use Email::Sender::Simple;
+
 eval "use Catalyst::View::Mason";
 if ( $@ ) {
     plan skip_all => 'Catalyst::View::Mason required for Mason tests';
     exit;
 }
-plan tests => 10;
 
 use_ok('Catalyst::Test', 'TestApp');
 
 TestApp->config->{default_view} = 'Mason';
-
+use Data::Dumper;
 my $response;
 my $time = time;
 ok( ( $response = request("/mason_email?time=$time"))->is_success,
     'request ok' );
 like( $response->content, qr/Mason Email Ok/, 'controller says ok' );
-my @emails = Email::Send::Test->emails;
-
+my @emails = Email::Sender::Simple->default_transport->deliveries;
+#warn "Email: " . Dumper @emails;
 cmp_ok(@emails, '==', 1, 'got emails');
-isa_ok( $emails[0], 'Email::MIME', 'email is ok' );
-my @parts = $emails[0]->parts;
+isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' );
+my @parts = $emails[0]->{'email'}[0]->parts;
 cmp_ok(@parts, '==', 2, 'got parts');
-
+#warn "Parts: " . Dumper @parts;
 is($parts[0]->content_type, 'text/plain', 'text/plain ok');
 like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back');
 is($parts[1]->content_type, 'text/html', 'text/html ok');
 like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
 #like($emails[0]->body, qr/$time/, 'Got our email');
-
+done_testing();

Modified: Catalyst-View-Email/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-View-Email/trunk/t/lib/TestApp/Controller/Root.pm	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/t/lib/TestApp/Controller/Root.pm	2010-01-13 01:17:26 UTC (rev 12626)
@@ -127,10 +127,10 @@
         to      => 'test-email at example.com',
         from    => 'no-reply at example.com',
         subject => 'Just a test',
-        view    => 'Mason',
         templates => [
             {
-                template        => 'text_plain/test.m',
+                view            => 'Mason',
+		        template        => 'text_plain/test.m',
                 content_type    => 'text/plain',
             },
             {

Modified: Catalyst-View-Email/trunk/t/lib/TestApp/View/Email/AppConfig.pm
===================================================================
--- Catalyst-View-Email/trunk/t/lib/TestApp/View/Email/AppConfig.pm	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/t/lib/TestApp/View/Email/AppConfig.pm	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,7 +1,7 @@
 package # Hide from PAUSE
     TestApp::View::Email::AppConfig;
 
-use Email::Send::Test;
+use Email::Sender::Simple;
 
 use base 'Catalyst::View::Email';
 

Modified: Catalyst-View-Email/trunk/t/lib/TestApp/View/Email/Template/AppConfig.pm
===================================================================
--- Catalyst-View-Email/trunk/t/lib/TestApp/View/Email/Template/AppConfig.pm	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/t/lib/TestApp/View/Email/Template/AppConfig.pm	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,7 +1,7 @@
 package # Hide from PAUSE
     TestApp::View::Email::Template::AppConfig;
 
-use Email::Send::Test;
+use Email::Sender::Simple;
 
 use base 'Catalyst::View::Email::Template';
 

Modified: Catalyst-View-Email/trunk/t/lib/TestApp.pm
===================================================================
--- Catalyst-View-Email/trunk/t/lib/TestApp.pm	2010-01-13 01:03:26 UTC (rev 12625)
+++ Catalyst-View-Email/trunk/t/lib/TestApp.pm	2010-01-13 01:17:26 UTC (rev 12626)
@@ -1,7 +1,7 @@
 package # Hide from PAUSE
     TestApp;
 
-use Catalyst;
+use Catalyst qw/ -Debug /;
 use FindBin;
 
 TestApp->config(
@@ -17,6 +17,7 @@
         sender => {
             mailer => 'Test',
         },
+		content_type => 'text/html',
         default => {
             view => 'TT',
         },




More information about the Catalyst-commits mailing list