<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -104,6 +104,13 @@ class Package &lt; ActiveRecord::Base
     self.name.downcase &lt;=&gt; other.name.downcase
   end
 
+  # If updated_at is nil (which is the case for some older records), return
+  # created_at as the value for updated_at. This is required because e.g. the
+  # sitemap relies on proper updated_at values.
+  def updated_at
+    super || self.created_at
+  end
+
   def description
     self.latest_version.description # for convenience
   end</diff>
      <filename>app/models/package.rb</filename>
    </modified>
    <modified>
      <diff>@@ -88,4 +88,14 @@ describe Package do
     (pkg.updated_at &gt; prev_time).should be_true
   end
 
+  it &quot;should return the created_at timestamp if updated_at is nil&quot; do
+    pkg = Package.make
+    pkg.updated_at.should == pkg.created_at
+    sql = &quot;UPDATE package SET updated_at = NULL where id = #{pkg.id}&quot;
+    ActiveRecord::Base.connection.execute(sql)
+    pkg.reload
+    pkg.attributes[&quot;updated_at&quot;].should == nil
+    pkg.updated_at.should == pkg.created_at
+  end
+
 end</diff>
      <filename>spec/models/package_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>33cfe54954996c5f85ebc2a8c5b25155e2334e5d</id>
    </parent>
  </parents>
  <author>
    <name>Bj&#248;rn Arild M&#230;land</name>
    <email>bjorn.maeland@gmail.com</email>
  </author>
  <url>http://github.com/hadley/crantastic/commit/3371b29165fb04ac86938f648adffc2bff875d48</url>
  <id>3371b29165fb04ac86938f648adffc2bff875d48</id>
  <committed-date>2009-07-03T07:27:41-07:00</committed-date>
  <authored-date>2009-07-03T07:27:41-07:00</authored-date>
  <message>If package#updated_at is nil (which is the case for some older records), return created_at instead of nil.</message>
  <tree>8fd1c638c928cea038e1e101e0fa220279b975b6</tree>
  <committer>
    <name>Bj&#248;rn Arild M&#230;land</name>
    <email>bjorn.maeland@gmail.com</email>
  </committer>
</commit>
