aaaalmost fixed tests..
Jess Robinson [Thu, 3 May 2007 22:58:13 +0000 (22:58 +0000)]
lib/DBIx/Class/Schema/Journal.pm
lib/DBIx/Class/Schema/Journal/DB/AuditLog.pm
t/01test.t

index 72d8881..68d6786 100644 (file)
@@ -45,7 +45,9 @@ sub connection
         return;
     }
 
+    $self->_journal_schema->deploy();
     $self->_journal_schema->class('ChangeSet')->belongs_to('user', @{$self->journal_user});
+    $self->_journal_schema->storage->disconnect();
 }
 
 sub get_audit_log_class_name
@@ -84,19 +86,19 @@ sub create_journal_for
     $self->_journal_schema->register_class("${s_name}AuditHistory", $histclass);
 }
 
-sub create_changeset
+sub txn_do
 {
     my ($self, $code) = @_;
 
     ## Create a new changeset, then run $code as a transaction
-    my $cs = $self->result_source->schema->_journal_schema->resultset('ChangeSet');
+    my $cs = $self->_journal_schema->resultset('ChangeSet');
     my $changeset = $cs->create({
-        user_id => $self->result_source->schema->_journal_schema->current_user(),
-        session_id => $self->result_source->schema->_journal_schema->current_session(),
+        user_id => $self->_journal_schema->current_user(),
+        session_id => $self->_journal_schema->current_session(),
     });
-    $self->result_source->schema->_journal_schema->current_changeset($changeset->ID);
+    $self->_journal_schema->current_changeset($changeset->ID);
 
-    $self->txn_do($code);
+    $self->next::method($code);
 }
 
 1;
index 6a37d38..9c82466 100644 (file)
@@ -23,13 +23,13 @@ __PACKAGE__->add_columns(
 
 sub new
 {
-    my ($self, $data, @rest) = @_;
+    my ($self, $data, $source, @rest) = @_;
 
     $data->{created} = {
-        changeset_id => $self->result_source->schema->_journal_schema->current_changeset,
+        changeset_id => $source->schema->current_changeset,
     };
 
-    $self->next::method($data, @rest);
+    $self->next::method($data, $source, @rest);
 }                           
 
 1;
index 786f126..3efaf6b 100644 (file)
@@ -20,12 +20,13 @@ isa_ok($schema->_journal_schema, 'DBIx::Class::Schema::Journal::DB', 'Actually h
 isa_ok($schema->_journal_schema->source('CDAuditHistory'), 'DBIx::Class::ResultSource', 'CDAuditHistory source exists');
 isa_ok($schema->_journal_schema->source('ArtistAuditLog'), 'DBIx::Class::ResultSource', 'ArtistAuditLog source exists');
 
-my $new_cd = $schema->resultset('CD')->create({
-    title => 'Angry young man',
-    artist => 0,
-    year => 2000,
+my $new_cd = $schema->txn_do( sub {
+    return  $schema->resultset('CD')->create({
+        title => 'Angry young man',
+        artist => 0,
+        year => 2000,
     });
-
+});
 isa_ok($new_cd, 'DBIx::Class::Journal', 'Created CD object');
 
 my $search = $schema->_journal_schema->resultset('CDAuditLog')->search();