title: Why does a sleep between ActiveRecord#first calls change its behaviour?
body: <p>I've inherited some code written in ruby 1.8.7 with Rails ~> 2.3.15 and it contains a test which looks something like this:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class Wibble &lt; ActiveRecord::Base
    # Wibbles have integer primary keys and string names
  end
  
  def test
    create_two_wibbles
    w1 = Wibble.first
    sleep 2 # This sleep is necessary to
    w2 = Wibble.first
  
    w1.name = "Name for w1"
    w2.name = "Name for w2"
  
    w1.save
  
    w3 = Wibble.first
  
    assert(!w3.update_attributes(w2.attributes))
  end
  </code></pre>
  
  <p>That comment next to the sleep line hasn't been cut off, it literally says <code>This sleep is necessary to</code>.  Without that sleep, this test fails - removing it changes the behaviour somehow beyond making it run 2 seconds faster. I've been digging through the file's history in our version control system, and the messages were uninformative. I also cannot contact the original author of this test to figure out what they were trying to do.</p>
  
  <p>From my understanding, we're pulling the same record out of the database twice, editing it in two different ways, saving the first, and asserting that we can't then save the second. I suspect this is a test to make sure our database locks the table correctly, but surely if this were to fail our Wibbles would be fine, and ActiveRecord would be at fault. Nobody in the office can figure out why this test may have been necessary, nor what difference the sleep statement might make. Any ideas?</p>