<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -470,9 +470,11 @@ module ActiveRecord #:nodoc:
           def without_locking(&amp;block)
             current = ActiveRecord::Base.lock_optimistically
             ActiveRecord::Base.lock_optimistically = false if current
-            result = block.call
-            ActiveRecord::Base.lock_optimistically = true if current
-            result
+            begin
+              block.call
+            ensure
+              ActiveRecord::Base.lock_optimistically = true if current
+            end
           end
         end
       end</diff>
      <filename>lib/acts_as_versioned.rb</filename>
    </modified>
    <modified>
      <diff>@@ -321,8 +321,29 @@ class VersionedTest &lt; AAVTestCase
     assert landmarks(:washington).changed?
     assert !landmarks(:washington).altered?
   end
-  
-  
-end
-
 
+  test &quot;without locking temporarily disables optimistic locking&quot; do
+    enabled1 = false
+    block_called = false
+    
+    ActiveRecord::Base.lock_optimistically = true
+    LockedPage.without_locking do
+      enabled1 = ActiveRecord::Base.lock_optimistically
+      block_called = true
+    end
+    enabled2 = ActiveRecord::Base.lock_optimistically
+    
+    assert block_called
+    assert !enabled1
+    assert enabled2
+  end
+  
+  test &quot;without locking reverts optimistic locking settings if block raises exception&quot; do
+    assert_raises(RuntimeError) do
+      LockedPage.without_locking do
+        raise RuntimeError, &quot;oh noes&quot;
+      end
+    end
+    assert ActiveRecord::Base.lock_optimistically
+  end
+end
\ No newline at end of file</diff>
      <filename>test/versioned_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c82ff9328dc1dbedccd5262c963aad86ce737393</id>
    </parent>
  </parents>
  <author>
    <name>Christian Romney</name>
    <email>cromney@pointslope.com</email>
  </author>
  <url>http://github.com/xmlblog/acts_as_versioned/commit/96f915e943189b510cdd67242a7bb0d62c3ba066</url>
  <id>96f915e943189b510cdd67242a7bb0d62c3ba066</id>
  <committed-date>2009-06-12T14:56:21-07:00</committed-date>
  <authored-date>2009-06-12T14:56:21-07:00</authored-date>
  <message>Merged 1bd3d255 from technoweenie's branch</message>
  <tree>e59bdd4cf87994a3ee74232bca839c58f432c63c</tree>
  <committer>
    <name>Christian Romney</name>
    <email>cromney@pointslope.com</email>
  </committer>
</commit>
