Merge 'trunk' into 'discard_changes_replication_fix'
Peter Rabbitson [Fri, 7 Aug 2009 08:48:41 +0000 (08:48 +0000)]
r7236@Thesaurus (orig r7233):  caelum | 2009-08-05 19:49:51 +0200
fix rounding issues in mssql money tests
r7237@Thesaurus (orig r7234):  caelum | 2009-08-05 20:09:03 +0200
better money value comparison in tests
r7239@Thesaurus (orig r7236):  frew | 2009-08-05 20:53:32 +0200
whitespace jfklds;ajfklds;a
r7240@Thesaurus (orig r7237):  frew | 2009-08-05 20:54:41 +0200
Fix testing bug.  Windows only.

Makefile.PL
lib/DBIx/Class/PK.pm
t/93storage_replication.t

index 79da35f..895540a 100644 (file)
@@ -45,6 +45,15 @@ requires 'Sub::Name'                => 0.04;
 
 recommends 'SQL::Translator'        => 0.09004;
 
+feature 'Replication',
+  -default => 0,
+  'Moose' => '0.88',
+  'MooseX::AttributeHelpers' => '0.21',
+  'MooseX::Types' => '0.16',
+  'namespace::clean' => '0.11',
+  'Hash::Merge' => '0.11';
+
+
 install_script (qw|
     script/dbicadmin
 |);
index 5be4833..cb59ec9 100644 (file)
@@ -43,6 +43,7 @@ sub discard_changes {
   delete $self->{_dirty_columns};
   return unless $self->in_storage; # Don't reload if we aren't real!
 
+  $attrs = { force_pool => 'master', %{ defined $attrs ? $attrs:{} } };
   if( my $current_storage = $self->get_from_storage($attrs)) {
 
     # Set $self to the current.
index 9b6f1bf..45b59c5 100644 (file)
@@ -13,7 +13,7 @@ BEGIN {
     eval "use DBIx::Class::Storage::DBI::Replicated; use Test::Moose";
     plan $@
         ? ( skip_all => "Deps not installed: $@" )
-        : ( tests => 126 );
+        : ( tests => 132 );
 }
 
 use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool';
@@ -766,6 +766,20 @@ is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{d
 
     is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
 
+    ok $artist->discard_changes({force_pool=>'master'})
+       => 'properly called discard_changes against master (manual attrs)';
+
+    is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
+
+    ok $artist->discard_changes()
+       => 'properly called discard_changes against master (default attrs)';
+
+    is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
+
+    ok $artist->discard_changes({force_pool=>$replicant_names[0]})
+       => 'properly able to override the default attributes';
+
+    is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}"
 }
 
 ## Test some edge cases, like trying to do a transaction inside a transaction, etc