<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,6 @@
 == master
 
+* Automatically determine the colspan for the last footer to match the number of headers
 * Fix default headers including all model columns when using :select in the collection query
 
 == 0.2.0 / 2009-04-25</diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,11 @@ module TableHelper
     end
     
     def html #:nodoc:
+      # Force the last cell to span the remaining columns
+      cells = row.cells.values
+      colspan = table.header.columns.length - cells[0..-2].inject(0) {|count, (name, cell)| count += (cell[:colspan] || 1).to_i}
+      cells.last[:colspan] ||= colspan if colspan &gt; 1
+      
       html_options = @html_options.dup
       html_options[:style] = &quot;display: none; #{html_options[:style]}&quot;.strip if table.empty? &amp;&amp; hide_when_empty
       </diff>
      <filename>lib/table_helper/footer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -44,8 +44,8 @@ end
 
 class FooterWithCellsTest &lt; Test::Unit::TestCase
   def setup
-    table = TableHelper::CollectionTable.new([Object.new])
-    @footer = TableHelper::Footer.new(table)
+    @table = TableHelper::CollectionTable.new([Object.new])
+    @footer = TableHelper::Footer.new(@table)
     @cell = @footer.cell :total, 20
   end
   
@@ -63,6 +63,19 @@ class FooterWithCellsTest &lt; Test::Unit::TestCase
     end_str
     assert_html_equal expected, @footer.html
   end
+  
+  def test_should_include_colspan_if_more_headers_than_footers
+    @table.header :title, :name, :value
+    
+    expected = &lt;&lt;-end_str
+      &lt;tfoot&gt;
+        &lt;tr&gt;
+          &lt;td class=&quot;object-total&quot; colspan=&quot;3&quot;&gt;20&lt;/td&gt;
+        &lt;/tr&gt;
+      &lt;/tfoot&gt;
+    end_str
+    assert_html_equal expected, @footer.html
+  end
 end
 
 class FooterWithEmptyCollectionTest &lt; Test::Unit::TestCase</diff>
      <filename>test/unit/footer_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b9e107d93ebc73d10a310ccd12401054057b822b</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </author>
  <url>http://github.com/pluginaweek/table_helper/commit/f06b813b71a974b1a58bff63f6669ce3bc26726f</url>
  <id>f06b813b71a974b1a58bff63f6669ce3bc26726f</id>
  <committed-date>2009-04-25T17:24:39-07:00</committed-date>
  <authored-date>2009-04-25T17:24:39-07:00</authored-date>
  <message>Automatically determine the colspan for the last footer to match the number of headers [#3 state:resolved]</message>
  <tree>d98280d7961698a48add29301608a5f93885ce37</tree>
  <committer>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </committer>
</commit>
