rev 1815 - in trunk/Email-Store-Pristine: . lib/Email/Store t

[prev] [thread] [next] [lurker] [Date index for 2005/02/04]

From: richardc
Subject: rev 1815 - in trunk/Email-Store-Pristine: . lib/Email/Store t
Date: 05:33 on 04 Feb 2005
Author: richardc
Date: 2005-02-04 05:33:56 +0000 (Fri, 04 Feb 2005)
New Revision: 1815

Modified:
   trunk/Email-Store-Pristine/
   trunk/Email-Store-Pristine/lib/Email/Store/Pristine.pm
   trunk/Email-Store-Pristine/t/
   trunk/Email-Store-Pristine/t/pristine.t
Log:
make it all work


Property changes on: trunk/Email-Store-Pristine
___________________________________________________________________
Name: svn:ignore
   + Build
blib
_build
*.tar.gz


Modified: trunk/Email-Store-Pristine/lib/Email/Store/Pristine.pm
===================================================================
--- trunk/Email-Store-Pristine/lib/Email/Store/Pristine.pm	2005-02-04 05:13:45 UTC (rev 1814)
+++ trunk/Email-Store-Pristine/lib/Email/Store/Pristine.pm	2005-02-04 05:33:56 UTC (rev 1815)
@@ -27,10 +27,11 @@
 use strict;
 use warnings;
 use base 'Email::Store::DBI';
-__PACKAGE__->table("pristine_mail");
-__PACKAGE__->columns(All => qw/id mail message/);
+__PACKAGE__->table("pristine");
+__PACKAGE__->columns(All  => qw/id mail message/);
+__PACKAGE__->columns(TEMP => qw/simple/);
 __PACKAGE__->has_a(mail => 'Email::Store::Mail');
-Email::Store::Mail->has_many( pristine_copies => [ __PACKAGE__, 'mail' ] );
+Email::Store::Mail->has_many( pristine_copies => __PACKAGE__ );
 
 # I damn well want to be first
 sub on_store_order { -20000 }
@@ -46,6 +47,7 @@
 
 sub on_store {
     my ($self, $mail) = @_;
+    print "On store\n";
     $self->_store( $mail, $mail->simple->as_string );
 }
 
@@ -60,12 +62,24 @@
     $self->_store( $mail, $message );
 }
 
-sub message { die "which part of pristine didn't you get?" }
+sub message {
+    my $self = shift;
+    if (@_) {
+        die "which part of pristine didn't you get?"
+    }
+    $self->get('message');
+}
 
+# hmm, is there a way to make this Email::Simple object readonly too?
+sub simple {
+    my $self = shift;
+    return $self->{simple} ||= Email::Simple->new( $self->message );
+}
+
 1;
-__END__
+__DATA__
 
-CREATE TABLE IF NOT EXISTS pristine_mail (
+CREATE TABLE IF NOT EXISTS pristine (
     id integer NOT NULL auto_increment primary key,
     mail varchar(255) NOT NULL,
     message text


Property changes on: trunk/Email-Store-Pristine/t
___________________________________________________________________
Name: svn:ignore
   + test.db


Modified: trunk/Email-Store-Pristine/t/pristine.t
===================================================================
--- trunk/Email-Store-Pristine/t/pristine.t	2005-02-04 05:13:45 UTC (rev 1814)
+++ trunk/Email-Store-Pristine/t/pristine.t	2005-02-04 05:33:56 UTC (rev 1815)
@@ -1,8 +1,9 @@
 # -*- cperl -*-
-use Test::More tests => 20;
+use Test::More tests => 7;
 use File::Slurp;
 BEGIN { unlink("t/test.db"); }
-use Email::Store "dbi:SQLite:dbname=t/test.db";
+use Email::Store { only => [qw( Mail List Pristine )] },
+  "dbi:SQLite:dbname=t/test.db";
 Email::Store->setup;
 ok(1, "Set up");
 
@@ -14,3 +15,18 @@
 is(@mails, 1, "Only one mail");
 is($mails[0]->message_id, '20001128211546.A29664@xxxxxxxxx.xxx', "Correct ID");
 like($mails[0]->message, qr/PRE_PROCESS/, "Contains the right stuff");
+
+my @copies = $mails[0]->pristine_copies;
+is(@copies, 1, "one pristine copy" );
+
+# we're expecting the List plugin to have fiddled with the subject line
+is($mails[0]->simple->header('subject'),
+   'ttree problems - the sequel',
+   'the mail has a munged subject' );
+is($copies[0]->simple->header('subject'),
+   '[Templates] ttree problems - the sequel',
+  "but the pristine copy doesn't");
+
+
+# to test.  getting one copy to you, one to the list - expect 1 mail
+# and 2 pristine

Generated at 11:00 on 04 Feb 2005 by mariachi 0.52