[Rt-commit] rt branch, 4.0/test-warnings, updated. rt-4.0.0-183-g6eaf2fe

Shawn Moore sartak at bestpractical.com
Tue May 3 15:25:18 EDT 2011


The branch, 4.0/test-warnings has been updated
       via  6eaf2fefe02b29777776b5e02452903024e4eb66 (commit)
      from  b4dbaa458fc7855c7d8af37b84aeabf03af010b4 (commit)

Summary of changes:
 lib/RT/Test/Web.pm |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 6eaf2fefe02b29777776b5e02452903024e4eb66
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue May 3 15:25:03 2011 -0400

    Clone mech during get_warnings to avoid disrupting mech state

diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index 0e56eb5..3be1b85 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -180,11 +180,17 @@ sub get_warnings {
     my $self = shift;
     local $Test::Builder::Level = $Test::Builder::Level + 1;
 
-    return unless $self->get_ok('/__test_warnings');
+    # We clone here so that when we fetch warnings, we don't disrupt the state
+    # of the test's mech. If we reuse the original mech then you can't
+    # test warnings immediately after fetching page XYZ, then fill out
+    # forms on XYZ. This is because the most recently fetched page has changed
+    # from XYZ to /__test_warnings, which has no form.
+    my $clone = $self->clone;
+    return unless $clone->get_ok('/__test_warnings');
 
     use Storable 'thaw';
 
-    my @warnings = @{ thaw $self->content };
+    my @warnings = @{ thaw $clone->content };
     return @warnings;
 }
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list